12

nexus を使用して会社のローカル Maven リポジトリを作成したいと考えています。リポジトリは公共のインターネットから何もダウンロードしてはなりません。必要なものはすべてリポジトリに追加されます。開発者のローカル Maven インスタンスは、必要なライブラリとツールを会社の nexus からダウンロードする必要があります。settings.xml で次のようなミラーを使用して、これを行うことができました。

<mirror>
  <id>company-repository</id>
  <name>Company releases repository</name>
  <url>http://nexus.company.com/nexus/content/repositories/releases</url>
  <mirrorOf>*</mirrorOf>
</mirror>

このソリューションの問題は、リリース リポジトリしか指定できないことです。サードパーティとスナップショット リポジトリも検索に含めたいと考えています。誰がそれをどのように行うべきか考えていますか? ミラー タグは URL を 1 つだけ受け取ります。

また、次のようにデフォルトのプロファイルを定義してみました:

<profile>            
    <id>defaultProfile</id>
    <activation>
        <activeByDefault>true</activeByDefault>
    </activation>
    <repositories>
        <repository>
            <id>company-thirdparty-repo</id>
            <url>http://nexus.company.com//nexus/content/repositories/thirdparty</url>
            <releases>
                 <checksumPolicy>fail</checksumPolicy> 
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>company-releases-repo</id>
            <url>http://nexus.company.com/nexus/content/repositories/releases</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
            </snapshots>
            <releases>
                <enabled>true</enabled>
                <checksumPolicy>fail</checksumPolicy>
            </releases>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>central</id>
            <url>http://nexus.company.com/nexus/content/repositories/central</url>
            <releases>
                <enabled>true</enabled>
                <checksumPolicy>fail</checksumPolicy>
            </releases>
            <snapshots>
                <checksumPolicy>fail</checksumPolicy>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>            
</profile> 

そのソリューションの問題は、Maven がそれらのリポジトリから何かを見つけられない場合でも、repo.maven.apache.org からダウンロードすることです。どんな助けにも感謝します。ありがとう!

4

1 に答える 1

5

You can use combination of both:

Create a repository group for the proxies of remote public repo (assume you call it public). Use this to mirror the only default repository of Maven, which is "central"

For other repositories, just add it as repository/plugin repo

the settings.xml looks like this:

<settings>
    <mirrors>
        <mirror>
            <id>nexus</id>
            <mirrorOf>central</mirrorOf>
            <url>http://your/nexus/groups/public</url>
        </mirror>
    </mirrors>

    <profiles>
        <profile>
            <id>nexus</id>
            <repositories>
                <repository>
                    <!-- for you to override settings of central -->
                    <id>central</id>
                    <url>http://a.fake.host</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
                <repository>
                    <id>anotherRepo</id>
                    <url>http://your/nexus/groups/anotherRepo</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>

            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <!-- for you to override settings of central -->
                    <id>central</id>
                    <url>http://a.fake.host</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </pluginRepository>

                <pluginRepository>
                    <id>anotherRepo</id>
                    <url>http://your/nexus/groups/anotherRepo</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </pluginRepository>
            </pluginRepositories> 
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
</settings>
于 2012-09-04T06:55:19.840 に答える