4

I'm completely new to Maven. I'm trying to set up a new project such that it doesn't require 20 page long word docs with screenshots to set it up. I've got developers on Macs and PCs, so I need to be able to customize the catalina.home directory as I can't just impose a standard location. I thought I'd do it in the ~/.m2/settings.xml file with the following:

<profile>
  <id>my-site-dev</id>
  <activation>
    <activeByDefault>true</activeByDefault>
  </activation>
  <properties>
    <catalina.home>/path/to/apache-tomcat</catalina.home>
  </properties>
</profile>

However, the documentation here: http://maven.apache.org/guides/introduction/introduction-to-profiles.html#Profile_Pitfalls seems to indicate that what I'm trying to accomplish is a bad idea. What's the official way of accomplishing this so that in my pom.xml I can just reference ${catalina.home}?

And now that I've declared my profile with an id, can I fail the build if my pom.xml can't load the profile "my-site-dev"? I'd like to get that <activeByDefault> out of the settings.xml if at all possible. I don't want to interfere with their global settings for no reason, I'd like to keep as much of it self contained as possible.

4

2 に答える 2

3

を使用しないでくださいactiveByDefault。他のすべてのプロファイルが隠蔽されるためです。

使用するものは次のとおりです。

<profiles>
    <profile>
        <id>path-to-catalina.home-linux</id>
        <activation>
            <os>
                <family>linux</family>
            </os>
        </activation>
        <properties>
            <catalina.home>...</catalina.home>
        </properties>
    </profile>
    <profile>
        <id>path-to-catalina.home-mac</id>
        <activation>
            <os>
                <family>mac</family>
            </os>
        </activation>
        <properties>
            <catalina.home>...</catalina.home>
        </properties>
    </profile>
    <profile>
        <id>path-to-catalina.home-windows</id>
        <activation>
            <os>
                <family>windows</family>
            </os>
        </activation>
        <properties>
            <catalina.home>...</catalina.home>           
           </properties>
     </profile>
于 2013-01-02T20:04:18.403 に答える