diff --git a/ear/plugin.jelly b/ear/plugin.jelly
index d75244fd..e3007645 100644
--- a/ear/plugin.jelly
+++ b/ear/plugin.jelly
@@ -338,6 +338,11 @@
${context.setVariable(var,'parent',thePath)}
+
+
+
+
+
diff --git a/ear/project.xml b/ear/project.xml
index ca41bd81..86cd1606 100644
--- a/ear/project.xml
+++ b/ear/project.xml
@@ -128,5 +128,13 @@
This library is already loaded by maven's core. Be careful to use the same version number as in the core.
+
+ commons-logging
+ commons-logging
+ 1.0.4
+
+ This library is already loaded by maven's core. Be careful to use the same version number as in the core.
+
+
diff --git a/ear/src/main/org/apache/maven/ear/j2ee/J2EEEntityResolver.java b/ear/src/main/org/apache/maven/ear/j2ee/J2EEEntityResolver.java
new file mode 100644
index 00000000..573e44da
--- /dev/null
+++ b/ear/src/main/org/apache/maven/ear/j2ee/J2EEEntityResolver.java
@@ -0,0 +1,129 @@
+package org.apache.maven.ear.j2ee;
+
+/* ====================================================================
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ * ====================================================================
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+
+/**
+ * A class to resolve external entity definitions for j2ee artifacts.
+ *
+ * @author dion
+ */
+public class J2EEEntityResolver implements EntityResolver
+{
+ /** log for debug output */
+ private static final Log LOG =
+ LogFactory.getLog( J2EEEntityResolver.class );
+
+ /** list of j2ee dtds that are being made available */
+ public static final String[] J2EE_DTDS =
+ new String[]
+ {
+ "-//Sun Microsystems, Inc.//DTD J2EE Application Client 1.3//EN",
+ "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN",
+ "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN",
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN",
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN",
+ "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
+ };
+ /** list of j2ee resources that are being made available */
+ public static final String[] J2EE_RESOURCES =
+ new String[]
+ {
+ "/plugin-resources/application-client_1_3.dtd",
+ "/plugin-resources/application_1_3.dtd",
+ "/plugin-resources/ejb-jar_2_0.dtd",
+ "/plugin-resources/web-app_2.2.dtd",
+ "/plugin-resources/web-app_2_3.dtd",
+ "/plugin-resources/web-jsptaglibrary_1_2.dtd"
+ };
+
+ /** map of ids to resource names */
+ private Map idToResource = new HashMap();
+
+ /** Creates a new instance of EntityResolver */
+ public J2EEEntityResolver()
+ {
+ for ( int i = 0; i < J2EE_DTDS.length; i++ )
+ {
+ idToResource.put( J2EE_DTDS[i], J2EE_RESOURCES[i] );
+ }
+ }
+
+ /** resolve the entity given by the provided Ids
+ * @param publicId the public id of the entity
+ * @param systemId the 'system location' (typically a URL) of the entity
+ * @return an {@link InputSource input source} for retrieval of the entity
+ * @throws IOException when an I/O error occurs retrieving the entity
+ * @throws SAXException if there are any problems
+ */
+ public InputSource resolveEntity( String publicId, String systemId )
+ throws SAXException, IOException
+ {
+ LOG.debug( "resolving entity with publicId='" + publicId
+ + ", systemId='" + systemId + "'" );
+
+ if ( publicId != null )
+ {
+ String resource = (String) idToResource.get( publicId );
+
+ LOG.debug( "resource found in map ='" + resource + "'" );
+
+ if ( resource != null )
+ {
+ InputStream in = getClass().getResourceAsStream( resource );
+
+ LOG.debug( "input stream ='" + in + "'" );
+
+ if ( in != null )
+ {
+ return new InputSource( in );
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /** Getter for publicId to resource name map.
+ * @return Value of property idToResource.
+ */
+ protected Map getIdToResource()
+ {
+ return idToResource;
+ }
+
+ /** Setter for publicId to resource name map.
+ * @param newIdToResource New value of property idToResource.
+ */
+ protected void setIdToResource( Map newIdToResource )
+ {
+ this.idToResource = newIdToResource;
+ }
+}
diff --git a/ear/src/main/org/apache/maven/ear/j2ee/package.html b/ear/src/main/org/apache/maven/ear/j2ee/package.html
new file mode 100644
index 00000000..27611d65
--- /dev/null
+++ b/ear/src/main/org/apache/maven/ear/j2ee/package.html
@@ -0,0 +1,11 @@
+
+
+
+ org.apache.maven.ear.j2ee
+
+
+
+ Utility classes for working with j2ee artifacts.
+
+
+
diff --git a/ear/src/plugin-resources/application-client_1_3.dtd b/ear/src/plugin-resources/application-client_1_3.dtd
new file mode 100644
index 00000000..f9d456d5
--- /dev/null
+++ b/ear/src/plugin-resources/application-client_1_3.dtd
@@ -0,0 +1,506 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ear/src/plugin-resources/application_1_3.dtd b/ear/src/plugin-resources/application_1_3.dtd
new file mode 100644
index 00000000..22a49aca
--- /dev/null
+++ b/ear/src/plugin-resources/application_1_3.dtd
@@ -0,0 +1,312 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ear/src/plugin-resources/ejb-jar_2_0.dtd b/ear/src/plugin-resources/ejb-jar_2_0.dtd
new file mode 100644
index 00000000..9a2cc7ce
--- /dev/null
+++ b/ear/src/plugin-resources/ejb-jar_2_0.dtd
@@ -0,0 +1,1671 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ear/src/plugin-resources/web-app_2.2.dtd b/ear/src/plugin-resources/web-app_2.2.dtd
new file mode 100644
index 00000000..5f439f42
--- /dev/null
+++ b/ear/src/plugin-resources/web-app_2.2.dtd
@@ -0,0 +1,639 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ear/src/plugin-resources/web-jsptaglibrary_1_2.dtd b/ear/src/plugin-resources/web-jsptaglibrary_1_2.dtd
new file mode 100644
index 00000000..369f41e6
--- /dev/null
+++ b/ear/src/plugin-resources/web-jsptaglibrary_1_2.dtd
@@ -0,0 +1,462 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ear/src/plugin-test/project.properties b/ear/src/plugin-test/project.properties
index ee45d71b..8ce8db74 100644
--- a/ear/src/plugin-test/project.properties
+++ b/ear/src/plugin-test/project.properties
@@ -15,7 +15,6 @@
# -------------------------------------------------------------------
maven.deployable.component=${maven.final.name}.ear
-maven.j2ee.ear.appxml=${maven.conf.dir}/application.xml
maven.ear.appxml.generate=true
# note the override below is needed, as the ear plugin redefines the licenseFile in
# it's own project.properties, and running plugin:test would otherwise fail
diff --git a/ear/src/plugin-test/simpleTest/maven.xml b/ear/src/plugin-test/simpleTest/maven.xml
index a78ffa0a..37c4b0f5 100644
--- a/ear/src/plugin-test/simpleTest/maven.xml
+++ b/ear/src/plugin-test/simpleTest/maven.xml
@@ -19,7 +19,7 @@
xmlns:u="jelly:util"
xmlns:x="jelly:xml"
xmlns:assert="assert"
- xmlns:j2ee="j2ee"
+ xmlns:ear="ear"
default="testPlugin">
@@ -47,7 +47,7 @@
-
+
${saxReader.setEntityResolver(resolver)}
diff --git a/ear/src/plugin-test/simpleTest/project.properties b/ear/src/plugin-test/simpleTest/project.properties
index ee45d71b..8ce8db74 100644
--- a/ear/src/plugin-test/simpleTest/project.properties
+++ b/ear/src/plugin-test/simpleTest/project.properties
@@ -15,7 +15,6 @@
# -------------------------------------------------------------------
maven.deployable.component=${maven.final.name}.ear
-maven.j2ee.ear.appxml=${maven.conf.dir}/application.xml
maven.ear.appxml.generate=true
# note the override below is needed, as the ear plugin redefines the licenseFile in
# it's own project.properties, and running plugin:test would otherwise fail
diff --git a/ear/src/plugin-test/simpleTest/project.xml b/ear/src/plugin-test/simpleTest/project.xml
index 871282f6..6a9fd4fa 100644
--- a/ear/src/plugin-test/simpleTest/project.xml
+++ b/ear/src/plugin-test/simpleTest/project.xml
@@ -65,13 +65,6 @@ http://maven.apache.org/maven-v3_0_0.xsd">
commons-jelly-tags-xml
1.1
-
-
- maven
- maven-j2ee-plugin
- 1.5.1
- plugin
-
src
diff --git a/ear/src/test/org/apache/maven/ear/j2ee/J2EEEntityResolverTest.java b/ear/src/test/org/apache/maven/ear/j2ee/J2EEEntityResolverTest.java
new file mode 100644
index 00000000..b3388734
--- /dev/null
+++ b/ear/src/test/org/apache/maven/ear/j2ee/J2EEEntityResolverTest.java
@@ -0,0 +1,88 @@
+package org.apache.maven.ear.j2ee;
+
+/* ====================================================================
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ * ====================================================================
+ */
+
+import junit.framework.TestCase;
+
+import org.xml.sax.InputSource;
+
+/**
+ * Test cases for the {@link J2EEEntityResolver}
+ *
+ * @author dIon Gillard
+ */
+public class J2EEEntityResolverTest extends TestCase
+{
+ /** instance for unit testing */
+ private J2EEEntityResolver instance;
+
+ /**
+ * Creates a new instance of J2EEEntityResolverTest
+ * @param testName the name of the test
+ */
+ public J2EEEntityResolverTest( String testName )
+ {
+ super( testName );
+ }
+
+ /**
+ * Initialize per test data
+ * @throws Exception when there is an unexpected problem
+ */
+ public void setUp() throws Exception
+ {
+ instance = new J2EEEntityResolver();
+ }
+
+ /**
+ * Test that all public ids are available and being found
+ */
+ public void testAllAvailable()
+ {
+ assertNotNull( "id to resource map not available",
+ instance.getIdToResource() );
+
+ int numDTDs = J2EEEntityResolver.J2EE_DTDS.length;
+
+ assertEquals( "wrong number of entries", numDTDs,
+ instance.getIdToResource().size() );
+
+ for ( int i = 0; i < numDTDs; i++ )
+ {
+ assertNotNull( "Can't find resource for publicId",
+ instance.getIdToResource().get( J2EEEntityResolver.J2EE_DTDS[i] ) );
+ }
+ }
+
+ /**
+ * Test that the resolver is getting resources locally
+ */
+ public void testResolvingLocally()
+ throws Exception
+ {
+ int numDTDs = J2EEEntityResolver.J2EE_DTDS.length;
+
+ for ( int i = 0; i < numDTDs; i++ )
+ {
+ String publicId = J2EEEntityResolver.J2EE_DTDS[i];
+
+ assertNotNull( "Can't find resource for publicId " + publicId,
+ instance.resolveEntity( publicId, null ) );
+ }
+ }
+}
diff --git a/ear/src/test/org/apache/maven/ear/j2ee/package.html b/ear/src/test/org/apache/maven/ear/j2ee/package.html
new file mode 100644
index 00000000..0ff4d29e
--- /dev/null
+++ b/ear/src/test/org/apache/maven/ear/j2ee/package.html
@@ -0,0 +1,11 @@
+
+
+
+ org.apache.maven.ear.j2ee
+
+
+
+ Test classes for org.apache.maven.ear.j2ee.
+
+
+