简体   繁体   English

使用Git配置maven war插件的outputDirectory

[英]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. 我在git仓库上建立了一个maven项目,它使用maven-war-plugin直接在tomcat目录中创建war。 But on different systems, tomcat directory path can be different. 但是在不同的系统上,tomcat目录路径可以不同。

        <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. 我希望这个outputDirectory参数可以配置,而无需在本地系统上更改pom.xml。

I faced the exact same issue and I resolved it by putting the below plugin in my POM file. 我遇到了完全相同的问题,我通过将下面的插件放在我的POM文件中来解决它。

<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. 正如注释中提到的ali4j ,使用env变量是适用于此场景的解决方案。 Use a custom env variable in POM and ask the users to set the env in their system. 在POM中使用自定义env变量,并要求用户在其系统中设置env。 How to refer environment variable in POM.xml? 如何在POM.xml中引用环境变量?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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