forked from pact-foundation/pact-jvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
60 lines (53 loc) · 3.03 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
dependencies {
api project(":provider:pact-jvm-provider")
compile 'org.apache.maven:maven-plugin-api:3.6.0',
'org.apache.maven.plugin-tools:maven-plugin-annotations:3.6.0'
compile 'org.apache.maven:maven-core:3.6.0'
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
compile "org.fusesource.jansi:jansi:${project.jansiVersion}"
testCompile "org.codehaus.groovy:groovy-nio:${project.groovyVersion}:indy"
testRuntime "org.junit.vintage:junit-vintage-engine:${project.junit5Version}"
}
import org.apache.tools.ant.taskdefs.condition.Os
def isWindows() {
Os.isFamily(Os.FAMILY_WINDOWS)
}
task generatePom(type: GenerateMavenPom, dependsOn: [":provider:pact-jvm-provider:publishToMavenLocal",
':core:pact-jvm-core-model:publishToMavenLocal',
':core:pact-jvm-core-matchers:publishToMavenLocal',
':core:pact-jvm-core-pact-broker:publishToMavenLocal',
':core:pact-jvm-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', project.mavenPluginPluginVersion)
pluginNode.appendNode('configuration').appendNode('goalPrefix', 'pact')
def repository = asNode().appendNode('repositories').appendNode('repository')
repository.appendNode('id', 'jcenter')
repository.appendNode('name', 'jcenter')
repository.appendNode('url', 'https://jcenter.bintray.com')
}
}
task pluginDescriptor(type: Exec, dependsOn: generatePom) {
if (isWindows()) {
commandLine 'mvn.bat', '-f', "${buildDir}/poms/pom.xml", '--settings',
'src/main/resources/settings.xml', '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:3.5:descriptor'
} else {
commandLine 'sh', '-c', "mvn -f ${buildDir}/poms/pom.xml --settings src/main/resources/settings.xml -e -B org.apache.maven.plugins:maven-plugin-plugin:3.5:descriptor"
}
doLast {
final pluginDescriptor = file("${project.compileKotlin.destinationDir}/META-INF/maven/plugin.xml")
assert pluginDescriptor.file, "[$pluginDescriptor.canonicalPath] was not created"
}
}
pluginDescriptor.shouldRunAfter project.jar
project.jar.dependsOn pluginDescriptor