Nexus找不到项目pom.xml的签名。

9
我已经将一个多模块项目上传到中央仓库作为一个 bundle.jar 文件,并出现了以下问题:nexus sais the file is missing 因此 Nexus 找不到 pom.asc 文件。

但是如果文件在the file is available,它怎么可能丢失呢?


请不要在图片上添加链接...最好将消息粘贴到帖子中... - khmarbaise
@khmarbaise,我不知道该写什么才能让它容易理解。下到这里已经很难了。我担心如果我对链接进行数据混淆,有人会抛出“嘿,链接没有解析证书”的错误。或者它被关闭了,无法再现。 - Grim
我不知道,但我有一个多模块的工作项目,我将其推送到中央仓库:https://github.com/timmolter/XChart。也许比较一下你所拥有的内容可以得出线索... - herrtim
你使用了哪个命令来签名和部署它? - A_Di-Matteo
@A_Di-Matteo 我 不会 自动部署到 central-nexus(像 herrtim 一样),我是通过 mvn release:prepare release:perform 部署到项目主页,其中在主 POM 中设置了 <distributionManagement>。在将文件部署到项目主页后,我会调用 mvn clean repository:bundle-create gpg:sign 命令来创建 *-0.9.12.pom.asc*-bundle.jar 文件,并将 asc 文件复制到项目主页上指定的目录(第一个截图中指明)并上传 *-bundle.jar 到 central-nexus。 - Grim
4个回答

1
除了仓库管理器中的“活动”选项卡外,您还应该能够浏览到“内容”选项卡。请检查一下,在GAV坐标文件夹中是否找到所有文件。似乎暂存规则没有找到该文件。它可能不存在(在仓库管理器上..而不是您的本地文件系统!)
请查看我们的文档以获取有关如何使用Maven设置所有内容的进一步提示,包括演示视频和完全工作的示例项目。
另外,如果您遇到问题,请直接与我联系或在我们的OSSRH jira项目中提交问题,以便我可以调查特定的部署。

1
根据您的评论,您在执行以下步骤后遇到了Nexus错误:
  • mvn release:prepare release:perform
  • mvn clean repository:bundle-create gpg:sign,它会创建*-0.9.12.pom.asc文件和*-bundle.jar
该错误很可能与上述步骤有关,这可能不是在此情况下应用的正确顺序,因为:
  • maven-repository-plugin插件及其create-bundle目标将为Maven项目创建上传捆绑包。请注意,生成的*-bundle.jar文件不会附加到Maven构建中(根据其源代码),而是仅在项目target文件夹中生成该文件。
  • maven-gpg-plugin插件及其sign目标将使用GnuPG签署项目构件、POM和附加构件以进行部署。
  • 您在执行的第二步中调用了clean阶段,这基本上意味着在release:perform操作后删除target文件夹的内容。
作为此类:
  • 由于 clean 调用,您应该验证 bundle jar 的内容
  • 您实际上没有签署经过 clean 调用清理的 jar 文件或 bundle(如上所述),尽管提到的错误涉及 POM 文件而不是 jar 文件
  • 尽管 官方示例 指出应该这样做,但您正在从命令行执行 gpg:sign

Currently this is not easily accomplished. gpg signs the artifacts attached to the build at the point that gpg runs. However, we want to "inject" the gpg into the phases.
What MIGHT work is:

mvn verify gpg:sign install:install deploy:deploy   

However, if there are other plugins configured for phases after the verify phase, they will not be run.

因此,我将审查部署流程并遵循标准程序来签署项目工件。

(注意:粗体为我所加)。


你说jar文件,但只有一个jar,你指的是哪个jar文件?我肯定在bundle-create之前清除目标,因为我不喜欢在发布中有快照构建(正如您可能注意到的版本是0.9.12而不是0.9.12-SNAPSHOT)。如果jar没有签名,错误消息将不同。签名过程与标准程序没有区别,我只是把它作为目标,而你的标准程序则将其作为pom.xml的一部分。 - Grim
我提到了JAR文件,因为发布插件也会在发布过程中创建源代码和Javadoc JAR文件。这些JAR文件默认附加到构建中,并且因此被安装、部署和签名(如上所述)。签名过程是不同的:推荐的方法是将其包含在POM文件中,在验证阶段期间调用,该阶段在安装和部署阶段之前进行打包。根据官方文档,从命令行执行无法保证其正常工作。 - A_Di-Matteo
从我的角度来看,除了一个我已经拥有但不知道放在哪里的文件位置之外,一切都运行良好。 - Grim

1
对我而言,缺少*.asc文件导致了签名错误。我已经安装了gpg密钥并将其发送到ssh服务器。
根据使用Apache Maven部署到OSSRH - 简介,我们需要添加插件nexus-staging-maven-pluginnexus-staging-maven-plugin。然后,当您运行maven clean deploy时,它会将软件包发布到repo.maven.apache.org(在半小时内)。
这是一个pom.xml示例。
<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/maven-v4_0_0.xsd">
    ...
    <build>
        <plugins>
            ...
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.6.7</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
                </configuration>
            </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>
        </plugins>
    </build>

    <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>
</project>


Maven的settings.xml。
<!--maven connect nexus need user and password-->
<settings>
    <servers>
        <server>
            <id>ossrh</id>
            <username></username>
            <password></password>
        </server>
    </servers>

    <profiles>
        <profile>
            <id>ossrh</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <gpg.passphrase>gpg.passphrase
                </gpg.passphrase>
            </properties>
        </profile>
    </profiles>
</settings>


0

我认为这个信息是错误的。不需要.asc,我会发布一个错误报告并观察情况。


你发布了这个问题吗? - Quy Tang
@QuyTang 无法复现,我报告发生了什么。 - Grim

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接