Index: C:/Documents and Settings/mgagne/repos/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossAppXmlWriter.java =================================================================== --- C:/Documents and Settings/mgagne/repos/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossAppXmlWriter.java (revision 568717) +++ C:/Documents and Settings/mgagne/repos/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossAppXmlWriter.java (working copy) @@ -73,6 +75,8 @@ } writer.startElement( JBOSS_APP_ELEMENT ); + List dataSources = jbossConfiguration.getDataSources(); + // If JBoss 4.2, write the jboss4.2 specific stuff if ( jbossConfiguration.isJbossFourDotTwo() ) { @@ -118,6 +122,20 @@ writer.endElement(); } + // Write out data source modules first + if ( dataSources != null ) + { + for ( int i = 0; i < dataSources.size(); i++ ) + { + writer.startElement( MODULE_ELEMENT ); + writer.startElement( SERVICE_ELEMENT ); + writer.writeText( (String) dataSources.get( i ) ); + writer.endElement(); + writer.endElement(); + } + + } + // Write the JBoss specific modules final Iterator it = earModules.iterator(); while ( it.hasNext() ) Index: C:/Documents and Settings/mgagne/repos/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossConfiguration.java =================================================================== --- C:/Documents and Settings/mgagne/repos/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossConfiguration.java (revision 568717) +++ C:/Documents and Settings/mgagne/repos/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossConfiguration.java (working copy) @@ -19,16 +19,17 @@ * under the License. */ +import java.util.List; @@ -47,6 +48,7 @@ static final String MODULE_ORDER = "module-order"; + static final String DATASOURCES = "data-sources"; private final String version; @@ -66,11 +68,13 @@ private final String moduleOrder; + private final List dataSources; public JbossConfiguration( String version, String securityDomain, String unauthenticatedPrincipal, String jmxName, - String loaderRepository, String moduleOrder ) + String loaderRepository, String moduleOrder, List dataSources ) throws EarPluginException { @@ -92,141 +97,136 @@ this.securityDomain = securityDomain; this.unauthenticatedPrincipal = unauthenticatedPrincipal; this.jmxName = jmxName; this.loaderRepository = loaderRepository; this.moduleOrder = moduleOrder; + this.dataSources = dataSources; } } + public List getDataSources() + { + return dataSources; + } + } Index: C:/Documents and Settings/mgagne/repos/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java =================================================================== --- C:/Documents and Settings/mgagne/repos/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java (revision 568717) +++ C:/Documents and Settings/mgagne/repos/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java (working copy) @@ -293,8 +292,19 @@ final String loaderRepository = jboss.getChild( JbossConfiguration.LOADER_REPOSITORY ).getValue(); final String jmxName = jboss.getChild( JbossConfiguration.JMX_NAME ).getValue(); final String moduleOrder = jboss.getChild( JbossConfiguration.MODULE_ORDER ).getValue(); - jbossConfiguration = new JbossConfiguration( version, securityDomain, unauthenticatedPrincipal, jmxName, - loaderRepository, moduleOrder ); + final int dataSourceCount = jboss.getChild( JbossConfiguration.DATASOURCES ).getChildCount(); + final List dataSources = new ArrayList(); + + // Build a list of data sources from jboss config section + for ( int i = 0; i < dataSourceCount; i++ ) + { + PlexusConfiguration temp = jboss.getChild( JbossConfiguration.DATASOURCES ).getChild( i ); + dataSources.add( temp.getValue() ); + } + + jbossConfiguration = + new JbossConfiguration( version, securityDomain, unauthenticatedPrincipal, jmxName, + loaderRepository, moduleOrder, dataSources ); } catch ( PlexusConfigurationException e ) { Index: C:/Documents and Settings/mgagne/repos/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractXmlWriter.java =================================================================== --- C:/Documents and Settings/mgagne/repos/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractXmlWriter.java (revision 568717) +++ C:/Documents and Settings/mgagne/repos/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractXmlWriter.java (working copy) @@ -38,6 +38,10 @@ private final String encoding; + protected static final String MODULE_ELEMENT = "module"; + + protected static final String SERVICE_ELEMENT = "service"; + AbstractXmlWriter( String encoding ) { this.encoding = encoding; Index: C:/Documents and Settings/mgagne/repos/maven-ear-plugin/src/site/apt/usage.apt =================================================================== --- C:/Documents and Settings/mgagne/repos/maven-ear-plugin/src/site/apt/usage.apt (revision 568717) +++ C:/Documents and Settings/mgagne/repos/maven-ear-plugin/src/site/apt/usage.apt (working copy) @@ -128,8 +128,22 @@ * <>: specify the order in which the modules specified in the application.xml file gets loaded (JBoss 4.2 only) - + * <>: specify the desired data source(s) to add into the jboss-app.xml, usage is as follows: + +----- + + + [...] + + (datasource1 location) + (datasource2 location) + (datasource3 location) + [...] + + + + +----- + Hibernate archives (HAR) and Service archives (SAR) will be recognized automatically and added the the jboss-app.xml file.