tags:

views:

24

answers:

2

This is a portion of my profiles.xml for mvn:

<profilesXml>
  <profiles>
    <profile>
      <id>production</id>
      <build>
        <plugins> .. </plugins>
      </build>
    </profile>
  </profiles>
</profilesXml>

This is what mvn says:

Caused by: org.codehaus.plexus.util.xml.pull.XmlPullParserException: 
Unrecognised tag: 'build' (position: START_TAG seen ...</id>\n
        <build>... @32:20)

What's wrong here?

A: 

You can not have <build> area in your profile. Only plugins etc. You can configure the plugins etc.

khmarbaise
The same story if I move `<plugins>` one level up and remove `<build>`..
Vincenzo
You will say you got the same message ? I can't believe...Did you try to make a minimal try with things like this: <profiles> <profile> <id>appserverConfig</id> <properties> <appserver.home>/path/to/appserver</appserver.home> </properties> </profile> </profiles>instead of your just to make everything else is working correct.
khmarbaise
A: 

The error message is giving you the correct feedback here, you cannot specify a <build/> section in an external profile, you are only allowed to specify <properties>, <pluginRepositories>, and <repositories>. From the Introduction to Build Profiles:

Profiles in external files

Profiles specified in external files (i.e in settings.xml or profiles.xml) are not portable in the strictest sense. Anything that seems to stand a high chance of changing the result of the build is restricted to the inline profiles in the POM. Things like repository lists could simply be a proprietary repository of approved artifacts, and won't change the outcome of the build. Therefore, you will only be able to modify the <repositories> and <pluginRepositories> sections, plus an extra <properties> section.

The <properties> section allows you to specify free-form key-value pairs which will be included in the interpolation process for the POM. This allows you to specify a plugin configuration in the form of ${profile.provided.path}.

If your snippet is coming from a book, the book should be fixed.

Pascal Thivent
Indeed, from a book, published by Sonatype. Ok, thanks for explanation, will fix my project (and a book :)
Vincenzo
@FaZend.com: I guess the Maven guys changed "the rules" at some time (because *Better Builds with Maven* also mentions a snippet similar to the one from your question).
Pascal Thivent
@FaZend.com: Feel free to upvote too by the way, always appreciated ;)
Pascal Thivent