maven - Maven deploy 创建两个不同的 sonatype 存储库
问题描述
我正在尝试使用 Travis CI 将发布工件从 github 自动上传到 Maven Central (Sonatype) 来构建 CI 流程。基本上,一切正常,除了最后;我从我的 Maven 部署命令中获得了两个不同的 Nexus 存储库:一个用于 pom 和 jar;第二个是源代码、javadoc 和签名。
我的猜测是,由于中间的元数据上传,他创建了两个存储库:
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ darksky-client ---
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.pom (5.3 kB at 212 kB/s)
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/1.0.12/plexus-1.0.12.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus/1.0.12/plexus-1.0.12.pom (9.8 kB at 392 kB/s)
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar (251 kB at 4.0 MB/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.jar
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.jar (41 kB at 4.6 kB/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.pom
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.pom (4.7 kB at 14 kB/s)
[INFO] Downloading from ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/maven-metadata.xml
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/maven-metadata.xml
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/maven-metadata.xml (312 B at 34 B/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1-sources.jar
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1-sources.jar (26 kB at 65 kB/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1-javadoc.jar
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1-javadoc.jar (182 kB at 439 kB/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.jar.asc
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.jar.asc (819 B at 7.3 kB/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.pom.asc
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1.pom.asc (819 B at 5.9 kB/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1-sources.jar.asc
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1-sources.jar.asc (819 B at 6.7 kB/s)
[INFO] Uploading to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1-javadoc.jar.asc
[INFO] Uploaded to ossrh: https://oss.sonatype.org/service/local/staging/deploy/maven2/be/skylark/weather/darksky-client/1.0.1/darksky-client-1.0.1-javadoc.jar.asc (819 B at 7.1 kB/s)
仍然 ; 我不明白为什么,以及如何解决它。
我的 pom.xml 看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>be.skylark.weather</groupId>
<artifactId>darksky-client</artifactId>
<version>1.0.1</version>
<name>darksky-client</name>
<description>Rest Client library for the darksky API</description>
<url>https://github.com/skylarkbe/darksky-client/</url>
<licenses>
<license>
<name>GNU GENERAL PUBLIC LICENSE V3</name>
<url>http://www.gnu.org/licenses/gpl.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<name>Romain Van der Keilen</name>
<email>somemail@gmail.com</email>
</developer>
</developers>
<scm>
<url>https://github.com/skylarkbe/darksky-client/</url>
<connection>scm:git:git://github.com/skylarkbe/darksky-client.git</connection>
<developerConnection>scm:git:git@github.com:skylarkbe/darksky-client.git</developerConnection>
</scm>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/skylarkbe/darksky-client/issues</url>
</issueManagement>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
</distributionManagement>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<jersey.client.version>2.26-b03</jersey.client.version>
<junit.jupiter.version>5.4.2</junit.jupiter.version>
<junit.test.excludes>**/*IntegrationTest.java</junit.test.excludes>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey.client.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey.client.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.6</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- To run tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<configuration>
<excludes>
<exclude>${junit.test.excludes}</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>release</id>
<activation>
<property>
<name>release</name>
</property>
</activation>
<build>
<plugins>
<!-- To attach sources -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- To generate javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- To sign the artifacts -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
使用 travis CI 工具的一些附加设置:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<!-- Maven Central Deployment -->
<id>ossrh</id>
<username>${env.SONATYPE_USERNAME}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
</servers>
<profiles>
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.executable>${env.GPG_EXECUTABLE}</gpg.executable>
<gpg.passphrase>${env.GPG_PASSWORD}</gpg.passphrase>
</properties>
</profile>
</profiles>
</settings>
Travis用来构建的maven命令如下
mvn --settings .travis.settings.xml install -DskipTests=true -Dgpg.skip -Dmaven.javadoc.skip=true -B -V
用于部署的一个如下
mvn clean deploy --settings .travis.settings.xml -DskipTests=true -Prelease -B
GPG 正在正确执行以签署工件;这只是上传到临时存储库的最后一步让我头疼......
在此先感谢您的帮助 :)
解决方案
可能这更像是一个 travis / sonatype 配置问题,而不是一个 Maven 问题。
我终于能够正确上传所有内容;但我不得不:
<build>
<plugins>
<!-- Disable default maven deploy plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
然后在我的发布配置文件中:
<!-- Uses Sonatype deploy plugin -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
感谢您的帮助和见解!
推荐阅读
- c# - 将“DataGridView 值”绘制到图表(线或点)
- node.js - 如何在 Node AWS Lambda 中检索输入查询参数
- javascript - Axios - 用é替换重音,例如
- swift - 出现错误“AVCapturePhotoOutput”不可用
- amazon-web-services - 豁免资源使用自己的集成,而其他资源使用 AWS API GW 代理集成
- maven - maven可以生成包含源代码的jar吗
- rest - 分享点休息 api GetFolderById 返回 System.IO.FileNotFoundException
- vb.net - 如何使用 vsto powerpoint 删除所有图像占位符 powerpoint
- android - 使用 ListAdapter 在 android recyclerview 中缺少默认动画
- vim - VIM - 改变内部?还是选择里面?