Maven 多模块发布
Posted
技术标签:
【中文标题】Maven 多模块发布【英文标题】:Maven Multi Module Release 【发布时间】:2016-08-25 10:01:11 【问题描述】:所以,我无法理解发生了什么。 我有一个这种结构的项目:
Aggregator Pom
|
+- Parent Pom
|
+- SubModule 1 (whose parent is "Parent Pom")
|
+- SubModule 2 (whose parent is "SubModule 1")
都是pom包装。
我这几天一直在与发布插件作斗争。我运行了一个版本,它成功地部署到了 maven Central。但是,Parent Pom、SubModule 1 和 SubModule 2 的版本是下一个 snapshot 版本。
它是由 TeamCity 执行的,但基本上它运行的是这样的:
mvn -P sign-artifacts -B release:clean release:prepare --batch-mode -Dtag=0.1.0 -DreleaseVersion=0.1.0 -DdevelopmentVersion=0.2.0-SNAPSHOT -Dscm.tag=0.1.0 -Dproject.rel.aggregator pom groupId:aggregator pom artifactId=0.1.0 -Dproject.dev.aggregator pom groupId:aggregator pom artifactId=0.2.0-SNAPSHOT
然后:
mvn -P sign-artifacts -B release:perform -P sign-artifacts
(“sign-artifacts”配置文件负责 GPG 签名)
在 maven Central 中,我看到 Parent Pom、SubModule 1 和 SubModule 2 在那里,它们的元数据显示它们的版本是 0.1.0,但是当我下载每个的 pom 时,我看到版本是 0.2.0-SNAPSHOT .
任何想法什么是错的,以及如何解决?
提前致谢,
天啊
编辑: 一些输出:
[INFO] Checking out the project to perform the release ...
[INFO] Executing: /bin/sh -c cd /home/builduser/agent03/work/4ae459b9554b762f/target && git clone --branch 0.25.0 git@github.com:wix/wix-oss-parents.git /home/builduser/agent03/work/4ae459b9554b762f/target/checkout
[INFO] Working directory: /home/builduser/agent03/work/4ae459b9554b762f/target
...
[INFO] Executing: /bin/sh -c cd /home/builduser/agent03/work/4ae459b9554b762f/target/checkout && git fetch git@github.com:wix/wix-oss-parents.git
[INFO] Working directory: /home/builduser/agent03/work/4ae459b9554b762f/target/checkout
[INFO] Executing: /bin/sh -c cd /home/builduser/agent03/work/4ae459b9554b762f/target/checkout && git checkout 0.25.0
[INFO] Working directory: /home/builduser/agent03/work/4ae459b9554b762f/target/checkout
...
[INFO] Invoking perform goals in directory /home/builduser/agent03/work/4ae459b9554b762f/target/checkout
[INFO] Executing goals 'deploy'...
[DEBUG] Using $maven.home of: '/home/builduser/agent03/tools/maven3_1'.
[DEBUG] Executing: /bin/sh -c cd /home/builduser/agent03/work/4ae459b9554b762f/target/checkout && /home/builduser/agent03/tools/maven3_1/bin/mvn -B -X -D maven.repo.local=/home/builduser/.m2/repository -s /home/builduser/agent03/temp/buildTmp/release-settings8995574762584519955.xml -D performRelease=true -P artifactory deploy
[INFO] Inspecting build with total of 4 modules...
[INFO] Installing Nexus Staging features:
...
[DEBUG] Goal: org.sonatype.plugins:nexus-staging-maven-plugin:1.6.7:deploy (injected-nexus-deploy)
[DEBUG] Style: Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
[INFO] <configuration>
[INFO] <altStagingDirectory>$altStagingDirectory</altStagingDirectory>
[INFO] <artifact default-value="$project.artifact"/>
[INFO] <attachedArtifacts default-value="$project.attachedArtifacts"/>
[INFO] <autoDropAfterRelease default-value="true">$autoDropAfterRelease</autoDropAfterRelease>
[INFO] <autoReleaseAfterClose default-value="false">false</autoReleaseAfterClose>
[INFO] <detectBuildFailures default-value="true">$detectBuildFailures</detectBuildFailures>
[INFO] <keepStagingRepositoryOnCloseRuleFailure>$keepStagingRepositoryOnCloseRuleFailure</keepStagingRepositoryOnCloseRuleFailure>
[INFO] <keepStagingRepositoryOnFailure>$keepStagingRepositoryOnFailure</keepStagingRepositoryOnFailure>
[INFO] <mavenSession default-value="$session"/>
[INFO] <mojoExecution default-value="$mojoExecution"/>
[INFO] <nexusUrl>https://oss.sonatype.org/</nexusUrl>
[INFO] <offline default-value="$settings.offline"/>
[INFO] <packaging default-value="$project.packaging"/>
[INFO] <pluginArtifactId default-value="$plugin.artifactId"/>
[INFO] <pluginGroupId default-value="$plugin.groupId"/>
[INFO] <pluginVersion default-value="$plugin.version"/>
[INFO] <pomFile default-value="$project.file"/>
[INFO] <serverId>os-s-rh</serverId>
[INFO] <skipLocalStaging>$skipLocalStaging</skipLocalStaging>
[INFO] <skipNexusStagingDeployMojo>$skipNexusStagingDeployMojo</skipNexusStagingDeployMojo>
[INFO] <skipRemoteStaging>$skipRemoteStaging</skipRemoteStaging>
[INFO] <skipStaging>$skipStaging</skipStaging>
[INFO] <skipStagingRepositoryClose>$skipStagingRepositoryClose</skipStagingRepositoryClose>
[INFO] <sslAllowAll default-value="false">$maven.wagon.http.ssl.allowall</sslAllowAll>
[INFO] <sslInsecure default-value="false">$maven.wagon.http.ssl.insecure</sslInsecure>
[INFO] <stagingDescription>$stagingDescription</stagingDescription>
[INFO] <stagingProfileId>$stagingProfileId</stagingProfileId>
[INFO] <stagingProgressPauseDurationSeconds default-value="3">$stagingProgressPauseDurationSeconds</stagingProgressPauseDurationSeconds>
[INFO] <stagingProgressTimeoutMinutes default-value="5">$stagingProgressTimeoutMinutes</stagingProgressTimeoutMinutes>
[INFO] <stagingRepositoryId>$stagingRepositoryId</stagingRepositoryId>
[INFO] <updateReleaseInfo>$updateReleaseInfo</updateReleaseInfo>
[INFO] </configuration>
...
[INFO] Executing: /bin/sh -c cd /home/builduser/agent03/work/4ae459b9554b762f/target/checkout/wix-oss-parents-parent && git log -n1 --date-order HEAD
[INFO] Working directory: /home/builduser/agent03/work/4ae459b9554b762f/target/checkout/wix-oss-parents-parent
[DEBUG] GitLatestRevisionCommandConsumer consumeLine : commit 4875b5de9d40f8a00be37e25d3548755b1f044f4
...
[DEBUG] GitLatestRevisionCommandConsumer consumeLine : [maven-release-plugin] prepare release 0.25.0
[INFO] Executing: /bin/sh -c cd /home/builduser/agent03/work/4ae459b9554b762f/target/checkout/wix-oss-parents-parent && git pull git@github.com:wix/wix-oss-parents.git HEAD
[INFO] Working directory: /home/builduser/agent03/work/4ae459b9554b762f/target/checkout/wix-oss-parents-parent
[INFO] Executing: /bin/sh -c cd /home/builduser/agent03/work/4ae459b9554b762f/target/checkout/wix-oss-parents-parent && git diff --raw 4875b5de9d40f8a00be37e25d3548755b1f044f4
[INFO] Working directory: /home/builduser/agent03/work/4ae459b9554b762f/target/checkout/wix-oss-parents-parent
...
[INFO] Executing: /bin/sh -c cd /home/builduser/agent03/work/4ae459b9554b762f/target/checkout/wix-oss-parents-parent && git log -n1 --date-order HEAD
[INFO] Working directory: /home/builduser/agent03/work/4ae459b9554b762f/target/checkout/wix-oss-parents-parent
[DEBUG] GitLatestRevisionCommandConsumer consumeLine : commit b5c5fa4e2a0c16d9247ae9261a67aeb4b1f09dda
...
[DEBUG] GitLatestRevisionCommandConsumer consumeLine : [maven-release-plugin] prepare for next development iteration
[INFO] Storing revision in 'scm.revision' project property.
[INFO] Project at revision b5c5fa4e2a0c16d9247ae9261a67aeb4b1f09dda
...
[INFO] --- maven-gpg-plugin:1.6:sign (sign-artifacts) @ wix-oss-parents-parent ---
...
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-gpg-plugin:1.6:sign' with basic configurator -->
[DEBUG] (f) ascDirectory = /home/builduser/agent03/work/4ae459b9554b762f/target/checkout/wix-oss-parents-parent/target/gpg
[DEBUG] (f) defaultKeyring = true
[DEBUG] (f) interactive = false
[DEBUG] (f) keyname = ***
[DEBUG] (f) passphraseServerId = ***
[DEBUG] (f) project = MavenProject: com.wix:wix-oss-parents-parent:0.25.0 @ /home/builduser/agent03/work/4ae459b9554b762f/target/checkout/wix-oss-parents-parent/pom.xml
[DEBUG] (f) settings = org.apache.maven.execution.SettingsAdapter@f08fdce
[DEBUG] (f) skip = false
[DEBUG] (f) useAgent = true
[DEBUG] -- end configuration --
[DEBUG] Generating signature for /home/builduser/agent03/work/4ae459b9554b762f/target/checkout/wix-oss-parents-parent/target/wix-oss-parents-parent-0.25.0.pom
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ wix-oss-parents-parent ---
...
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-install-plugin:2.4:install' with basic configurator -->
[DEBUG] (f) artifact = com.wix:wix-oss-parents-parent:pom:0.25.0
[DEBUG] (f) attachedArtifacts = [com.wix:wix-oss-parents-parent:pom.asc:0.25.0]
[DEBUG] (f) createChecksum = false
[DEBUG] (f) localRepository = id: local
[INFO] url: file:///home/builduser/.m2/repository/
[INFO] layout: none
[DEBUG] (f) packaging = pom
[DEBUG] (f) pomFile = /home/builduser/agent03/work/4ae459b9554b762f/target/checkout/wix-oss-parents-parent/pom.xml
[DEBUG] (s) skip = false
[DEBUG] (f) updateReleaseInfo = false
[DEBUG] -- end configuration --
...
[INFO] Installing /home/builduser/agent03/work/4ae459b9554b762f/target/checkout/wix-oss-parents-parent/pom.xml to /home/builduser/.m2/repository/com/wix/wix-oss-parents-parent/0.25.0/wix-oss-parents-parent-0.25.0.pom
...
[DEBUG] Installing com.wix:wix-oss-parents-parent/maven-metadata.xml to /home/builduser/.m2/repository/com/wix/wix-oss-parents-parent/maven-metadata-local.xml
[INFO] Installing /home/builduser/agent03/work/4ae459b9554b762f/target/checkout/wix-oss-parents-parent/target/wix-oss-parents-parent-0.25.0.pom.asc to /home/builduser/.m2/repository/com/wix/wix-oss-parents-parent/0.25.0/wix-oss-parents-parent-0.25.0.pom.asc
...
[DEBUG] Installing com.wix:wix-oss-parents-parent/maven-metadata.xml to /home/builduser/.m2/repository/com/wix/wix-oss-parents-parent/maven-metadata-local.xml
...
[INFO] --- nexus-staging-maven-plugin:1.6.7:deploy (injected-nexus-deploy) @ wix-oss-parents-parent ---
...
Configuring mojo 'org.sonatype.plugins:nexus-staging-maven-plugin:1.6.7:deploy' with basic configurator -->
[DEBUG] (f) artifact = com.wix:wix-oss-parents-parent:pom:0.25.0
[DEBUG] (f) attachedArtifacts = [com.wix:wix-oss-parents-parent:pom.asc:0.25.0]
[DEBUG] (f) autoDropAfterRelease = true
[DEBUG] (f) autoReleaseAfterClose = true
[DEBUG] (f) detectBuildFailures = true
[DEBUG] (f) mavenSession = org.apache.maven.execution.MavenSession@4ebadd3d
[DEBUG] (f) mojoExecution = org.sonatype.plugins:nexus-staging-maven-plugin:1.6.7:deploy execution: injected-nexus-deploy
[DEBUG] (f) nexusUrl = https://oss.sonatype.org/
[DEBUG] (f) offline = false
[DEBUG] (f) packaging = pom
[DEBUG] (f) pluginArtifactId = nexus-staging-maven-plugin
[DEBUG] (f) pluginGroupId = org.sonatype.plugins
[DEBUG] (f) pluginVersion = 1.6.7
[DEBUG] (f) pomFile = /home/builduser/agent03/work/4ae459b9554b762f/target/checkout/wix-oss-parents-parent/pom.xml
[DEBUG] (f) serverId = os-s-rh
[DEBUG] (f) sslAllowAll = false
[DEBUG] (f) sslInsecure = false
[DEBUG] (f) stagingProgressPauseDurationSeconds = 3
[DEBUG] (f) stagingProgressTimeoutMinutes = 5
[DEBUG] -- end configuration --
...
[INFO] Performing local staging (local stagingDirectory="/home/builduser/agent03/work/4ae459b9554b762f/target/checkout/wix-oss-parents-parent/target/nexus-staging/staging")...
...
关于.m2,这是一个构建代理;它得到一个新的.m2 ...
有什么想法吗?
【问题讨论】:
找到根本原因; maven scm 插件中的错误 【参考方案1】:嗯……在你的解释中我不太清楚……
首先我认为在这种情况下项目结构不是问题......
通常的行为是:
-
我有一个项目 1.0-SNAPSHOT..
我使用 maven 发布插件发布它..
这被标记为 1.0 并提交到 tags 文件夹中
然后将主干\分支版本增加为 1.1-SNAPSHOT..
看来您正在下载主干版本,并且正在将标记版本检查到远程存储库中......
这是对的吗?
如果不是,那是某种与插件执行有关的奇怪版本,你能检查一下 SVN 标签,告诉我那里的 pom 是哪个版本,以及创建标签的提交的注释?
这两个命令的输出也可以帮助理解发生了什么......
Lat 的东西,可能不相关,但是您是否将工件下载到 .m2 本地存储库中,您可以清理它并重试吗?这不是 .m2 第一次做一些奇怪的事情了 :)
【讨论】:
ivoroJavaBoy,感谢您的回复。我不认为你建议的场景是正确的。以下是一些输出: [13:10:33][INFO] 检查项目以执行发布... [13:10:33][INFO] 执行:/bin/sh -c cd /home/ builduser/agent03/work/4ae459b9554b762f/target && git clone --branch 0.25.0 git@github.com:wix/wix-oss-parents.git /home/builduser/agent03/work/4ae459b9554b762f/target/checkout [13: 10:33][INFO] 工作目录:/home/builduser/agent03/work/4ae459b9554b762f/target ...(更多内容在下一条评论中) [13:10:35][INFO] 执行:/bin/sh -c cd /home/builduser/agent03/work/4ae459b9554b762f/target/checkout && git fetch git@github.com: wix/wix-oss-parents.git [13:10:35][INFO] 工作目录:/home/builduser/agent03/work/4ae459b9554b762f/target/checkout [13:10:35][INFO] 执行:/bin /sh -c cd /home/builduser/agent03/work/4ae459b9554b762f/target/checkout && git checkout 0.25.0 [13:10:35][INFO] 工作目录:/home/builduser/agent03/work/4ae459b9554b762f/target /checkout ...(接下来会更多) 算了,这行不通。我将尝试在“编辑”中提供输出 对不起,看输出我不知道......但问题是你的解释中缺少一些东西......我的意思是,你说描述符是 0.1。 0 但 pom 是 0.2.0-SNAPSHOT 并且似乎是不可能的,因为部署参数取自 pom.xml ......现在例如......如果你创建一个新项目,并添加依赖项 0.1.0 和建造它..它建造吗?如果是这样?如果下载的工件 pom.xml 版本是 0.1.0 或 0.2.0-SNAPSHOT,你能检查一下 .m2 里面吗?如果你能做这个测试,它会给我们更多的信息.. 对不起,但这不是批评,做检查我问他他可以找到他问题的答案,所以是的,这是一个答案......以上是关于Maven 多模块发布的主要内容,如果未能解决你的问题,请参考以下文章