Gradle尝试两次发布maven的POM(通过uploadArchives
任务)
我有apply from:
的多项目构建,其中指定了如何发布我的工件(publish-jars.gradle
):
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
build.dependsOn(sourcesJar)
artifacts {
archives sourcesJar
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: 'releases repo') {
authentication(
userName: rootProject.properties.get('artifactory.username'),
password: rootProject.properties.get('artifactory.token')
)
}
snapshotRepository(url: 'snapshots repo) {
authentication(
userName: rootProject.properties.get('artifactory.username'),
password: rootProject.properties.get('artifactory.token')
)
}
}
}
}
def installer = install.repositories.mavenInstaller
def deployer = uploadArchives.repositories.mavenDeployer
[installer, deployer]*.pom*.whenConfigured { pom ->
pom.project {
packaging 'jar'
}
pom.withXml {
asNode().dependencies.'*'.each {
if (it.scope*.value != null) {
it.scope*.value = 'compile'
}
}
asNode().dependencyManagement.dependencies.'*'.each {
if (it.scope*.value != null) {
it.scope*.value = 'compile'
}
}
def repos = asNode().appendNode('repositories')
project.repositories.findAll { it.name != 'MavenLocal' }.each {
def repo = repos.appendNode('repository')
repo.appendNode('id', it.name)
repo.appendNode('name', it.name)
repo.appendNode('url', it.url)
}
}
if (project.hasProperty('pomConfigurer')) {
pom.withXml(pomConfigurer)
}
}
install.dependsOn build
uploadArchives.dependsOn build
task 'publish-snapshot'() {
dependsOn uploadArchives
}
task publish() {
dependsOn uploadArchives
}
我的模块只包含父pom(:my-project:parent
):
dependencyManagement {
generatedPomCustomization {
enabled = true
}
}
ext.pomConfigurer = {
// some pom configuration
}
最后我有root项目build.gradle:
allprojects {
apply plugin: 'maven'
apply plugin: 'io.spring.dependency-management'
}
subprojects {
apply from: file('publish-jars.gradle')
}
是不是有问题,或者我做错了什么?
UPD:Gradle输出
> Task :my-project:some-module:compileKotlin
> Task :my-project:some-other-module:compileKotlin
> Task :my-project:some-another-module:compileKotlin
> Task :my-project:some-yet-another-module:compileKotlin
> Task :my-project:one-more-module:compileKotlin
> Task :my-project:last-module:compileTestKotlin
> Task :mkGitTag
##teamcity[setParameter name='env.release_tag' value='v2.1.1-rc20']
> Task :my-project:parent:uploadArchives
Could not transfer artifact groupname:parent:pom:2.1.1-rc20 from/to remote (https://releases repo): Failed to transfer file: https://releases repo/groupname/parent/2.1.1-rc20/parent-2.1.1-rc20.pom. Return code is: 409, ReasonPhrase: Conflict.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':my-project:parent:uploadArchives'.
> Could not publish configuration 'archives'
> Failed to deploy artifacts: Could not transfer artifact groupname:parent:pom:2.1.1-rc20 from/to remote (https://releases repo): Failed to transfer file: https://releases repo/groupname/parent/2.1.1-rc20/test-parent-2.1.1-rc20.pom. Return code is: 409, ReasonPhrase: Conflict.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 22s
43 actionable tasks: 43 executed