【发布时间】:2017-09-21 16:09:34
【问题描述】:
我正在为 gradle 使用 gradle 3.5 和 maven 插件。
我的任务是生成 pom.xml,由于 java 的源和目标版本,生成的 pom 是错误的。
这为 1.5 生成了一个 pom.xml(错误):
task createPom << {
pom {
project {
groupId 'com.domain.api'
artifactId 'gs-gradle'
version '0.1.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("pom.xml")
}
这会使gradle makePom 任务失败:
task createPom << {
pom {
project {
groupId 'com.domain.api'
artifactId 'gs-gradle'
version '0.1.0'
build {
plugins {
plugin {
groupId 'org.apache.maven.plugins'
artifactId 'maven-compiler-plugin'
version '3.7.0'
configuration {
source '1.8'
target '1.8'
}
}
}
}
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("pom.xml")
}
这是添加build 对象时的输出错误:
* What went wrong:
Execution failed for task ':createPom'.
> No such property: _SCRIPT_CLASS_NAME_ for class: org.apache.maven.model.Model
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
【问题讨论】:
-
您在尝试构建时是否收到来自 gradle 的错误消息?
标签: java maven gradle build.gradle maven-plugin