You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sn...@apache.org on 2007/08/24 23:12:41 UTC
svn commit: r569524 - in /maven/plugins/trunk/maven-ear-plugin/src:
main/java/org/apache/maven/plugin/ear/ site/apt/
test/java/org/apache/maven/plugin/ear/ test/resources/projects/project-042/
test/resources/projects/project-042/expected-META-INF/
Author: snicoll
Date: Fri Aug 24 14:12:40 2007
New Revision: 569524
URL: http://svn.apache.org/viewvc?rev=569524&view=rev
Log:
MEAR-52: Ability to add JBoss datasources (*ds.xml) files
Reviewed By: Stephane Nicoll
Submitted By: Matthew Gagne
Added:
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/expected-META-INF/
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/expected-META-INF/application.xml
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/expected-META-INF/jboss-app.xml
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/pom.xml
Modified:
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractXmlWriter.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossAppXmlWriter.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossConfiguration.java
maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/EarMojoTest.java
Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java?rev=569524&r1=569523&r2=569524&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarMojo.java Fri Aug 24 14:12:40 2007
@@ -293,8 +293,23 @@
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();
+
+ final List dataSources = new ArrayList();
+ final PlexusConfiguration dataSourcesEl = jboss.getChild( JbossConfiguration.DATASOURCES );
+ if ( dataSourcesEl != null )
+ {
+
+ final PlexusConfiguration[] dataSourcesConfig =
+ dataSourcesEl.getChildren( JbossConfiguration.DATASOURCE );
+ for ( int i = 0; i < dataSourcesConfig.length; i++ )
+ {
+ PlexusConfiguration dataSourceConfig = dataSourcesConfig[i];
+ dataSources.add( dataSourceConfig.getValue() );
+
+ }
+ }
jbossConfiguration = new JbossConfiguration( version, securityDomain, unauthenticatedPrincipal, jmxName,
- loaderRepository, moduleOrder );
+ loaderRepository, moduleOrder, dataSources );
}
catch ( PlexusConfigurationException e )
{
Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractXmlWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractXmlWriter.java?rev=569524&r1=569523&r2=569524&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractXmlWriter.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractXmlWriter.java Fri Aug 24 14:12:40 2007
@@ -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;
Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossAppXmlWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossAppXmlWriter.java?rev=569524&r1=569523&r2=569524&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossAppXmlWriter.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossAppXmlWriter.java Fri Aug 24 14:12:40 2007
@@ -118,6 +118,22 @@
writer.endElement();
}
+ List dataSources = jbossConfiguration.getDataSources();
+ // Write out data source modules first
+ if ( dataSources != null )
+ {
+ final Iterator it = dataSources.iterator();
+ while ( it.hasNext() )
+ {
+ String dsPath = (String) it.next();
+ writer.startElement( MODULE_ELEMENT );
+ writer.startElement( SERVICE_ELEMENT );
+ writer.writeText( dsPath );
+ writer.endElement();
+ writer.endElement();
+ }
+ }
+
// Write the JBoss specific modules
final Iterator it = earModules.iterator();
while ( it.hasNext() )
Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossConfiguration.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossConfiguration.java?rev=569524&r1=569523&r2=569524&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossConfiguration.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/JbossConfiguration.java Fri Aug 24 14:12:40 2007
@@ -1,5 +1,7 @@
package org.apache.maven.plugin.ear;
+import java.util.List;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -47,6 +49,9 @@
static final String MODULE_ORDER = "module-order";
+ static final String DATASOURCES = "data-sources";
+
+ static final String DATASOURCE = "data-source";
private final String version;
@@ -66,9 +71,11 @@
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
{
if ( version == null )
@@ -100,6 +107,7 @@
this.jmxName = jmxName;
this.loaderRepository = loaderRepository;
this.moduleOrder = moduleOrder;
+ this.dataSources = dataSources;
}
}
@@ -227,6 +235,18 @@
public String getModuleOrder()
{
return moduleOrder;
+ }
+
+ /**
+ * Returns the list of datasources to include in the <tt>jboss-app.xml</tt>
+ * file as services. Each element of the list is the relative path to the
+ * datasource file contained in the EAR archive.
+ *
+ * @return the list of datasources paths
+ */
+ public List getDataSources()
+ {
+ return dataSources;
}
}
Modified: maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt?rev=569524&r1=569523&r2=569524&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt Fri Aug 24 14:12:40 2007
@@ -128,6 +128,20 @@
* <<module-order>>: specify the order in which the modules specified in the application.xml file gets loaded (JBoss 4.2 only)
+ * <<data-sources>>: specify the desired data source(s) to add into the jboss-app.xml, usage is as follows:
+
++-----
+<configuration>
+ <jboss>
+ [...]
+ <data-sources>
+ <data-source>main-ds.xml</data-source>
+ <data-source>config/secondary-ds.xml</data-source>
+ [...]
+ </data-sources>
+ </jboss>
+</configuration>
++-----
Hibernate archives (HAR) and Service archives (SAR) will be recognized automatically
Modified: maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/EarMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/EarMojoTest.java?rev=569524&r1=569523&r2=569524&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/EarMojoTest.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/EarMojoTest.java Fri Aug 24 14:12:40 2007
@@ -440,4 +440,13 @@
doTestProject( "project-041", new String[]{"ejb-sample-one-1.0.jar", "ejb-sample-two-1.0.jar"} );
}
+ /**
+ * Builds an EAR with a Jboss 4.2 configuration specifying a datasource to add.
+ */
+ public void testProject042()
+ throws Exception
+ {
+ doTestProject( "project-042", new String[]{"ejb-sample-one-1.0.jar", "ejb-sample-two-1.0.jar"} );
+ }
+
}
Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/expected-META-INF/application.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/expected-META-INF/application.xml?rev=569524&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/expected-META-INF/application.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/expected-META-INF/application.xml Fri Aug 24 14:12:40 2007
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<!DOCTYPE application PUBLIC
+ "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
+ "http://java.sun.com/dtd/application_1_3.dtd">
+<application>
+ <display-name>maven-ear-plugin-test-project-042</display-name>
+ <module>
+ <ejb>ejb-sample-two-1.0.jar</ejb>
+ </module>
+ <module>
+ <ejb>ejb-sample-one-1.0.jar</ejb>
+ </module>
+</application>
Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/expected-META-INF/jboss-app.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/expected-META-INF/jboss-app.xml?rev=569524&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/expected-META-INF/jboss-app.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/expected-META-INF/jboss-app.xml Fri Aug 24 14:12:40 2007
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<!DOCTYPE jboss-app PUBLIC
+ "-//JBoss//DTD J2EE Application 1.4//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
+<jboss-app>
+ <module>
+ <service>my-ds.xml</service>
+ </module>
+</jboss-app>
\ No newline at end of file
Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/pom.xml?rev=569524&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/pom.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-042/pom.xml Fri Aug 24 14:12:40 2007
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>ear</groupId>
+ <artifactId>maven-ear-plugin-test-project-042</artifactId>
+ <version>99.0</version>
+ <name>Maven</name>
+ <packaging>ear</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>eartest</groupId>
+ <artifactId>ejb-sample-one</artifactId>
+ <version>1.0</version>
+ <type>ejb</type>
+ </dependency>
+ <dependency>
+ <groupId>eartest</groupId>
+ <artifactId>ejb-sample-two</artifactId>
+ <version>1.0</version>
+ <type>ejb</type>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-ear-plugin</artifactId>
+ <configuration>
+ <jboss>
+ <version>4.2</version>
+ <data-sources>
+ <data-source>my-ds.xml</data-source>
+ </data-sources>
+ </jboss>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>