以下Gradle脚本的build.gradle.kts版本是什么?
apply plugin: 'maven'
apply plugin: 'java'
sourceCompatibility = 7
targetCompatibility = 7
dependencies {
compile 'com.google.guava:guava:13.0.1'
compile 'joda-time:joda-time:2.1'
testCompile 'junit:junit:4.11'
testCompile 'org.mockito:mockito-core:1.9.5'
}
task writeNewPom << {
pom {
project {
groupId 'org.example'
artifactId 'test'
version '1.0.0'
inceptionYear '2008'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
}
}.writeTo("$buildDir/newpom.xml")
}
1- Gradle样本为here。
答案 0 :(得分:3)
我认为这与build.gradle.kts
文件相同:
plugins {
java
maven
}
java {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
repositories {
jcenter()
}
dependencies {
compile("com.google.guava:guava:13.0.1")
compile("joda-time:joda-time:2.1")
testCompile("junit:junit:4.11")
testCompile("org.mockito:mockito-core:1.9.5")
}
tasks {
"writeNewPom" {
doLast {
project.the<MavenPluginConvention>().pom {
project {
groupId = "org.example"
artifactId = "test"
version = "1.0.0"
withGroovyBuilder {
"inceptionYear"("2008")
"licenses" {
"license" {
"name"("The Apache Software License, Version 2.0")
"url"("http://www.apache.org/licenses/LICENSE-2.0.txt")
"distribution"("repo")
}
}
}
}
}.writeTo("$buildDir/newPom.xml")
}
}
}
您必须使用withGroovyBuilder
方法将无类型属性添加到模型