Maven3 Issue:
Maven3 does not evaluate external properties during the "ear:generate-application-xml" goal.
In a portable build we want Maven to generate the application.xml
and jboss.app.xml
resource files based on property values stored in an external properties file. This works perfect i in
Maven-2 but fails in Maven-3:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<finalName>${app.context}-ear</finalName>
<displayName>${app.display.name}</displayName>
<description>${app.description}</description>
<!--
MNGECLIPSE-1541:
During the import of a mavenized ear project (File > Import... > General > Maven Projects)
an application.xml file is generated in src/main/application/META-INF/application.xml.
https://issues.sonatype.org/browse/MNGECLIPSE-1541
MNGECLIPSE-2145:
Generated application.xml doesn't contain final names
https://issues.sonatype.org/browse/MNGECLIPSE-2145
To fix this we excludes the eclipse generated application.xml during mvn package
-->
<earSourceExcludes>**/application.xml</earSourceExcludes>
<!-- Use maven generated application.xml -->
<generateApplicationXml>true</generateApplicationXml>
<version>5</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<encoding>UTF-8</encoding>
<jboss>
<!--
To trigger the generation of the jboss-app.xml file you need to
configure the 'jboss' element. see:
http://maven.apache.org/plugins/maven-ear-plugin/usage.html and:
http://maven.apache.org/plugins/maven-ear-plugin/examples/generating-jboss-app.html
-->
<version>${as.version}</version>
<loader-repository>
<!--
seam.jboss.org is a Seam-specific scoped classloader. It acts as
a way for Seam to disassociate artifacts bundled with the
application from those that exist within the JBoss application
server's shared artifacts or JARs (for example, those that
reside in the default server's lib directory or in JBoss's
general lib directory).
The classloader is referenced in jboss-app.xml for EAR deployment and and in
jboss-web.xml for WAR deployment (SiA-2.5.3-p63).
see: http://www.jboss.org/community/wiki/classloadingconfiguration
see: http://www.mastertheboss.com/en/jboss-application-server/141-jboss-classloader.html
-->
seam.jboss.org:loader=${app.context}-ear
</loader-repository>
<data-sources>
<data-source>META-INF/ds/${ds.xml}</data-source>
</data-sources>
</jboss>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Build-Machine>${env.COMPUTERNAME}</Build-Machine>
<Url>${project.url}</Url>
</manifestEntries>
</archive>
</configuration>
</plugin>
Properties are externalized to filter-*.properties file and read into maven using
org.codehaus.mojo:properties-maven-plugin
.
Running e.g. mvn install
in Maven 3 gives the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.4.2:generate-application-xml
(default-generate-application-xml) on project mvn3-problem-ear: Failed to initialize JBoss configuration:
Invalid JBoss configuration, version[${as.version}] is not supported. -> [Help 1]
The bug is reported in JIRA: http://jira.codehaus.org/browse/MNG-2971.