从gradle创建maven包装器pom.xml:不能创建<build>元素
我如何设置sourceDirectory
, testSourceDirectory
并在我使用gradle maven-plugin的pom
DSL创建的pom.xml中构建plugins
?
当我添加没有Closure
到我的DSL部分的build
,没关系..但是当我添加build { /* anything else, like actual compile plugins */}
它给了我这个错误:
Execution failed for task ':mavenWrapper'. > No such property: _SCRIPT_CLASS_NAME_ for class: org.apache.maven.model.Model
我猜Gradle将build
视为任务,而不是由org.sonatype.maven.polyglot.groovy.builder.ModelBuilder
生成的DSL谓词。
有没有办法强制build
被视为DSL的一部分? 它可以被施放什么?
现在我正在通过使用.withXml
解决这个问题,但是它非常冗长,而且维护起来也很少。
这里是我工作的缩写版本:
task mavenWrapper { doLast { delete 'pom.xml', 'mvnw', 'mvnw.cmd' pom { project { packaging 'pom' repositories { repository { id 'spring-milestones' name 'Spring Milestones' url 'https://repo.spring.io/libs-milestone' snapshots { enabled 'false' } } } properties { 'kotlin.compiler.incremental' 'true' } /* ******** Problem is here build { plugins { plugin { // ... etc. etc. } } } ******* */ dependencyManagement { dependencies { dependency { groupId 'org.jetbrains.kotlin' artifactId 'kotlin-stdlib-jre8' version "${kotlin_version}" scope 'compile' } } } } }.withXml { // Workaround for the missing build { ... } section above. asNode().appendNode('build').appendNode('plugins') // etc. etc. }.writeTo("${projectDir}/pom.xml") exec { commandLine 'mvn', '-N', 'io.takari:maven:wrapper', '-Dmaven=3.5.0' } } }
- 为什么在OnCreate()中设置ViewTreeObserver> OnScrollChangedListener不会在Android 2.x上调用?
- 在IntelliJ中找到文件,但不是在建立的jar
- 尝试在金丝雀上迁移5
- 未解决的参考:kotlinx – Kotlin 1-0-0-RC-1036
- 找不到id为`kotlin`的插件
- JaCoCo Gradle插件报告每个包的0.0类覆盖率
- RegisterResGeneratingTask已弃用,请使用registerGeneratedFolders(FileCollection)
- 如何跨多个Gradle项目共享样板Kotlin配置?
- 从gradle org.gradle.api.Project获取ClassLoader?
- Gradle kotlin-spring插件不能打开spring类
- kotlin-kapt插件不使用“kapt.generateStubs”