仅允许存储库用于插件?

Allow repository only for plugins?

我可以限制 Maven 仅使用给定的 Nexus 存储库(组)来解析插件及其依赖项(并且不能用于项目本身的依赖项)吗?

目前,我使用 settings.xml 镜像 "public" 组中的所有内容:

<?xml version="1.0" encoding="UTF-8"?>

<settings>
    <mirrors>
        <mirror>
            <!--This sends everything to /public -->
            <id>nexus</id>
            <mirrorOf>*</mirrorOf>
            <url>http://ik-repo:8080/nexus/content/groups/public</url>
        </mirror>
    </mirrors>
    <profiles>
        <profile>           
            <id>nexus</id>
            <repositories>
                <repository>
                    <id>central</id>
                    <url>http://central</url>
                    <snapshots><enabled>true</enabled></snapshots>
                    <releases><enabled>true</enabled></releases>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>central</id>
                    <url>http://central</url>
                    <snapshots><enabled>true</enabled></snapshots>
                    <releases><enabled>true</enabled></releases>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <!--make the profile active all the time -->
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
</settings>

现在我想使用第二组 "pluginPublic"(除了 "public")用于解决插件的依赖关系。

背景如下:我想允许某些依赖项被 Maven 插件使用,但不允许每个开发人员访问它们以进行构建。

是的,您只需在 .m2/settings.xml

中设置 pluginRepositores
        <repositories>
            <repository>
                <id>central</id>
                <url>https://my.company/repo</url>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
            </repository>
        </repositories>

        <pluginRepositories>
            <pluginRepository>
                <id>central</id>
                <url>https://my.company/plugin_repo</url>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>

除了插件存储库组之外,我最终对所有内容都使用了镜像:

<settings>
    <mirrors>
        <mirror>
            <!--This sends everything to /public -->
            <id>nexus</id>
            <mirrorOf>*,!pluginpublic</mirrorOf>
            <url>http://ik-repo:8080/nexus/content/groups/public</url>
        </mirror>
    </mirrors>
    <profiles>
        <profile>           
            <id>nexus</id>
            <repositories>
                <repository>
                    <id>central</id>
                    <url>http://central</url>
                    <snapshots><enabled>true</enabled></snapshots>
                    <releases><enabled>true</enabled></releases>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>central</id>
                    <url>http://central</url>
                    <snapshots><enabled>true</enabled></snapshots>
                    <releases><enabled>true</enabled></releases>
                </pluginRepository>
                <pluginRepository>
                    <id>pluginpublic</id>
                    <url>http://ik-repo:8080/nexus/content/groups/pluginpublic/</url>
                    <snapshots><enabled>true</enabled></snapshots>
                    <releases><enabled>true</enabled></releases>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <!--make the profile active all the time -->
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
</settings>