Gradle构建解析Maven2快照的方式与Maven构建不同



我正在使用Nexus OSS 3.x,我有一个自定义库,我正在使用Nexus staging maven插件部署到我的Nexus存储库中。我使用maven部署目标来部署快照。然后,我可以将该快照作为依赖项包含在另一个Maven项目的pom.xml中,并适当地解析正确的带时间戳的快照。问题是,当我现在试图在Gradle构建中包含快照依赖项时,Gradle正试图删除不正确的版本。我注意到,在创建的maven-metadata.xml中,Gradle实际上正在尝试解析my-lib-2.0.0-20200225.163947-14jar,而我的maven构建正确地解析为my-lib-2.0.0-202002 25.163945-13jar

<metadata modelVersion="1.1.0">
<groupId>com.mycompany</groupId>
<artifactId>my-lib</artifactId>
<version>2.0.0-SNAPSHOT</version>
<versioning>
<snapshot>
<timestamp>20200225.163947</timestamp>
<buildNumber>14</buildNumber>
</snapshot>
<lastUpdated>20200225163947</lastUpdated>
<snapshotVersions>
<snapshotVersion>
<classifier>sources</classifier>
<extension>jar</extension>
<value>2.0.0-20200225.163945-13</value>
<updated>20200225163947</updated>
</snapshotVersion>
<snapshotVersion>
<extension>jar</extension>
<value>2.0.0-20200225.163945-13</value>
<updated>20200225163947</updated>
</snapshotVersion>
<snapshotVersion>
<extension>pom</extension>
<value>2.0.0-20200225.163945-13</value>
<updated>20200225163947</updated>
</snapshotVersion>
</snapshotVersions>
</versioning>
</metadata>

我发现了问题所在。事实证明,我使用的nexus staging maven插件导致了这种情况。我从pom.xml中删除了该插件(如下所示(,并默认为标准的maven部署插件,它解决了版本差异(如下所述(

这是我使用的插件。删除它解决了我的问题

<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${nexus-staging-plugin.version}</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>

删除了上面的nexus特定插件后,我现在得到了一致的时间戳&快照上的内部版本号:

<metadata modelVersion="1.1.0">
<groupId>com.mycompany</groupId>
<artifactId>my-lib</artifactId>
<version>2.0.0-SNAPSHOT</version>
<versioning>
<snapshot>
<timestamp>20200225.174453</timestamp>
<buildNumber>22</buildNumber>
</snapshot>
<lastUpdated>20200225174453</lastUpdated>
<snapshotVersions>
<snapshotVersion>
<extension>jar</extension>
<value>2.0.0-20200225.174453-22</value>
<updated>20200225174453</updated>
</snapshotVersion>
<snapshotVersion>
<extension>pom</extension>
<value>2.0.0-20200225.174453-22</value>
<updated>20200225174453</updated>
</snapshotVersion>
<snapshotVersion>
<classifier>sources</classifier>
<extension>jar</extension>
<value>2.0.0-20200225.174453-22</value>
<updated>20200225174453</updated>
</snapshotVersion>
</snapshotVersions>
</versioning>
</metadata>

相关内容

  • 没有找到相关文章

最新更新