后续问题:使用Maven仅签名jar并将其部署到Maven Central。构建和编译完全由Ant完成

【字号: 日期:2024-02-27浏览:26作者:雯心
如何解决后续问题:使用Maven仅签名jar并将其部署到Maven Central。构建和编译完全由Ant完成?

您的settings.xml文件配置是问题所在,因为您的服务器配置中的ID与distributionManagement中的条目不对应:

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

它们必须与distributionManagement中的条目相对应。

解决方法

请参阅后续问题: 后续部分2 –使用Maven仅将jar签名并部署到Maven Central。构建和编译完全由Ant完成

我的目标是让Maven签名并将 已创建的 jar 推送到MavenCentral。该三个jar

xbnjava-0.1.2.jarxbnjava-0.1.2-sources.jarxbnjava-0.1.2-javadoc.jar

位于 R:jeffyprogrammingbuildxbnjava-0.1.1download

这些jar由我的Ant构建过程独立创建。Maven不会以任何方式用于构建或编译我的项目-我只是用它来将罐子放在MavenCentral上。(在我上一个问题的帮助下,看来我的POM的签名部分至少与它所需要的接近。)

执行时mvn deploy,我得到错误Return code is: 401,ReasonPhrase:Unauthorized。Maven并没有要求我提供密钥密码,我希望它应该如此,而且我看不到此信息(保存的密钥的位置?)的配置位置。(对我来说,签名文件是新手,所以请原谅任何不正确的术语)。

(此外,该项目groupId位于com.github.xbn,但该xbn目录中没有目录

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

我已经为此打开了声呐支持票,尽管我不知道这是否是问题的一部分。)

诊断信息如下。如果有人可以提供指导,我真的很需要。谢谢。

这是我的pom.xml,位于

R:jeffyprogrammingsandboxxbnjavapom.xml

(请注意,罐子位于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:applicationsprogrammingapache-maven-3.2.2confsettings.xml

(M2_HOME环境变量设置为C:applicationsprogrammingapache-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>这是调用的输出 mvn deploy

[R:jeffyprogrammingsandboxxbnjava]mvn deploy > temp.txtTCC: C:applicationsprogrammingapache-maven-3.1.1binmvn.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:jeffyprogrammingsandboxxbnjavapom.xml to C:Usersjeffy.m2repositorycomgithubxbnxbnjava0.1.2-SNAPSHOTxbnjava-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.xmlUploading: https://oss.sonatype.org/content/repositories/snapshots/com/github/xbn/xbnjava/0.1.2-SNAPSHOT/xbnjava-0.1.2-20140716.150828-1.pom2/4 KB4/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再一次,这次使用 mvn deploy -e

[R:jeffyprogrammingsandboxxbnjava]mvn deploy -e >temp.txtTCC: C:applicationsprogrammingapache-maven-3.1.1binmvn.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:jeffyprogrammingsandboxxbnjavapom.xml to C:Usersjeffy.m2repositorycomgithubxbnxbnjava0.1.2-SNAPSHOTxbnjava-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.xmlUploading: https://oss.sonatype.org/content/repositories/snapshots/com/github/xbn/xbnjava/0.1.2-SNAPSHOT/xbnjava-0.1.2-20140716.142845-1.pom2/4 KB4/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 moreCaused 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 moreCaused 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.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 moreCaused 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 moreCaused 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

相关文章: