Maven profiles and install

假装没事ソ 提交于 2019-12-06 05:31:21

Well, you could use the classifier attribute so that each profile creates a jar with the classifier, i.e. a unique jar for each environment. Here is a code snippet to illustrate this. When run with the dev profile (mvn -P dev install), it creates a jar with -dev classifier, like myapp-dev-0.0.1.jar

<project>
...
    <properties>
        <env></env>
    </properties>
...

    <build>
        <plugins>
            ...
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <classifier>${env}</classifier>
                </configuration>
            </plugin>
        </plugins>
    </build>


    <profiles>
        ...
        <profile>
            <id>dev</id>
            <properties>
                <env>dev</env>
            </properties>
            ...
        </profile>
    </profiles>

</project>

You run the usual mvn commands and can select the appropriate profile with -P http://maven.apache.org/guides/introduction/introduction-to-profiles.html So it dependends on which profile you chose, what gets installed in the repository.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!