简体   繁体   中英

Configurable outputDirectory for maven war plugin using Git

I have put up a maven project on git repository which is using maven-war-plugin to create war directly in tomcat directory. But on different systems, tomcat directory path can be different.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <outputDirectory><file-path></outputDirectory>
            </configuration>
        </plugin>

I want this outputDirectory parameter to be configurable without needing to change pom.xml on local systems.

I faced the exact same issue and I resolved it by putting the below plugin in my POM file.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <resources>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>                            
            </resource>
        </resources>
    </configuration>
</plugin>  


<properties>
    <failOnMissingWebXml>false</failOnMissingWebXml>
</properties>

As ali4j mentioned in comment, using env variable is appropriate solution for this scenario. Use a custom env variable in POM and ask the users to set the env in their system. How to refer environment variable in POM.xml?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM