我怎样才能把一个groovy任务gradle转换成Gradle Kotlin DSL来生成一个pom.xml?

下面的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样本在这里 。

    One Solution collect form web for “我怎样才能把一个groovy任务gradle转换成Gradle Kotlin DSL来生成一个pom.xml?”

    我相信这是一个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.withConvention(MavenPluginConvention::class) { 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方法将无types的属性添加到模型中

    Kotlin language will be the best programming language for Android.