我正在尝试将Java包部署到Maven中央存储库。为此,我将这些插件包含在pom.xml中:
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<id>deploy</id>
<phase>deploy</phase>
<goals><goal>deploy</goal></goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
然后,我运行:
mvn clean javadoc:jar source:jar gpg:sign deploy -Dmaven.test.skip=true
输出不包含任何错误,并且我的项目文件夹现在包含一个像这样的文件夹目标:
+-- target
| +-- apidocs
| +-- classes
| +-- generated-sources
| +-- javadoc-bundle-options
| +-- maven-archiver
| +-- maven-status
| +-- myproject.jar
| +-- myproject.pom
| +-- myproject.pom.asc
| +-- myproject-javadoc.jar
| +-- myproject-javadoc.jar.asc
| +-- myproject-sources.jar
| +-- myproject-sources.jar.asc
如您所见,没有myproject.jar.asc文件,这与在h3xStream的评论中遇到this issue的问题相同。 所以,我做到了:
gpg -ab myproject.jar
它创建了一个myproject.jar.asc文件。我以为我终于可以部署该程序包了,但是在运行时:
mvn javadoc:jar source:jar gpg:sign deploy -Dmaven.test.skip=true
我在Nexus Repository Manager上再次看到myproject.jar.asc丢失了。
有人对如何部署此myproject.jar.asc文件有想法,以便我可以发布我的软件包吗?
(我对Java完全陌生,只是遵循了the official documentation中的步骤)。
提前谢谢!