内容
タイトルどおり。deployがなかなかできなかったのでメモメモ
maven3 install
最初にデータ領域を設定します。
docker volume create nexus-data
上のデータ域を設定して起動すれば、次の起動時にデータが残ってます。
docker run -d -p 8081:8081 --name nexus -v nexus-data:/nexus-data sonatype/nexus3
で、一発起動!私の環境はwindows10 home wsl2であります。
このあと、
docker exec -it nexus bash
で/nexus-dataにadmin.passwodファイルがあるので、このパスワードをメモ。
ブラウザからlocalhost:8081で画面を表示して、右上の「admin」をクリック
最終設定を聞いてくるので、これを設定すればおしまい。
ちょっとレポジトリの説明
nexusには「proxy」と「hosted」と「group」というレポジトリの設定があります。
それぞれのアドレスは
http://localhost:8081/repository/maven-proxy これがproxy(downloadしたものを保存)
http://localhost:8081/repository/maven-releases これがhosted(upload領域)
http://localhost:8081/repository/maven-snapshots これもhosted(upload領域)
http://localhost:8081/repository/maven-public これは上の3つのグループの総称
というのを理解したところで、次の設定
settigs.xml
<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">
<offline>false</offline>
<mirrors>
<mirror>
<id>aaaa</id>
<url>http://localhost:8088/repository/meaven-public</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<localRepository>C:/maven/repository</localRepository>
<profiles>
<profile>
<id>aaaa</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>aaaa</activeProfile>
</activeProfiles>
<servers>
<server>
<id>releases</id>
<username>admin</username>
<password>[設定したpsw]</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>[設定したpsw]</password>
</server>
</servers>
</settings>
ここのpasswordがnetの情報はadmin123とかなっていたんで、かなり時間がかかった。
distributionManagement
最後にdistributionManagementを各pom.xmlに書かねばならんのだが下の宣言を
親pomに設定しておけば、それぞれは書く必要がない。まあ、わからなければ全部の
pom.xmlに追加すれば良い。
<distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8088/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8088/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
deployも成功!
mvn installだけであれば、もう少し簡単なんだが、せっかくなのでmeven3にupload=deploy
したいので、ちょっと1日費やした。