1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

nexus 3でMAVENリポジトリの作成

Last updated at Posted at 2020-09-12

内容

タイトルどおり。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.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に追加すれば良い。

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日費やした。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?