当前位置: 首页 > 知识库问答 >
问题:

后续问题:使用Maven只在Maven Central上签名和部署jars。构建和编译完全使用ant完成

督建柏
2023-03-14

请参阅后续问题:后续第2部分——使用Maven仅对JAR进行签名并将其部署到Maven Central。构建和编译完全由Ant完成

这是对这个问题的跟进:如何使用Maven只签三个罐子并将其推向Maven Central?

我的目标是让马文签名并把已经制作好的罐子推到马文中心。三个罐子

  • xbnjava-0.1.2。jar
  • xbnjava-0.1.2-sources。jar
  • xbnjava-0.1.2-javadoc。jar

位于R:\jeffy\programming\build\xbnjava-0.1.1\download

这些JAR是由我的Ant构建过程独立创建的。Maven不用于以任何方式构建或编译我的项目——我只是用它将JAR放在Maven Central上。(在我上一个问题的帮助下,我的POM的签约部分似乎至少更接近于它所需要的。)

当执行mvn部署时,我得到的错误返回代码是:401,原因短语:未授权。Maven没有向我询问我的密钥-密码,我希望它应该这样做,我也没有看到这个信息(我保存的密钥的位置?)的配置。(签名文件对我来说是新的,所以请原谅任何不正确的术语)。

(此外,该项目的groupIdcom.github.xbn,但在中没有xbn目录。)

https://oss.sonatype.org/content/repositories/snapshots/com/github/

关于这一点,我已经在sonatype上打开了一张支持票,尽管我不知道这是否是问题的一部分。)

诊断信息如下。如果有人能提供指导,我真的很需要。非常感谢。

这是我的pom。xml,位于

R:\jeffy\programming\sandbox\xbnjava\pom。xml

(请注意,JAR位于build目录中,而不是沙箱中。)

    <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">
       <modelVersion>4.0.0</modelVersion>
       <groupId>com.github.xbn</groupId>
       <artifactId>xbnjava</artifactId>
       <packaging>pom</packaging>
       <version>0.1.2-SNAPSHOT</version>
       <name>XBN-Java</name>
       <url>https://github.com/aliteralmind/xbnjava</url>
       <inceptionYear>2014</inceptionYear>
       <organization>
          <name>Jeff Epstein</name>
       </organization>
       <description>XBN-Java is a collection of generically-useful backend (server side, non-GUI) programming utilities, featuring RegexReplacer and FilteredLineIterator. XBN-Java is the foundation of Codelet (http://codelet.aliteralmind.com).</description>

       <parent>
          <groupId>org.sonatype.oss</groupId>
          <artifactId>oss-parent</artifactId>
          <version>7</version>
       </parent>

       <licenses>
          <license>
             <name>Lesser General Public License (LGPL) version 3.0</name>
             <url>https://www.gnu.org/licenses/lgpl-3.0.txt</url>
          </license>
          <license>
             <name>Apache Software License (ASL) version 2.0</name>
             <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
          </license>
       </licenses>

       <developers>
          <developer>
             <name>Jeff Epstein</name>
             <email>aliteralmind-github@yahoo.com</email>
             <roles>
                <role>Lead Developer</role>
             </roles>
          </developer>
       </developers>

       <issueManagement>
          <system>GitHub Issue Tracker</system>
          <url>https://github.com/aliteralmind/xbnjava/issues</url>
       </issueManagement>

       <distributionManagement>
          <snapshotRepository>
             <id>ossrh</id>
             <url>https://oss.sonatype.org/content/repositories/snapshots</url>
          </snapshotRepository>
       </distributionManagement>

       <scm>
          <connection>scm:git:git@github.com:aliteralmind/xbnjava.git</connection>
          <url>scm:git:git@github.com:aliteralmind/xbnjava.git</url>
          <developerConnection>scm:git:git@github.com:aliteralmind/xbnjava.git</developerConnection>
       </scm>

       <properties>
          <java.version>1.7</java.version>
          <jarprefix>../build/${project.artifactId}-${project.version}/download/${project.artifactId}-${project.version}</jarprefix>
       </properties>

       <profiles>
          <!--
          This profile will sign the JAR file, sources file, and javadocs file using the GPG key on the local machine.
          See: https://docs.sonatype.org/display/Repository/How+To+Generate+PGP+Signatures+With+Maven
          -->
          <profile>
             <id>release-sign-artifacts</id>
             <activation>
                <property>
                   <name>release</name>
                   <value>true</value>
                </property>
             </activation>
             <build>
                <plugins>
                   <plugin>
                      <groupId>org.codehaus.mojo</groupId>
                      <artifactId>build-helper-maven-plugin</artifactId>
                      <version>1.8</version>
                      <executions>
                         <execution>
                            <id>attach-artifacts</id>
                            <phase>package</phase>
                            <goals>
                               <goal>attach-artifact</goal>
                            </goals>
                            <configuration>
                               <artifacts>
                                  <artifact>
                                     <file>${jarprefix}.jar</file>
                                     <type>jar</type>
                                  </artifact>
                                  <artifact>
                                     <file>${jarprefix}-javadoc.jar</file>
                                     <type>jar</type>
                                     <classifier>javadoc</classifier>
                                  </artifact>
                                  <artifact>
                                     <file>${jarprefix}-sources.jar</file>
                                     <type>jar</type>
                                     <classifier>sources</classifier>
                                  </artifact>
                               </artifacts>
                            </configuration>
                         </execution>
                      </executions>
                   </plugin>
                </plugins>
             </build>
          </profile>
       </profiles>
</project>

我的settings.xml,它位于

C:\applications\programming\apache-maven-3.2.2\conf\settings。xml

(将M2_HOME环境变量设置为C:\应用程序\编程\apache-maven-3.2.2

<?xml version="1.0" encoding="UTF-8"?>
<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>
         <id>sonatype-nexus-snapshots</id>
         <username>aliteralmind</username>
         <password>MY_SONATYPE_DOT_COM_PASSWORD </password>
      </server>
      <server>
         <id>sonatype-nexus-staging</id>
         <username>aliteralmind</username>
         <password>MY_SONATYPE_DOT_COM_PASSWORD </password>
      </server>
   </servers>

   <pluginGroups></pluginGroups>
   <proxies></proxies>
   <mirrors></mirrors>
   <profiles></profiles>
</settings>
[R:\jeffy\programming\sandbox\xbnjava]mvn deploy > temp.txt
TCC: C:\applications\programming\apache-maven-3.1.1\bin\mvn.bat [182]  Missing SETLOCAL

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building XBN-Java 0.1.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ xbnjava ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ xbnjava ---
[INFO] Installing R:\jeffy\programming\sandbox\xbnjava\pom.xml to C:\Users\jeffy\.m2\repository\com\github\xbn\xbnjava\0.1.2-SNAPSHOT\xbnjava-0.1.2-SNAPSHOT.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ xbnjava ---
Downloading: https://oss.sonatype.org/content/repositories/snapshots/com/github/xbn/xbnjava/0.1.2-SNAPSHOT/maven-metadata.xml

Uploading: https://oss.sonatype.org/content/repositories/snapshots/com/github/xbn/xbnjava/0.1.2-SNAPSHOT/xbnjava-0.1.2-20140716.150828-1.pom
2/4 KB
4/4 KB

(失败部分:)

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.407 s
[INFO] Finished at: 2014-07-16T11:08:29-04:00
[INFO] Final Memory: 7M/19M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xbnjava: Failed to deploy artifacts: Could not transfer artifact com.github.xbn:xbnjava:pom:0.1.2-20140716.150828-1 from/to ossrh (https://oss.sonatype.org/content/repositories/snapshots): Failed to transfer file: https://oss.sonatype.org/content/repositories/snapshots/com/github/xbn/xbnjava/0.1.2-SNAPSHOT/xbnjava-0.1.2-20140716.150828-1.pom. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[R:\jeffy\programming\sandbox\xbnjava]mvn deploy -e >temp.txt
TCC: C:\applications\programming\apache-maven-3.1.1\bin\mvn.bat [182]  Missing SETLOCAL

[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building XBN-Java 0.1.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ xbnjava ---
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ xbnjava ---
[INFO] Installing R:\jeffy\programming\sandbox\xbnjava\pom.xml to C:\Users\jeffy\.m2\repository\com\github\xbn\xbnjava\0.1.2-SNAPSHOT\xbnjava-0.1.2-SNAPSHOT.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ xbnjava ---
Downloading: https://oss.sonatype.org/content/repositories/snapshots/com/github/xbn/xbnjava/0.1.2-SNAPSHOT/maven-metadata.xml

Uploading: https://oss.sonatype.org/content/repositories/snapshots/com/github/xbn/xbnjava/0.1.2-SNAPSHOT/xbnjava-0.1.2-20140716.142845-1.pom
2/4 KB
4/4 KB

(失败部分:)

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.357 s
[INFO] Finished at: 2014-07-16T10:28:45-04:00
[INFO] Final Memory: 6M/16M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xbnjava: Failed to deploy artifacts: Could not transfer artifact com.github.xbn:xbnjava:pom:0.1.2-20140716.142845-1 from/to ossrh (https://oss.sonatype.org/content/repositories/snapshots): Failed to transfer file: https://oss.sonatype.org/content/repositories/snapshots/com/github/xbn/xbnjava/0.1.2-SNAPSHOT/xbnjava-0.1.2-20140716.142845-1.pom. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xbnjava: Failed to deploy artifacts: Could not transfer artifact com.github.xbn:xbnjava:pom:0.1.2-20140716.142845-1 from/to ossrh (https://oss.sonatype.org/content/repositories/snapshots): Failed to transfer file: https://oss.sonatype.org/content/repositories/snapshots/com/github/xbn/xbnjava/0.1.2-SNAPSHOT/xbnjava-0.1.2-20140716.142845-1.pom. Return code is: 401, ReasonPhrase: Unauthorized.
  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
  at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
  at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
  at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
  at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
  at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
  at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
  at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
  at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
  at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:606)
  at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
  at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
  at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
  at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to deploy artifacts: Could not transfer artifact com.github.xbn:xbnjava:pom:0.1.2-20140716.142845-1 from/to ossrh (https://oss.sonatype.org/content/repositories/snapshots): Failed to transfer file: https://oss.sonatype.org/content/repositories/snapshots/com/github/xbn/xbnjava/0.1.2-SNAPSHOT/xbnjava-0.1.2-20140716.142845-1.pom. Return code is: 401, ReasonPhrase: Unauthorized.
  at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:193)
  at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
  at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
  ... 19 more
Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact com.github.xbn:xbnjava:pom:0.1.2-20140716.142845-1 from/to ossrh (https://oss.sonatype.org/content/repositories/snapshots): Failed to transfer file: https://oss.sonatype.org/content/repositories/snapshots/com/github/xbn/xbnjava/0.1.2-SNAPSHOT/xbnjava-0.1.2-20140716.142845-1.pom. Return code is: 401, ReasonPhrase: Unauthorized.
  at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:143)
  at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:167)
  at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:149)
  ... 21 more
Caused by: org.eclipse.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact com.github.xbn:xbnjava:pom:0.1.2-20140716.142845-1 from/to ossrh (https://oss.sonatype.org/content/repositories/snapshots): Failed to transfer file: https://oss.sonatype.org/content/repositories/snapshots/com/github/xbn/xbnjava/0.1.2-SNAPSHOT/xbnjava-0.1.2-20140716.142845-1.pom. Return code is: 401, ReasonPhrase: Unauthorized.
  at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:337)
  at org.html" target="_blank">eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:268)
  at org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:413)
  at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:139)
  ... 23 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact com.github.xbn:xbnjava:pom:0.1.2-20140716.142845-1 from/to ossrh (https://oss.sonatype.org/content/repositories/snapshots): Failed to transfer file: https://oss.sonatype.org/content/repositories/snapshots/com/github/xbn/xbnjava/0.1.2-SNAPSHOT/xbnjava-0.1.2-20140716.142845-1.pom. Return code is: 401, ReasonPhrase: Unauthorized.
  at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$6.wrap(WagonRepositoryConnector.java:1016)
  at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$6.wrap(WagonRepositoryConnector.java:1004)
  at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:895)
  at org.eclipse.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:522)
  at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:331)
  ... 26 more
Caused by: org.apache.maven.wagon.TransferFailedException: Failed to transfer file: https://oss.sonatype.org/content/repositories/snapshots/com/github/xbn/xbnjava/0.1.2-SNAPSHOT/xbnjava-0.1.2-20140716.142845-1.pom. Return code is: 401, ReasonPhrase: Unauthorized.
  at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:573)
  at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:493)
  at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:474)
  at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:454)
  at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:871)
  ... 28 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

共有1个答案

廉博赡
2023-03-14

您的settings.xml文件配置是问题导致您的Id在您的服务器配置不对应的条目在分发管理:

<distributionManagement>
  <snapshotRepository>
    <id>ossrh</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
  </snapshotRepository>
</distributionManagement>

您必须使用以下服务器ID:

<server>
  <id>ossrh</id>
  <username>username</username>
  <password>password</password>
</server>

它们必须与分发管理中的条目相对应。

 类似资料:
  • 问题内容: 请参阅后续问题: 后续部分2 –使用Maven仅将jar签名并部署到Maven Central。构建和编译完全由Ant完成 我的目标是让Maven签名并将 已创建的 jar 推送到Maven Central。该三个jar 位于 这些jar由我的Ant构建过程独立创建。Maven不会以任何方式用于构建或编译我的项目-我只是用它来将罐子放在Maven Central上。(在我上一个问题的帮

  • 问题内容: 这是以下 问题 的后续措施: 后续问题:使用Maven仅将jar签名并部署到Maven Central。构建和编译完全由Ant完成 多亏了对先前问题的回答,以及声纳支持人员的一些建议,我才有了我的第一个“永无止境”。这是当前的输出: 根据此日志,以下文件已上传到 https://oss.sonatype.org/content/repositories/snapshots/com/gi

  • 以下是后续问题:使用Maven只对JAR进行签名并将其部署到Maven Central。构建和编译完全由Ant完成 感谢前面问题的答案,以及sonatype支持人员的一些建议,我刚刚经历了第一次“非失败”。以下是的当前输出: 根据该日志,以下文件已上载到 https://oss.sonatype.org/content/repositories/snapshots/com/github/alite

  • 我的团队正在使用功能分支来实现新功能,并不断将快照构建部署到远程存储库中供我们的用户使用。因此,“部署”实际上只意味着“分发到远程Maven存储库”。我们目前只为master分支运行持续集成构建,而不是功能分支,原因如下:我们使用Maven构建我们的项目并将JavaDoc和源代码与JAR一起分发。 我现在的计划是为每个功能分支构建添加一个分类器,并期望在创建和部署如下工件时使用该分类器: > 分支

  • 没有任何好的插件来使用Maven构建本机代码。native-maven-plugin是一个非常严格的构建系统,除其他外,这使得调试结果的二进制文件变得困难。您必须手动将本机Maven-Plugin构建系统与用于调试的本机IDE同步。 Maven没有替换部署的pom.xml文件中的变量:MNG-2971、MNG-4223。这意味着库必须在每个Maven配置文件中声明一次特定于平台的依赖关系(而不是声

  • 我们的构建系统使用ANT进行代码编译,使用MAVEN生成编译/运行时类路径和静态预处理。我们正在为我们的端到端构建生命周期采用MAVEN,我认为这不会很快发生。因此,在此期间,我们决定使用Maven创建一个打包工件。为此,我最终使用了maven-assembly-plugin,只是因为我可以从ant编译的工件中输入创建包所需的内容,这是我通过在POM中定义一个程序集描述符来实现的。然而,我们还希望