Подтвердить что ты не робот

Как использовать только локальный репозиторий для локальных сетей

Я хотел бы создать локальный репозиторий maven компании, используя nexus. Репозиторий не должен скачивать что-либо из общедоступного Интернета, все необходимое добавляется к репо. Разработчики local maven instanses должны загружать необходимые библиотеки и инструменты из компании 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.

Я также пробовал с определением профиля по умолчанию следующим образом:

<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. Буду признателен за любую помощь. Спасибо!

4b9b3361

Ответ 1

Вы можете использовать комбинацию обоих:

Создать группу репозитория для прокси удаленного удаленного репо (предположим, вы называете это общедоступным). Используйте это, чтобы отразить единственный репозиторий по умолчанию Maven, который является "центральным"

Для других репозиториев просто добавьте его как репозиторий/плагин репо

параметр settings.xml выглядит следующим образом:

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