gradle artifactory 插件无法使用 groupID 发布
gradle artifactory plugin fails to publish with groupID
在我的 build.gradle 脚本中,当 groupId 未定义时发布有效。我想使用 "org.company.foobar.common" 作为 groupId。
当我取消注释以下 build.gradle 脚本中的 groupId 行时,我收到错误消息。脚本下面是定义了这个groupId时的执行结果
buildscript {
repositories {
maven { url "http://tribe.ust.doj.gov:8085/artifactory/jcenter/"}
maven { url "http://tribe.ust.doj.gov:8085/artifactory/MavenCentral/"}
maven { url "http://tribe.ust.doj.gov:8085/artifactory/gradlePlugins/"}
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release"
}
}
repositories {
maven { url "http://tribe.ust.doj.gov:8085/artifactory/jcenter/"}
maven { url "http://tribe.ust.doj.gov:8085/artifactory/MavenCentral/"}
maven { url "http://tribe.ust.doj.gov:8085/artifactory/gradlePlugins/"}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: "com.jfrog.artifactory"
def getArtifactoryUrl() {
return "http://tribe.ust.doj.gov:8085/artifactory/"
}
allprojects {
repositories {
def artifactoryMcentralUrl = getArtifactoryUrl() + "MavenCentral/"
maven {url artifactoryMcentralUrl }
}
}
dependencies {
}
sourceSets {
main {
java {
srcDir "/src"
}
}
}
//project.group = 'org.company.foobar.common'
task printProps {
doLast {
println artifactory_user
println artifactory_contextUrl
//println project.group
}
}
publishing {
publications {
mavenJava(MavenPublication) {
//groupId project.group
artifactId project.getName()
version '1.0.0'
from components.java
}
}
}
artifactory {
def artifactoryUrl = getArtifactoryUrl()
contextUrl = artifactoryUrl
publish {
repository {
repoKey = 'libs-snapshot-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
}
defaults {
publications('mavenJava')
publishArtifacts = true
publishPom = true
}
}
}
使用 groupId(未注释)时 "gradle artifactoryPublish" 的输出是:
$ gradle artifactoryPublish
:generatePomFileForMavenJavaPublication
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:artifactoryPublish
Deploying artifact: http://tribe.ust.doj.gov:8085/artifactory/libs-snapshot-local/org/company/foobar/common/kambucha/1.0.0/kambucha-1.0.0.jar
:artifactoryPublish FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':artifactoryPublish'.
> java.io.IOException: Failed to deploy file. Status code: 409 Response message: Artifactory returned the following errors:
The repository 'libs-snapshot-local' rejected the resolution of an artifact 'libs-snapshot-local:org/company/foobar/common/kambucha/1.0.0/kambucha-1.0.0.jar' due to conflict in the snapshot release handling policy. Status code: 409
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.84 secs
看起来,您正在尝试将 RELEASE 工件发布到 SNAPSHOT 存储库。在 Artifactory 中使用 Maven 存储库时,您需要确保同时遵循 Maven 布局和发布/快照策略。
在此特定示例中,您的问题似乎如下:
Artifactory 遵循 Maven 政策,识别以下路径:
'libs-snapshot-local:org/company/foobar/common/kambucha/1.0.0/kambucha-1.0.0.jar' 作为一个版本,而存储库设置为仅处理快照。为了让这个特定的路径起作用,并且如果这真的是一个快照工件,您需要将路径更改为:
libs-snapshot-local:org/company/foobar/common/kambucha/1.0.0-SNAPSHOT/kambucha-1.0.0-SNAPSHOT.jar
如果这是一个版本,请更改您的部署路径以使用 'libs-release-local' 存储库
您可以阅读有关存储库配置的更多信息here
在我的 build.gradle 脚本中,当 groupId 未定义时发布有效。我想使用 "org.company.foobar.common" 作为 groupId。
当我取消注释以下 build.gradle 脚本中的 groupId 行时,我收到错误消息。脚本下面是定义了这个groupId时的执行结果
buildscript {
repositories {
maven { url "http://tribe.ust.doj.gov:8085/artifactory/jcenter/"}
maven { url "http://tribe.ust.doj.gov:8085/artifactory/MavenCentral/"}
maven { url "http://tribe.ust.doj.gov:8085/artifactory/gradlePlugins/"}
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release"
}
}
repositories {
maven { url "http://tribe.ust.doj.gov:8085/artifactory/jcenter/"}
maven { url "http://tribe.ust.doj.gov:8085/artifactory/MavenCentral/"}
maven { url "http://tribe.ust.doj.gov:8085/artifactory/gradlePlugins/"}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: "com.jfrog.artifactory"
def getArtifactoryUrl() {
return "http://tribe.ust.doj.gov:8085/artifactory/"
}
allprojects {
repositories {
def artifactoryMcentralUrl = getArtifactoryUrl() + "MavenCentral/"
maven {url artifactoryMcentralUrl }
}
}
dependencies {
}
sourceSets {
main {
java {
srcDir "/src"
}
}
}
//project.group = 'org.company.foobar.common'
task printProps {
doLast {
println artifactory_user
println artifactory_contextUrl
//println project.group
}
}
publishing {
publications {
mavenJava(MavenPublication) {
//groupId project.group
artifactId project.getName()
version '1.0.0'
from components.java
}
}
}
artifactory {
def artifactoryUrl = getArtifactoryUrl()
contextUrl = artifactoryUrl
publish {
repository {
repoKey = 'libs-snapshot-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
}
defaults {
publications('mavenJava')
publishArtifacts = true
publishPom = true
}
}
}
使用 groupId(未注释)时 "gradle artifactoryPublish" 的输出是:
$ gradle artifactoryPublish
:generatePomFileForMavenJavaPublication
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:artifactoryPublish
Deploying artifact: http://tribe.ust.doj.gov:8085/artifactory/libs-snapshot-local/org/company/foobar/common/kambucha/1.0.0/kambucha-1.0.0.jar
:artifactoryPublish FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':artifactoryPublish'.
> java.io.IOException: Failed to deploy file. Status code: 409 Response message: Artifactory returned the following errors:
The repository 'libs-snapshot-local' rejected the resolution of an artifact 'libs-snapshot-local:org/company/foobar/common/kambucha/1.0.0/kambucha-1.0.0.jar' due to conflict in the snapshot release handling policy. Status code: 409
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.84 secs
看起来,您正在尝试将 RELEASE 工件发布到 SNAPSHOT 存储库。在 Artifactory 中使用 Maven 存储库时,您需要确保同时遵循 Maven 布局和发布/快照策略。 在此特定示例中,您的问题似乎如下: Artifactory 遵循 Maven 政策,识别以下路径: 'libs-snapshot-local:org/company/foobar/common/kambucha/1.0.0/kambucha-1.0.0.jar' 作为一个版本,而存储库设置为仅处理快照。为了让这个特定的路径起作用,并且如果这真的是一个快照工件,您需要将路径更改为: libs-snapshot-local:org/company/foobar/common/kambucha/1.0.0-SNAPSHOT/kambucha-1.0.0-SNAPSHOT.jar
如果这是一个版本,请更改您的部署路径以使用 'libs-release-local' 存储库
您可以阅读有关存储库配置的更多信息here