【发布时间】:2018-07-12 09:00:19
【问题描述】:
我正在尝试使用 Ant 进行构建,并使用 Gradle 将我的 jar 和 pom 发布到 Artifactory,但有些运气不佳。希望没有用完,因为我需要/希望这发生。
task createPom() {
pom {
project {
groupId "${groupId}"
artifactId 'pluginmanager'
version "${version}"
}
}.writeTo('pom.xml')
}
def pomfile = file('pom.xml')
task publishPom(type: Upload) {
dependsOn 'createPom'
artifacts {
archives pomfile
}
repositories {
"${artifactory_url}"
}
}
artifactory() {
publish {
repository {
repoKey = "${repoKey}"
}
}
}
artifactoryPublish {
dependsOn 'publishPom'
}
现在很明显,我如何 writeTo('pom.xml') 然后创建(def)pomfile,但这就是我迷失如何使这项工作的地方。在 writeTo 部分,当我将档案定义为“pomfile.xml”时,我无法传入 pomfile 变量和 publishPom 工件块,我得到“无法转换提供的 PublishArtifact 类型对象的表示法:pom.xml”错误,它告诉我使用“文件实例”。但是,当我传入 pomfile 变量时,我得到一个新错误,“没有为属性'工件'指定值。”
我的 Gradle 任务 createPom() 有效,但我无法运行 publishPom()。现在可能已经很明显了。
【问题讨论】:
-
问题 - 为什么?为什么不直接使用Ivy?
-
被告知我必须这样做。我在一家国防公司工作,所以我们能做的事情有一定的限制。对于这个项目,我们不想完全转换为 Gradle。我们几乎不需要构建它,所以只想使用 Gradle 进行发布。这可能是一个失败的原因,但我需要证明这一点。我们不再/不能使用 Ivy。
标签: java maven gradle groovy ant