maven のライブラリのリリースではまったことのメモ
maven ではじめて自分ののライブラリを maven central にリリースしようとした時のメモです
現象
以下の参考記事を見ながらリリースをしてみようとしていました
その際にいざ mvn -DperformRelease=true deploy でリリースすると Return code is: 401, ReasonPhrase: Unauthorized. のようなエラーが出るように..
解決策
pom.xml に書いた設定と `$HOME/.m2/settings.xml に書いた設定のずれが問題でした。
$HOME/.m2/settings.xml
<distributionManagement>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>sonatype-nexus-staging</id>
<name>Nexus Release Repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
- pom.xml
<servers>
<server>
<id>ossrh</id>
<username><JIRA_USERID></username>
<password><JIRA_PASSWORD></password>
</server>
</servers>
これだと id がずれてしまっていて 、正しく認証情報が使われないんですね。正しく書いたものは以下のようです
<servers>
<server>
<id>sonatype-nexus-snapshots</id>
<username><JIRA_USERID></username>
<password><JIRA_PASSWORD></password>
</server>
<server>
<id>sonatype-nexus-staging</id>
<username><JIRA_USERID></username>
<password><JIRA_PASSWORD></password>
</server>
</servers>
これでリリースができるようになりました