tomcat7-maven-plugin - store server url outside of pom.xml

痞子三分冷 提交于 2019-12-25 09:03:04

问题


I'm working on some open-source project and wouldn't like to keep URL of production servers in public repository with source code, but at the same time I'd like to have an opportunity to deploy using tomcat-maven-plugin.

I tried to move server url from pom.xml to settings.xml, but it didn't work. Could You please give me a hint, what is the best way to keep url out of pom.xml?

Thank You very much.

Here is my configuration: settings.xml

<settings>
    <servers>
        <server>
            <id>prod</id>
            <username>deployer</username>
            <password>********</password>
        </server>
    </servers>
</settings>

pom.xml (in the project)

<project>
    ...
    <profiles>
        <profile>
            <id>prod</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.tomcat.maven</groupId>
                        <artifactId>tomcat7-maven-plugin</artifactId>
                        <version>2.2</version>
                        <configuration>
                            <server>prod</server>
                            <url>http://host:XXXX/manager/text</url>
                            <path>/</path>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

Update: Yes, there is an opportunity to keep this in .properties-files, but:

  1. It's a bit strange to keep server configuration in several places, i.e. ~/.m2/settings.xml, application.properties, pom.xml. As long as username and password are able to be stored in settings.xml, it would be nice to keep server URL also there.
  2. Actually I couldn't make it work, so I'm keep working on this way as workaround...

Update 2: Just found out, why the approach with reading properties didn't work for me. I used:

mvn tomcat7:redeploy

to deploy application, and properties-maven-plugin didn't inject properties in the placeholders in tomcat7-maven-plugin configuration. After I changed tomcat7-maven-plugin execution due to deploy phase, then the injection of properties works properly by invocation:

mvn clean deploy

But never the less, I would like to know, is it possible to keep server URL in settings.xml?

来源:https://stackoverflow.com/questions/43014310/tomcat7-maven-plugin-store-server-url-outside-of-pom-xml

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