forked from pact-foundation/pact-jvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
62 lines (56 loc) · 2.64 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
apply plugin: 'maven-publish'
dependencies {
compile project(":pact-jvm-provider_${project.scalaVersion}"),
'org.apache.maven:maven-plugin-api:3.5.0',
'org.apache.maven.plugin-tools:maven-plugin-annotations:3.5'
compile 'org.apache.maven:maven-core:3.5.0'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlinVersion"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
compile "org.fusesource.jansi:jansi:${project.jansiVersion}"
}
import org.apache.tools.ant.taskdefs.condition.Os
def isWindows() {
Os.isFamily(Os.FAMILY_WINDOWS)
}
task pluginDescriptor(type: Exec, dependsOn: [":pact-jvm-provider_${project.scalaVersion}:install",
':pact-jvm-model:install',
":pact-jvm-matchers_${project.scalaVersion}:install",
':pact-jvm-pact-broker:install']) {
String mvn = 'mvn'
if (isWindows()) {
mvn = 'mvn.bat'
}
commandLine mvn, '-f', "${buildDir}/poms/pom.xml", '--settings',
'src/main/resources/settings.xml', '-e', '-B', 'org.apache.maven.plugins:maven-plugin-plugin:3.5:descriptor'
doFirst {
def pomFile = file("${buildDir}/poms/pom.xml")
def pom = install.repositories.mavenInstaller.pom
pom.packaging = 'maven-plugin'
pom.groupId = project.group
pom.artifactId = project.name
pom.version = version
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')
}
pom.writeTo( pomFile )
}
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
compileGroovy.dependsOn = []
compileKotlin {
classpath = classpath.plus(files(compileGroovy.destinationDir))
dependsOn compileGroovy
}