maven存储库订单

时间:2012-12-04 15:31:15

标签: maven maven-3

我有一个maven repo,它存储了

下的所有工件

http://example.com/content/public

我有第二个回购,它存储

下的不同工件

http://example.com/content/type1

默认情况下,我想从“content / public”

获取所有构建

但是对于一个标志打开时的一个特定用例,我想从“content / type1”获取工件

如果没有工件,那么我想在“content / public”中找到它

我的apache-maven / 3.04./ conf / settings.xml看起来像这样

<mirrors>
    <mirror>
        <!-- This sends everything else to /public -->
        <id>nexus</id>
        <mirrorOf>*,!type1</mirrorOf>
        <url>http://example.com/content/public</url>
    </mirror>
</mirrors>
<profiles>

    <profile>
        <id>nexus</id>
        <!-- Enable snapshots for the built in central repo to direct -->
        <!-- all requests to nexus via the mirror -->
        <repositories>
            <repository>
                <id>central</id>
                <url>http://central</url>
                <releases><enabled>true</enabled></releases>
                  <snapshots><enabled>true</enabled><updatePolicy>never</updatePolicy></snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>central</id>
                <url>http://central</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>true</enabled></snapshots>
            </pluginRepository>
        </pluginRepositories>

        <properties>
            <!-- Default this property so we can create references easily. -->
            <nexusHostName>example.com</nexusHostName>
        </properties>
    </profile>
</profiles>
<activeProfiles>
    <!-- make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
</activeProfiles>

我在pom.xml中的个人资料看起来像这样

<profile>
        <id>type1-build</id>
        <activation>
            <property>
                <name>type1</name>
                <value>true</value>
            </property>
        </activation>

        <repositories>
            <repository>
                <id>type1</id>
                <name>Type1 Repo</name>
                <url>http://${nexusHostName}/content/groups/type1/</url>
                <layout>default</layout>
                <!-- Enforce strict checksums and always update releases and snapshots -->
                <releases>
                    <enabled>true</enabled>
                    <checksumPolicy>fail</checksumPolicy>
                    <updatePolicy>always</updatePolicy>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <checksumPolicy>fail</checksumPolicy>
                    <updatePolicy>always</updatePolicy>
                </snapshots>
            </repository>
            <repository>
                <id>nexus</id>
                <name>Nexus</name>
                <url>http://${nexusHostName}/content/groups/public/</url>
                <layout>default</layout>
                <!-- Enforce strict checksums and always update releases and snapshots -->
                <releases>
                    <enabled>false</enabled>
                    <checksumPolicy>fail</checksumPolicy>
                    <updatePolicy>always</updatePolicy>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <checksumPolicy>fail</checksumPolicy>
                    <updatePolicy>always</updatePolicy>
                </snapshots>
            </repository>
        </repositories>

    </profile>

即使在我执行了像mvn goal1 -Dtype1 = true这样的目标之后,它仍会在“内容/公共”中查找工件

有人可以告诉我,我做错了什么

1 个答案:

答案 0 :(得分:0)

首先更改存储库内容/ type1的顺序,然后再更改content / public