-
-
Notifications
You must be signed in to change notification settings - Fork 480
/
build.gradle
76 lines (65 loc) · 3.13 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
plugins {
id 'au.com.dius.pact.kotlin-library-conventions'
}
description = 'Pact-JVM - Pact Maven plugin'
group = 'au.com.dius.pact.provider'
dependencies {
api project(":provider")
implementation 'org.apache.maven:maven-plugin-api:3.8.1'
implementation 'org.apache.maven.plugin-tools:maven-plugin-annotations:3.6.1'
implementation 'org.apache.maven:maven-core:3.8.6'
implementation 'com.github.ajalt:mordant:1.2.1'
testImplementation 'junit:junit'
testImplementation 'org.apache.groovy:groovy'
testImplementation 'org.apache.groovy:groovy-nio'
testRuntimeOnly 'net.bytebuddy:byte-buddy'
testRuntimeOnly 'org.objenesis:objenesis:3.1'
testRuntimeOnly 'ch.qos.logback:logback-classic'
}
import org.apache.tools.ant.taskdefs.condition.Os
def isWindows() {
Os.isFamily(Os.FAMILY_WINDOWS)
}
task generatePom(type: GenerateMavenPom, dependsOn: [":provider:publishToMavenLocal",
':core:model:publishToMavenLocal',
':core:matchers:publishToMavenLocal',
':core:pactbroker:publishToMavenLocal',
':core:support:publishToMavenLocal']) {
destination = file("${buildDir}/poms/pom.xml")
pom = publishMavenPublicationPublicationToMavenLocal.publication.pom
pom.packaging = 'maven-plugin'
pom.withXml {
def buildNode = asNode().appendNode('build')
buildNode.appendNode('directory', buildDir)
buildNode.appendNode('outputDirectory', "$buildDir/classes/kotlin/main")
//add and configure the maven-plugin-plugin so that we can use the shortened 'pact' prefix
//https://maven.apache.org/guides/introduction/introduction-to-plugin-prefix-mapping.html
def pluginNode = buildNode.appendNode('plugins').appendNode('plugin')
pluginNode.appendNode('artifactId', 'maven-plugin-plugin')
pluginNode.appendNode('version', '3.5')
pluginNode.appendNode('configuration').appendNode('goalPrefix', 'pact')
}
}
if (System.env.CI != 'true') {
task pluginDescriptor(type: Exec, dependsOn: generatePom) {
if (isWindows()) {
try {
// check if mvn.bat exists
def proc = new ProcessBuilder('mvn.bat', '-v')
proc.start().waitFor()
commandLine 'mvn.bat', '-f', "${buildDir}/poms/pom.xml", '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:3.6.1:descriptor'
} catch(Exception e) {
commandLine 'mvn.cmd', '-f', "${buildDir}/poms/pom.xml", '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:3.6.1:descriptor'
}
} else {
commandLine 'sh', '-c', "mvn -f ${buildDir}/poms/pom.xml -e -B org.apache.maven.plugins:maven-plugin-plugin:3.6.1:descriptor"
}
doLast {
final dir = project.compileKotlin.destinationDirectory.dir('META-INF/maven').get()
final pluginDescriptor = dir.file('plugin.xml').getAsFile()
assert pluginDescriptor.exists(), "[$pluginDescriptor.canonicalPath] was not created"
}
}
pluginDescriptor.shouldRunAfter project.jar
project.jar.dependsOn pluginDescriptor
}