Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/JbossConfiguration.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/JbossConfiguration.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/JbossConfiguration.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/JbossConfiguration.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,360 @@
+package org.apache.maven.plugins.ear;
+
+/*
+ * 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.
+ */
+
+import java.util.List;
+
+/**
+ * The JBoss specific configuration, used to generate the jboss-app.xml 
deployment descriptor file
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: JbossConfiguration.java 1636449 2014-11-03 21:27:36Z 
khmarbaise $
+ */
+class JbossConfiguration
+{
+    static final String VERSION_3_2 = "3.2";
+
+    static final String VERSION_4 = "4";
+
+    static final String VERSION_4_2 = "4.2";
+
+    static final String VERSION_5 = "5";
+
+    static final String VERSION = "version";
+
+    static final String SECURITY_DOMAIN = "security-domain";
+
+    static final String UNAUHTHENTICTED_PRINCIPAL = 
"unauthenticated-principal";
+
+    static final String JMX_NAME = "jmx-name";
+
+    static final String LOADER_REPOSITORY = "loader-repository";
+
+    static final String LOADER_REPOSITORY_CLASS_ATTRIBUTE = 
"loaderRepositoryClass";
+
+    static final String LOADER_REPOSITORY_CONFIG = "loader-repository-config";
+
+    static final String CONFIG_PARSER_CLASS_ATTRIBUTE = "configParserClass";
+
+    static final String MODULE_ORDER = "module-order";
+
+    static final String DATASOURCES = "data-sources";
+
+    static final String DATASOURCE = "data-source";
+
+    static final String LIBRARY_DIRECTORY = "library-directory";
+
+    private final String version;
+
+    private boolean jbossThreeDotTwo;
+
+    private boolean jbossFour;
+
+    private boolean jbossFourDotTwo;
+
+    private boolean jbossFive;
+
+    private final String securityDomain;
+
+    private final String unauthenticatedPrincipal;
+
+    private final String jmxName;
+
+    private final String loaderRepository;
+
+    private final String loaderRepositoryConfig;
+
+    private final String loaderRepositoryClass;
+
+    private final String configParserClass;
+
+    private final String moduleOrder;
+
+    private final List<String> dataSources;
+
+    private final String libraryDirectory;
+
+    public JbossConfiguration( String version, String securityDomain, String 
unauthenticatedPrincipal, String jmxName,
+                               String loaderRepository, String moduleOrder, 
List<String> dataSources,
+                               String libraryDirectory, String 
loaderRepositoryConfig, String loaderRepositoryClass,
+                               String configParserClass )
+        throws EarPluginException
+    {
+        if ( version == null )
+        {
+            throw new EarPluginException( "jboss version could not be null." );
+        }
+        else
+        {
+            this.version = version;
+            if ( version.equals( JbossConfiguration.VERSION_3_2 ) )
+            {
+                this.jbossThreeDotTwo = true;
+            }
+            else if ( version.equals( JbossConfiguration.VERSION_4 ) )
+            {
+                this.jbossFour = true;
+            }
+            else if ( version.equals( JbossConfiguration.VERSION_4_2 ) )
+            {
+                this.jbossFourDotTwo = true;
+            }
+            else if ( version.equals( JbossConfiguration.VERSION_5 ) )
+            {
+                this.jbossFive = true;
+            }
+            else
+            {
+                // CHECKSTYLE_OFF: LineLength
+                throw new EarPluginException( "Invalid JBoss configuration, 
version[" + version + "] is not supported." );
+                // CHECKSTYLE_ON: LineLength
+            }
+            this.securityDomain = securityDomain;
+            this.unauthenticatedPrincipal = unauthenticatedPrincipal;
+            this.jmxName = jmxName;
+            this.loaderRepository = loaderRepository;
+            this.moduleOrder = moduleOrder;
+            this.dataSources = dataSources;
+            this.libraryDirectory = libraryDirectory;
+            this.loaderRepositoryConfig = loaderRepositoryConfig;
+            this.loaderRepositoryClass = loaderRepositoryClass;
+            this.configParserClass = configParserClass;
+        }
+    }
+
+    /**
+     * Returns the targeted version of JBoss.
+     * 
+     * @return the jboss version
+     */
+    public String getVersion()
+    {
+        return version;
+    }
+
+    /**
+     * Returns true if the targeted JBoss version is 3.2.
+     * 
+     * @return if the targeted version is 3.2
+     */
+    public boolean isJbossThreeDotTwo()
+    {
+        return jbossThreeDotTwo;
+    }
+
+    /**
+     * Returns true if the targeted JBoss version is 4.
+     * 
+     * @return if the targeted version is 4
+     */
+    public boolean isJbossFour()
+    {
+        return jbossFour;
+    }
+
+    /**
+     * Returns true if the targeted JBoss version if 4 or higher (that is 4, 
4.2 or 5).
+     * 
+     * @return true if the targeted version is 4+
+     */
+    public boolean isJbossFourOrHigher()
+    {
+        return jbossFour || jbossFourDotTwo || jbossFive;
+    }
+
+    /**
+     * Returns true if the targeted JBoss version is 4.2.
+     * 
+     * @return if the targeted version is 4.2
+     */
+    public boolean isJbossFourDotTwo()
+    {
+        return jbossFourDotTwo;
+    }
+
+    /**
+     * Returns true if the targeted JBoss version if 4.2 or higher (that is 
4.2 or 5).
+     * 
+     * @return true if the targeted version is 4.2+
+     */
+    public boolean isJbossFourDotTwoOrHigher()
+    {
+        return jbossFourDotTwo || jbossFive;
+    }
+
+    /**
+     * Returns true if the targeted JBoss version is 5.
+     * 
+     * @return if the targeted version is 5
+     */
+    public boolean isJbossFive()
+    {
+        return jbossFive;
+    }
+
+    /**
+     * The security-domain element specifies the JNDI name of the security 
manager that implements the
+     * EJBSecurityManager and RealmMapping for the domain. When specified at 
the jboss level it specifies the security
+     * domain for all j2ee components in the deployment unit.
+     * <p/>
+     * One can override the global security-domain at the container level 
using the security-domain element at the
+     * container-configuration level.
+     * <p/>
+     * Only available as from JBoss 4.
+     * 
+     * @return the JNDI name of the security manager
+     */
+    public String getSecurityDomain()
+    {
+        return securityDomain;
+    }
+
+    /**
+     * The unauthenticated-principal element specifies the name of the 
principal that will be returned by the
+     * EJBContext.getCallerPrincipal() method if there is no authenticated 
user. This Principal has no roles or
+     * privileges to call any other beans.
+     * <p/>
+     * Only available as from JBoss 4.
+     * 
+     * @return the unauthenticated principal
+     */
+    public String getUnauthenticatedPrincipal()
+    {
+        return unauthenticatedPrincipal;
+    }
+
+    /**
+     * The jmx-name element allows one to specify the JMX ObjectName to use 
for the MBean associated with the ear
+     * module. This must be a unique name and valid JMX ObjectName string.
+     * 
+     * @return the object name of the ear mbean
+     */
+    public String getJmxName()
+    {
+        return jmxName;
+    }
+
+    /**
+     * The loader-repository specifies the name of the UnifiedLoaderRepository 
MBean to use for the ear to provide ear
+     * level scoping of classes deployed in the ear. It is a unique JMX 
ObjectName string.
+     * <p/>
+     * <P>
+     * Example:
+     * </P>
+     * 
&lt;loader-repository>jboss.test:loader=cts-cmp2v1-sar.ear&lt;/loader-repository>
+     * 
+     * @return the object name of the ear mbean
+     */
+    public String getLoaderRepository()
+    {
+        return loaderRepository;
+    }
+
+    /**
+     * The module-order specifies the order in which the modules specified in 
the application.xml file gets loaded.
+     * Allowed values are:
+     * <p/>
+     * <module-order>strict</module-order> The strict value indicates that the 
deployments of the modules will be done
+     * in the order that would be specified in the application.xml and 
jboss-app.xml file.
+     * <p/>
+     * <module-order>implicit</module-order> The implicit value indicates the 
deployment would follow the order which
+     * would be specified in the DeploymentSorter.
+     * <p/>
+     * Returns <tt>null</tt> if no module order is set.
+     * <p/>
+     * Only available in JBoss 4.2 and 4.3. Has no effect in JBoss 5 and is 
not added when mentioned version is used.
+     * 
+     * @return the module order
+     */
+    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<String> getDataSources()
+    {
+        return dataSources;
+    }
+
+    /**
+     * Returns the library directory to include in the <tt>jboss-app.xml</tt> 
file. It tells JBoss where to find
+     * non-Java EE libraries included in the EAR.
+     * 
+     * @return the library directory
+     */
+    public String getLibraryDirectory()
+    {
+        return libraryDirectory;
+    }
+
+    /**
+     * Returns the class loader repository configuration to include in the 
<tt>jboss-app.xml</tt> file. The content of
+     * this element is handed to the class loader, thereby altering it's 
default behaviour.
+     * <p/>
+     * This element is added as a child to the <tt>loader-repository</tt> 
element. If the element is not present in the
+     * configuration, it will be added.
+     * <p/>
+     * Example: 
&lt;loader-repository-config>java2ParentDelegaton=true&lt;/loader-repository-config>
+     * 
+     * @return the class loader repository configuration
+     */
+    public String getLoaderRepositoryConfig()
+    {
+        return loaderRepositoryConfig;
+    }
+
+    /**
+     * Returns the class loader repository class to include in the 
<tt>jboss-app.xml</tt> file. It tells JBoss which
+     * loader repository implementation to use.
+     * <p/>
+     * This element is added as an attribute to the <tt>loader-repository</tt> 
element, therefore it is not added if no
+     * such element configuration is present.
+     * <p/>
+     * Example: 
&lt;loader-repository-class>org.mindbug.jboss.AlternateLoaderRepository&lt;/loader-repository-class>
+     * 
+     * @return the class loader repository class
+     */
+    public String getLoaderRepositoryClass()
+    {
+        return loaderRepositoryClass;
+    }
+
+    /**
+     * Returns the class loader's configuration parser class to include in the 
<tt>jboss-app.xml</tt> file. It tells
+     * JBoss how to parse the configuration given in the 
<tt>loader-repository-config</tt> element.
+     * <p/>
+     * This element is added as an attribute to the 
<tt>loader-repository-config</tt> element, therefore it is not added
+     * if no such element configuration is present.
+     * <p/>
+     * Example: 
&lt;config-parser-class>org.mindbug.jboss.AlternateLoaderRepositoryConfigParser&lt;/config-parser-class>
+     * 
+     * @return the class loader's configuration parser class
+     */
+    public String getConfigParserClass()
+    {
+        return configParserClass;
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/JbossEarModule.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/JbossEarModule.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/JbossEarModule.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/JbossEarModule.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,39 @@
+package org.apache.maven.plugins.ear;
+
+/*
+ * 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.
+ */
+
+import org.codehaus.plexus.util.xml.XMLWriter;
+
+/**
+ * Represents a JBoss specific ear module.
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: JbossEarModule.java 1542511 2013-11-16 13:33:56Z rfscholte $
+ */
+public interface JbossEarModule
+{
+    /**
+     * Appends the <tt>XML</tt> representation of this module for the 
jboss-app.xml file.
+     * 
+     * @param writer the writer to use
+     * @param version the version of the <tt>jboss-app.xml</tt> file
+     */
+    void appendJbossModule( XMLWriter writer, String version );
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/ParModule.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/ParModule.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/ParModule.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/ParModule.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,58 @@
+package org.apache.maven.plugins.ear;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.artifact.Artifact;
+
+/**
+ * The {@link EarModule} implementation for a Par module.
+ * 
+ * @author Stephane Nicoll <[email protected]>
+ * @author $Author: khmarbaise $ (last edit)
+ * @version $Revision: 1645331 $
+ */
+public class ParModule
+    extends EjbModule
+{
+
+    /**
+     * Create an instance.
+     */
+    public ParModule()
+    {
+        super();
+    }
+
+    /**
+     * @param a {@link Artifact}
+     */
+    public ParModule( Artifact a )
+    {
+        super( a );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getType()
+    {
+        return "par";
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/RarModule.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/RarModule.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/RarModule.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/RarModule.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,73 @@
+package org.apache.maven.plugins.ear;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.artifact.Artifact;
+import org.codehaus.plexus.util.xml.XMLWriter;
+
+/**
+ * The {@link EarModule} implementation for an J2EE connector module.
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: RarModule.java 1660473 2015-02-17 19:33:00Z khmarbaise $
+ */
+public class RarModule
+    extends AbstractEarModule
+{
+    private static final String RAR_MODULE = "connector";
+
+    /**
+     * Create an instance.
+     */
+    public RarModule()
+    {
+    }
+
+    /**
+     * @param a {@link Artifact}
+     */
+    public RarModule( Artifact a )
+    {
+        super( a );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void appendModule( XMLWriter writer, String version, Boolean 
generateId )
+    {
+        startModuleElement( writer, generateId );
+        writer.startElement( RAR_MODULE );
+        writer.writeText( getUri() );
+        writer.endElement();
+
+        writeAltDeploymentDescriptor( writer, version );
+
+        writer.endElement();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getType()
+    {
+        return "rar";
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/SarModule.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/SarModule.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/SarModule.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/SarModule.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,92 @@
+package org.apache.maven.plugins.ear;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.artifact.Artifact;
+import org.codehaus.plexus.util.xml.XMLWriter;
+
+/**
+ * The {@link EarModule} implementation for a JBoss sar module.
+ * 
+ * @author Stephane Nicoll <[email protected]>
+ * @author $Author: khmarbaise $ (last edit)
+ * @version $Revision: 1645331 $
+ */
+/**
+ * @author kama
+ *
+ */
+public class SarModule
+    extends AbstractEarModule
+    implements JbossEarModule
+{
+    private static final String SAR_MODULE = "connector";
+
+    /**
+     * Create an instance.
+     */
+    public SarModule()
+    {
+    }
+
+    /**
+     * @param a {@link Artifact}
+     */
+    public SarModule( Artifact a )
+    {
+        super( a );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void appendModule( XMLWriter writer, String version, Boolean 
generateId )
+    {
+        // If JBoss is not configured, add the module as a connector element
+        if ( !earExecutionContext.isJbossConfigured() )
+        {
+            startModuleElement( writer, generateId );
+            writer.startElement( SAR_MODULE );
+            writer.writeText( getUri() );
+            writer.endElement();
+            writer.endElement();
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void appendJbossModule( XMLWriter writer, String version )
+    {
+        writer.startElement( MODULE_ELEMENT );
+        writer.startElement( "service" );
+        writer.writeText( getUri() );
+        writer.endElement();
+        writer.endElement();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getType()
+    {
+        return "sar";
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/SecurityRole.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/SecurityRole.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/SecurityRole.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/SecurityRole.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,135 @@
+package org.apache.maven.plugins.ear;
+
+/*
+ * 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.
+ */
+
+import org.codehaus.plexus.util.xml.XMLWriter;
+
+/**
+ * The representation of a security-role entry within an application.xml file.
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: SecurityRole.java 1542508 2013-11-16 13:21:35Z rfscholte $
+ */
+class SecurityRole
+{
+
+    protected static final String SECURITY_ROLE = "security-role";
+
+    protected static final String ID_ATTRIBUTE = "id";
+
+    protected static final String DESCRIPTION = "description";
+
+    protected static final String ROLE_NAME = "role-name";
+
+    private final String roleName;
+
+    private final String roleNameId;
+
+    private final String roleId;
+
+    private final String description;
+
+    private final String descriptionId;
+
+    public SecurityRole( String roleName, String roleNameId, String roleId, 
String description, String descriptionId )
+    {
+        if ( roleName == null )
+        {
+            throw new NullPointerException( "role-name in security-role 
element could not be null." );
+        }
+        this.roleName = roleName;
+        this.roleNameId = roleNameId;
+        this.roleId = roleId;
+        this.description = description;
+        this.descriptionId = descriptionId;
+    }
+
+    public String getRoleName()
+    {
+        return roleName;
+    }
+
+    public String getRoleNameId()
+    {
+        return roleNameId;
+    }
+
+    public String getRoleId()
+    {
+        return roleId;
+    }
+
+    public String getDescription()
+    {
+        return description;
+    }
+
+    public String getDescriptionId()
+    {
+        return descriptionId;
+    }
+
+    /**
+     * Appends the <tt>XML</tt> representation of this security role.
+     * 
+     * @param writer the writer to use
+     */
+    public void appendSecurityRole( XMLWriter writer )
+    {
+        writer.startElement( SECURITY_ROLE );
+
+        // role id
+        if ( getRoleId() != null )
+        {
+            writer.addAttribute( ID_ATTRIBUTE, getRoleId() );
+        }
+
+        // description
+        if ( getDescription() != null )
+        {
+            writer.startElement( DESCRIPTION );
+            if ( getDescriptionId() != null )
+            {
+                writer.addAttribute( ID_ATTRIBUTE, getDescriptionId() );
+            }
+            writer.writeText( getDescription() );
+            writer.endElement();
+
+        }
+
+        // role name
+        writer.startElement( ROLE_NAME );
+        if ( getRoleNameId() != null )
+        {
+            writer.addAttribute( ID_ATTRIBUTE, getRoleNameId() );
+        }
+        writer.writeText( getRoleName() );
+        writer.endElement();
+
+        // end of security-role
+        writer.endElement();
+    }
+
+    public String toString()
+    {
+        return "Security role " + getRoleName();
+    }
+
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/UnknownArtifactTypeException.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/UnknownArtifactTypeException.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/UnknownArtifactTypeException.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/UnknownArtifactTypeException.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,51 @@
+package org.apache.maven.plugins.ear;
+
+/*
+ * 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.
+ */
+
+/**
+ * Thrown if an unknown artifact type is encountered.
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: UnknownArtifactTypeException.java 1645331 2014-12-13 
17:31:09Z khmarbaise $
+ */
+public class UnknownArtifactTypeException
+    extends EarPluginException
+{
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 2738931967722457793L;
+
+    /**
+     * Create an instance.
+     */
+    public UnknownArtifactTypeException()
+    {
+    }
+
+    /**
+     * @param message The message of the problem.
+     */
+    public UnknownArtifactTypeException( String message )
+    {
+        super( message );
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/WebModule.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/WebModule.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/WebModule.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/WebModule.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,141 @@
+package org.apache.maven.plugins.ear;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.util.xml.XMLWriter;
+
+import java.util.Set;
+
+/**
+ * The {@link EarModule} implementation for a Web application module.
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: WebModule.java 1645331 2014-12-13 17:31:09Z khmarbaise $
+ */
+public class WebModule
+    extends AbstractEarModule
+{
+    private static final String WEB_MODULE = "web";
+
+    private static final String WEB_URI_FIELD = "web-uri";
+
+    private static final String CONTEXT_ROOT_FIELD = "context-root";
+
+    private String contextRoot;
+
+    /**
+     * Create an instance.
+     */
+    public WebModule()
+    {
+    }
+
+    /**
+     * @param a {@link Artifact}
+     */
+    public WebModule( Artifact a )
+    {
+        super( a );
+        this.contextRoot = getDefaultContextRoot( a );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void appendModule( XMLWriter writer, String version, Boolean 
generateId )
+    {
+        startModuleElement( writer, generateId );
+        writer.startElement( WEB_MODULE );
+        writer.startElement( WEB_URI_FIELD );
+        writer.writeText( getUri() );
+        writer.endElement(); // web-uri
+
+        writer.startElement( CONTEXT_ROOT_FIELD );
+        writer.writeText( getContextRoot() );
+        writer.endElement(); // context-root
+
+        writer.endElement(); // web
+
+        writeAltDeploymentDescriptor( writer, version );
+
+        writer.endElement(); // module
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void resolveArtifact( Set<Artifact> artifacts )
+        throws EarPluginException, MojoFailureException
+    {
+        // Let's resolve the artifact
+        super.resolveArtifact( artifacts );
+
+        // Context root has not been customized - using default
+        if ( contextRoot == null )
+        {
+            contextRoot = getDefaultContextRoot( getArtifact() );
+        }
+    }
+
+    /**
+     * Returns the context root to use for the web module.
+     * <p/>
+     * Note that this might return <tt>null</tt> till the artifact has been 
resolved.
+     * 
+     * @return the context root
+     */
+    public String getContextRoot()
+    {
+        return contextRoot;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getType()
+    {
+        return "war";
+    }
+
+    /**
+     * Generates a default context root for the given artifact, based on the 
<tt>artifactId</tt>.
+     * 
+     * @param a the artifact
+     * @return a context root for the artifact
+     */
+    private static String getDefaultContextRoot( Artifact a )
+    {
+        if ( a == null )
+        {
+            throw new NullPointerException( "Artifact could not be null." );
+        }
+        return "/" + a.getArtifactId();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getLibDir()
+    {
+        return "WEB-INF/lib";
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/WsrModule.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/WsrModule.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/WsrModule.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/WsrModule.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,56 @@
+package org.apache.maven.plugins.ear;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.artifact.Artifact;
+
+/**
+ * The {@link EarModule} implementation for a JBoss wsr module.
+ * 
+ * @author Brad O'Hearne <[email protected]>
+ * @author $Author: khmarbaise $ (last edit)
+ * @version $Revision: 1645331 $
+ */
+public class WsrModule
+    extends RarModule
+{
+    /**
+     * Create an instance.
+     */
+    public WsrModule()
+    {
+    }
+
+    /**
+     * @param a {@link Artifact}
+     */
+    public WsrModule( Artifact a )
+    {
+        super( a );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getType()
+    {
+        return "wsr";
+    }
+}
\ No newline at end of file

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/AbstractFileNameMapping.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/AbstractFileNameMapping.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/AbstractFileNameMapping.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/AbstractFileNameMapping.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,80 @@
+package org.apache.maven.plugins.ear.output;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.artifact.Artifact;
+
+/**
+ * A base class used to generate the standard name of an artifact instead of 
relying on the (potentially) wrong file
+ * name provided by {@link org.apache.maven.artifact.Artifact#getFile()}.
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ */
+public abstract class AbstractFileNameMapping
+    implements FileNameMapping
+{
+
+    private boolean useBaseVersion = false;
+
+    /** {@inheritDoc} */
+    public final void setUseBaseVersion( boolean useBaseVersion )
+    {
+        this.useBaseVersion = useBaseVersion;
+    }
+
+    /**
+     * Generates a standard file name for the specified {@link Artifact}.
+     * <p/>
+     * Returns something like 
<tt>artifactId-version[-classifier].extension</tt> if <tt>addVersion</tt> is 
true.
+     * Otherwise it generates something like 
<tt>artifactId[-classifier].extension</tt>
+     * 
+     * @param a the artifact to generate a filename from
+     * @param addVersion whether the version should be added
+     * @return the filename, with a standard format
+     */
+    protected String generateFileName( final Artifact a, boolean addVersion )
+    {
+        final String extension = a.getArtifactHandler().getExtension();
+
+        final StringBuilder buffer = new StringBuilder( 128 );
+        buffer.append( a.getArtifactId() );
+        if ( addVersion )
+        {
+            if ( useBaseVersion )
+            {
+                buffer.append( '-' ).append( a.getBaseVersion() );
+            }
+            else
+            {
+                buffer.append( '-' ).append( a.getVersion() );
+            }
+        }
+        if ( a.hasClassifier() )
+        {
+            buffer.append( '-' ).append( a.getClassifier() );
+        }
+        if ( extension != null && extension.length() > 0 )
+        {
+            buffer.append( '.' ).append( extension );
+        }
+
+        return buffer.toString();
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/FileNameMapping.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/FileNameMapping.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/FileNameMapping.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/FileNameMapping.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,47 @@
+package org.apache.maven.plugins.ear.output;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.artifact.Artifact;
+
+/**
+ * Maps file name {@link Artifact}.
+ * <p/>
+ * TODO: it might be easier to use a token-based approach instead.
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: FileNameMapping.java 1645331 2014-12-13 17:31:09Z khmarbaise $
+ */
+public interface FileNameMapping
+{
+
+    /**
+     * @param useBaseVersion true if the base version will be use false 
otherwise.
+     */
+    void setUseBaseVersion( boolean useBaseVersion );
+
+    /**
+     * Returns the file name of the specified artifact.
+     * 
+     * @param a the artifact
+     * @return the name of the file for the specified artifact
+     */
+    String mapFileName( final Artifact a );
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/FileNameMappingFactory.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/FileNameMappingFactory.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/FileNameMappingFactory.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/FileNameMappingFactory.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,106 @@
+package org.apache.maven.plugins.ear.output;
+
+/*
+ * 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.
+ */
+
+/**
+ * Provides access to {@link FileNameMapping} implementations.
+ * <p/>
+ * Two basic implementations are provided by default:
+ * <ul>
+ * <li>standard: the default implementation</li>
+ * <li>full: an implementation that maps to a 'full' file name, i.e. 
containing the groupId</li>
+ * </ul>
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: FileNameMappingFactory.java 1645331 2014-12-13 17:31:09Z 
khmarbaise $
+ */
+public class FileNameMappingFactory
+{
+    static final String STANDARD_FILE_NAME_MAPPING = "standard";
+
+    static final String FULL_FILE_NAME_MAPPING = "full";
+
+    static final String NO_VERSION_FILE_NAME_MAPPING = "no-version";
+
+    static final String NO_VERSION_FOR_EJB_FILE_NAME_MAPPING = 
"no-version-for-ejb";
+
+    private FileNameMappingFactory()
+    {
+    }
+
+    /**
+     * @return {@link StandardFileNameMapping}
+     */
+    public static FileNameMapping getDefaultFileNameMapping()
+    {
+        return new StandardFileNameMapping();
+    }
+
+    /**
+     * Returns the file name mapping implementation based on a logical name of 
a fully qualified name of the class.
+     * 
+     * @param nameOrClass a name of the fqn of the implementation
+     * @return the file name mapping implementation
+     */
+    public static FileNameMapping getFileNameMapping( final String nameOrClass 
)
+    {
+        if ( STANDARD_FILE_NAME_MAPPING.equals( nameOrClass ) )
+        {
+            return getDefaultFileNameMapping();
+        }
+        if ( FULL_FILE_NAME_MAPPING.equals( nameOrClass ) )
+        {
+            return new FullFileNameMapping();
+        }
+        if ( NO_VERSION_FILE_NAME_MAPPING.equals( nameOrClass ) )
+        {
+            return new NoVersionFileNameMapping();
+        }
+        if ( NO_VERSION_FOR_EJB_FILE_NAME_MAPPING.equals( nameOrClass ) )
+        {
+            return new NoVersionForEjbFileNameMapping();
+        }
+        try
+        {
+            final Class<?> c = Class.forName( nameOrClass );
+            return (FileNameMapping) c.newInstance();
+        }
+        catch ( ClassNotFoundException e )
+        {
+            throw new IllegalStateException( "File name mapping 
implementation[" + nameOrClass + "] was not found "
+                + e.getMessage() );
+        }
+        catch ( InstantiationException e )
+        {
+            throw new IllegalStateException( "Could not instantiate file name 
mapping implementation[" + nameOrClass
+                + "] make sure it has a default public constructor" );
+        }
+        catch ( IllegalAccessException e )
+        {
+            throw new IllegalStateException( "Could not access file name 
mapping implementation[" + nameOrClass
+                + "] make sure it has a default public constructor" );
+        }
+        catch ( ClassCastException e )
+        {
+            throw new IllegalStateException( "Specified class[" + nameOrClass 
+ "] does not implement["
+                + FileNameMapping.class.getName() + "]" );
+        }
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/FullFileNameMapping.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/FullFileNameMapping.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/FullFileNameMapping.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/FullFileNameMapping.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,42 @@
+package org.apache.maven.plugins.ear.output;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.artifact.Artifact;
+
+/**
+ * A full file name mapping, useful if artifacts might have the same name 
across groups.
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: FullFileNameMapping.java 1645331 2014-12-13 17:31:09Z 
khmarbaise $
+ */
+public class FullFileNameMapping
+    extends AbstractFileNameMapping
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    public String mapFileName( final Artifact a )
+    {
+        final String dashedGroupId = a.getGroupId().replace( '.', '-' );
+        return dashedGroupId + "-" + generateFileName( a, true );
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/NoVersionFileNameMapping.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/NoVersionFileNameMapping.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/NoVersionFileNameMapping.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/NoVersionFileNameMapping.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,41 @@
+package org.apache.maven.plugins.ear.output;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.artifact.Artifact;
+
+/**
+ * A simplified version of the standard file name mapping which does not 
retain the version in the generated file name.
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ */
+public class NoVersionFileNameMapping
+    extends AbstractFileNameMapping
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    public String mapFileName( Artifact a )
+    {
+        return generateFileName( a, false );
+    }
+
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/NoVersionForEjbFileNameMapping.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/NoVersionForEjbFileNameMapping.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/NoVersionForEjbFileNameMapping.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/NoVersionForEjbFileNameMapping.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,43 @@
+package org.apache.maven.plugins.ear.output;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.artifact.Artifact;
+
+/**
+ * A more sophisticated file name mapping which retains the version only for 
library jars and leaves it out for for
+ * ejb-jars.
+ * 
+ * @author <a href="mailto:[email protected]";>Philippe Marschall</a>
+ */
+public class NoVersionForEjbFileNameMapping
+    extends AbstractFileNameMapping
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    public String mapFileName( Artifact a )
+    {
+        boolean isEjb = "ejb".equals( a.getType() );
+        return generateFileName( a, !isEjb );
+    }
+
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/StandardFileNameMapping.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/StandardFileNameMapping.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/StandardFileNameMapping.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/StandardFileNameMapping.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,42 @@
+package org.apache.maven.plugins.ear.output;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.artifact.Artifact;
+
+/**
+ * The standard file name mapping. It returns the name of the file in the 
local repository.
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: StandardFileNameMapping.java 1645331 2014-12-13 17:31:09Z 
khmarbaise $
+ */
+public class StandardFileNameMapping
+    extends AbstractFileNameMapping
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    public String mapFileName( final Artifact a )
+    {
+        return generateFileName( a, true );
+    }
+
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/ArtifactRepository.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/ArtifactRepository.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/ArtifactRepository.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/ArtifactRepository.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,147 @@
+package org.apache.maven.plugins.ear.util;
+
+/*
+ * 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.
+ */
+
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.maven.artifact.Artifact;
+
+/**
+ * An artifact repository used to resolve {@link 
org.apache.maven.plugins.ear.EarModule}.
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: ArtifactRepository.java 1645331 2014-12-13 17:31:09Z 
khmarbaise $
+ */
+public class ArtifactRepository
+{
+    private final Set<Artifact> artifacts;
+
+    private final String mainArtifactId;
+
+    private final ArtifactTypeMappingService artifactTypeMappingService;
+
+    /**
+     * Creates a new repository wih the specified artifacts.
+     * 
+     * @param artifacts the artifacts
+     * @param mainArtifactId the id to use for the main artifact (no 
classifier)
+     * @param artifactTypeMappingService {@link ArtifactTypeMappingService}
+     */
+    public ArtifactRepository( Set<Artifact> artifacts, String mainArtifactId,
+                               ArtifactTypeMappingService 
artifactTypeMappingService )
+    {
+        this.artifacts = artifacts;
+        this.mainArtifactId = mainArtifactId;
+        this.artifactTypeMappingService = artifactTypeMappingService;
+    }
+
+    /**
+     * Returns the artifact with the specified parameters.
+     * <p/>
+     * If the artifact is classified and is the only one with the specified 
groupI, artifactId and type, it will be
+     * returned.
+     * <p/>
+     * If the artifact is classified and is not the only one with the 
specified groupI, artifactId and type, it returns
+     * null.
+     * <p/>
+     * If the artifact is not found, it returns null.
+     * 
+     * @param groupId the group id
+     * @param artifactId the artifact id
+     * @param type the type
+     * @param classifier the classifier
+     * @return the artifact or null if no artifact were found
+     */
+    public Artifact getUniqueArtifact( String groupId, String artifactId, 
String type, String classifier )
+    {
+        final Set<Artifact> candidates = getArtifacts( groupId, artifactId, 
type );
+        if ( candidates.size() == 0 )
+        {
+            return null;
+        }
+        else if ( candidates.size() == 1 && classifier == null )
+        {
+            return candidates.iterator().next();
+        }
+        else if ( classifier != null )
+        {
+            for ( Artifact a : candidates )
+            {
+                if ( a.getClassifier() == null && classifier.equals( 
mainArtifactId ) )
+                {
+                    return a;
+                }
+                else if ( classifier.equals( a.getClassifier() ) )
+                {
+                    return a;
+                }
+            }
+        }
+        // All other cases, classifier is null and more than one candidate ; 
artifact not found
+        return null;
+    }
+
+    /**
+     * Returns the artifact with the specified parameters.
+     * <p/>
+     * If the artifact is classified and is the only one with the specified 
groupI, artifactId and type, it will be
+     * returned.
+     * <p/>
+     * If the artifact is classified and is not the only one with the 
specified groupI, artifactId and type, it returns
+     * null.
+     * <p/>
+     * If the artifact is not found, it returns null.
+     * 
+     * @param groupId the group id
+     * @param artifactId the artifact id
+     * @param type the type
+     * @return the artifact or null if no artifact were found
+     */
+    public Artifact getUniqueArtifact( String groupId, String artifactId, 
String type )
+    {
+        return getUniqueArtifact( groupId, artifactId, type, null );
+    }
+
+    /**
+     * Returns the artifacts with the specified parameters.
+     * 
+     * @param groupId the group id
+     * @param artifactId the artifact id
+     * @param type the type
+     * @return the artifacts or an empty set if no artifact were found
+     */
+    public Set<Artifact> getArtifacts( String groupId, String artifactId, 
String type )
+    {
+        final Set<Artifact> result = new TreeSet<Artifact>();
+        for ( Artifact a : artifacts )
+        {
+            // If the groupId, the artifactId and if the
+            // artifact's type is known, then we have found a candidate.
+            if ( a.getGroupId().equals( groupId ) && a.getArtifactId().equals( 
artifactId )
+                && artifactTypeMappingService.isMappedToType( type, 
a.getType() ) )
+            {
+                result.add( a );
+
+            }
+        }
+        return result;
+    }
+}
\ No newline at end of file

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/ArtifactTypeMappingService.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/ArtifactTypeMappingService.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/ArtifactTypeMappingService.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/ArtifactTypeMappingService.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,179 @@
+package org.apache.maven.plugins.ear.util;
+
+/*
+ * 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.
+ */
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.plugins.ear.EarModuleFactory;
+import org.apache.maven.plugins.ear.EarPluginException;
+import org.apache.maven.plugins.ear.UnknownArtifactTypeException;
+import org.codehaus.plexus.configuration.PlexusConfiguration;
+import org.codehaus.plexus.configuration.PlexusConfigurationException;
+
+/**
+ * Allows to map custom artifact type to standard type.
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: ArtifactTypeMappingService.java 1645331 2014-12-13 17:31:09Z 
khmarbaise $
+ */
+public class ArtifactTypeMappingService
+{
+    static final String ARTIFACT_TYPE_MAPPING_ELEMENT = "artifactTypeMapping";
+
+    static final String TYPE_ATTRIBUTE = "type";
+
+    static final String MAPPING_ATTRIBUTE = "mapping";
+
+    // A standard type to a list of customType
+    private final Map<String, List<String>> typeMappings;
+
+    // The user-defined mapping for direct access
+    private final Map<String, String> customMappings;
+
+    /**
+     * Create an instance.
+     */
+    public ArtifactTypeMappingService()
+    {
+        this.typeMappings = new HashMap<String, List<String>>();
+        this.customMappings = new HashMap<String, String>();
+        init();
+    }
+
+    /**
+     * @param plexusConfiguration {@link PlexusConfiguration}
+     * @throws EarPluginException {@link EarPluginException}
+     * @throws PlexusConfigurationException {@link 
PlexusConfigurationException}
+     */
+    public void configure( final PlexusConfiguration plexusConfiguration )
+        throws EarPluginException, PlexusConfigurationException
+    {
+
+        // No user defined configuration
+        if ( plexusConfiguration == null )
+        {
+            return;
+        }
+
+        // Inject users configuration
+        final PlexusConfiguration[] artifactTypeMappings =
+            plexusConfiguration.getChildren( ARTIFACT_TYPE_MAPPING_ELEMENT );
+        for ( PlexusConfiguration artifactTypeMapping : artifactTypeMappings )
+        {
+            final String customType = artifactTypeMapping.getAttribute( 
TYPE_ATTRIBUTE );
+            final String mapping = artifactTypeMapping.getAttribute( 
MAPPING_ATTRIBUTE );
+
+            if ( customType == null )
+            {
+                throw new EarPluginException( "Invalid artifact type mapping, 
type attribute should be set." );
+            }
+            else if ( mapping == null )
+            {
+                throw new EarPluginException( "Invalid artifact type mapping, 
mapping attribute should be set." );
+            }
+            else if ( !EarModuleFactory.isStandardArtifactType( mapping ) )
+            {
+                throw new EarPluginException( "Invalid artifact type mapping, 
mapping[" + mapping
+                    + "] must be a standard Ear artifact type[" + 
EarModuleFactory.getStandardArtifactTypes() + "]" );
+            }
+            else if ( customMappings.containsKey( customType ) )
+            {
+                throw new EarPluginException( "Invalid artifact type mapping, 
type[" + customType
+                    + "] is already registered." );
+            }
+            else
+            {
+                // Add the custom mapping
+                customMappings.put( customType, mapping );
+
+                // Register the custom mapping to its standard type
+                List<String> typeMapping = typeMappings.get( mapping );
+                typeMapping.add( customType );
+            }
+        }
+    }
+
+    /**
+     * Specify whether the <tt>customType</tt> could be mapped to the 
<tt>standardType</tt>.
+     * 
+     * @param standardType the standard type (ejb, jar, war, ...)
+     * @param customType a user-defined type
+     * @return true if the customType could be mapped to the standard type
+     */
+    public boolean isMappedToType( final String standardType, final String 
customType )
+    {
+        if ( !EarModuleFactory.isStandardArtifactType( standardType ) )
+        {
+            throw new IllegalStateException( "Artifact type[" + standardType + 
"] is not a standard Ear artifact type["
+                + EarModuleFactory.getStandardArtifactTypes() + "]" );
+        }
+        return this.typeMappings.get( standardType ).contains( customType );
+
+    }
+
+    /**
+     * Returns the standard type for the specified <tt>type</tt>. If the 
specified type is already a standard type, the
+     * orignal type is returned.
+     * 
+     * @param type a type
+     * @return the standard type (ejb, jar, war, ...) for this type
+     * @throws UnknownArtifactTypeException In case of missing mappings types.
+     */
+    public String getStandardType( final String type )
+        throws UnknownArtifactTypeException
+    {
+        if ( type == null )
+        {
+            throw new IllegalStateException( "custom type could not be null." 
);
+        }
+        else if ( EarModuleFactory.getStandardArtifactTypes().contains( type ) 
)
+        {
+            return type;
+        }
+        else if ( !customMappings.containsKey( type ) )
+        {
+            throw new UnknownArtifactTypeException( "Unknown artifact type[" + 
type + "]" );
+        }
+        else
+        {
+            return customMappings.get( type );
+        }
+    }
+
+    private void init()
+    {
+        // Initialize the typeMappings
+        typeMappings.clear();
+
+        // Clear the customMappings
+        customMappings.clear();
+
+        // Initialize the mapping with the standard artifact types
+        for ( String type : EarModuleFactory.getStandardArtifactTypes() )
+        {
+            List<String> typeMapping = new ArrayList<String>();
+            typeMapping.add( type );
+            this.typeMappings.put( type, typeMapping );
+        }
+    }
+}
\ No newline at end of file

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/EarMavenArchiver.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/EarMavenArchiver.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/EarMavenArchiver.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/EarMavenArchiver.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,146 @@
+package org.apache.maven.plugins.ear.util;
+
+/*
+ * 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.
+ */
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.archiver.MavenArchiveConfiguration;
+import org.apache.maven.archiver.MavenArchiver;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugins.ear.EarModule;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.archiver.jar.Manifest;
+import org.codehaus.plexus.archiver.jar.ManifestException;
+
+/**
+ * A custom {@link MavenArchiver} implementation that takes care of setting 
the right classpath value according to the
+ * actual path of bundled files.
+ * 
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ */
+public class EarMavenArchiver
+    extends MavenArchiver
+{
+    /**
+     * {@code Class-Path}.
+     */
+    public static final String CLASS_PATH_KEY = "Class-Path";
+
+    private final List<EarModule> earModules;
+
+    /**
+     * Creates an instance with the ear modules that will be packaged in the 
EAR archive.
+     * 
+     * @param earModules the intitialized list of ear modules
+     */
+    public EarMavenArchiver( List<EarModule> earModules )
+    {
+        this.earModules = earModules;
+    }
+
+    /**
+     * @param project {@link MavenProject}
+     * @param config {@link MavenArchiveConfiguration}
+     * @throws ManifestException in case of an error
+     * @throws DependencyResolutionRequiredException in case of an resolution 
error.
+     * @return Manifest
+     * @deprecated
+     */
+    public Manifest getManifest( MavenProject project, 
MavenArchiveConfiguration config )
+        throws ManifestException, DependencyResolutionRequiredException
+    {
+        return this.getManifest( null, project, config );
+    }
+
+    /** {@inheritDoc} */
+    public Manifest getManifest( MavenSession session, MavenProject project, 
MavenArchiveConfiguration config )
+        throws ManifestException, DependencyResolutionRequiredException
+    {
+        final Manifest manifest = super.getManifest( session, project, config 
);
+        if ( config.getManifest().isAddClasspath() )
+        {
+            String earManifestClassPathEntry = generateClassPathEntry( 
config.getManifest().getClasspathPrefix() );
+            // Class-path can be customized. Let's make sure we don't 
overwrite this
+            // with our custom change!
+            final String userSuppliedClassPathEntry = 
getUserSuppliedClassPathEntry( config );
+            if ( userSuppliedClassPathEntry != null )
+            {
+                earManifestClassPathEntry = userSuppliedClassPathEntry + " " + 
earManifestClassPathEntry;
+            }
+
+            // Overwrite the existing one, if any
+            final Manifest.Attribute classPathAttr = 
manifest.getMainSection().getAttribute( CLASS_PATH_KEY );
+            if ( classPathAttr != null )
+            {
+                classPathAttr.setValue( earManifestClassPathEntry );
+            }
+            else
+            {
+                final Manifest.Attribute attr = new Manifest.Attribute( 
CLASS_PATH_KEY, earManifestClassPathEntry );
+                manifest.addConfiguredAttribute( attr );
+            }
+        }
+        return manifest;
+    }
+
+    /**
+     * Generates the <tt>Class-Path</tt> entry of the manifest according to 
the list of ear modules.
+     * 
+     * @param classPathPrefix the classpath prefix to use
+     * @return the <tt>Class-Path</tt> entry
+     */
+    protected String generateClassPathEntry( String classPathPrefix )
+    {
+        final StringBuilder classpath = new StringBuilder();
+        for ( final EarModule earModule : earModules )
+        {
+            if ( !earModule.isExcluded() )
+            {
+                classpath.append( classPathPrefix ).append( earModule.getUri() 
).append( " " );
+            }
+        }
+        return classpath.toString().trim();
+    }
+
+    /**
+     * @param config {@link MavenArchiveConfiguration}
+     * @return The class path entry.
+     */
+    protected String getUserSuppliedClassPathEntry( MavenArchiveConfiguration 
config )
+    {
+        if ( config.getManifestEntries() != null )
+        {
+            final Set<String> keys = config.getManifestEntries().keySet();
+            for ( String key : keys )
+            {
+                String value = config.getManifestEntries().get( key );
+                if ( "Class-Path".equals( key ) && value != null )
+                {
+                    return value;
+
+                }
+
+            }
+        }
+        return null;
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/InvalidJavaEEVersion.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/InvalidJavaEEVersion.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/InvalidJavaEEVersion.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/InvalidJavaEEVersion.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,55 @@
+package org.apache.maven.plugins.ear.util;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * @author Stephane Nicoll
+ */
+public class InvalidJavaEEVersion
+    extends MojoExecutionException
+{
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 3189028517550801372L;
+
+    private final String invalidVersion;
+
+    /**
+     * @param message The message for the error
+     * @param invalidVersion The invalid version.
+     */
+    public InvalidJavaEEVersion( String message, String invalidVersion )
+    {
+        super( message );
+        this.invalidVersion = invalidVersion;
+    }
+
+    /**
+     * @return The invalid version.
+     */
+    public String getInvalidVersion()
+    {
+        return invalidVersion;
+    }
+}

Added: 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java?rev=1755643&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java
 (added)
+++ 
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java
 Tue Aug  9 19:17:58 2016
@@ -0,0 +1,200 @@
+package org.apache.maven.plugins.ear.util;
+
+/*
+ * 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.
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Represents the supported JavaEE version.
+ * 
+ * @author Stephane Nicoll
+ */
+public class JavaEEVersion
+    implements Comparable<JavaEEVersion>
+{
+
+    private static final String VERSION_1_3 = "1.3";
+
+    private static final String VERSION_1_4 = "1.4";
+
+    private static final String VERSION_5 = "5";
+
+    private static final String VERSION_6 = "6";
+
+    private static final String VERSION_7 = "7";
+    
+    private static final String VERSION_8 = "8";
+
+    private static final Map<String, JavaEEVersion> VERSION_MAP = new 
HashMap<String, JavaEEVersion>();
+
+    /**
+     * Represents the J2EE 1.3 version.
+     */
+    public static final JavaEEVersion ONE_DOT_THREE = new JavaEEVersion( 
Integer.valueOf( 0 ), VERSION_1_3 );
+
+    /**
+     * Represents the J2EE 1.4 version.
+     */
+    public static final JavaEEVersion ONE_DOT_FOUR = new JavaEEVersion( 
Integer.valueOf( 1 ), VERSION_1_4 );
+
+    /**
+     * Represents the JavaEE 5 version.
+     */
+    public static final JavaEEVersion FIVE = new JavaEEVersion( 
Integer.valueOf( 2 ), VERSION_5 );
+
+    /**
+     * Represents the JavaEE 6 version.
+     */
+    public static final JavaEEVersion SIX = new JavaEEVersion( 
Integer.valueOf( 3 ), VERSION_6 );
+
+    /**
+     * Represents the JavaEE 7 version.
+     */
+    public static final JavaEEVersion SEVEN = new JavaEEVersion( 
Integer.valueOf( 4 ), VERSION_7 );
+
+    /**
+     * Represents the JavaEE 8 version.
+     */
+    public static final JavaEEVersion EIGHT = new JavaEEVersion( 
Integer.valueOf( 5 ), VERSION_8 );
+
+    private final Integer index;
+
+    private final String version;
+
+    private JavaEEVersion( Integer index, String version )
+    {
+        this.index = index;
+        this.version = version;
+        VERSION_MAP.put( version, this );
+    }
+
+    /**
+     * @param paramVersion The version.
+     * @return {@link JavaEEVersion}
+     * @throws InvalidJavaEEVersion in case of a wrong version.
+     */
+    public static JavaEEVersion getJavaEEVersion( String paramVersion )
+        throws InvalidJavaEEVersion
+    {
+        if ( !isValid( paramVersion ) )
+        {
+            throw new InvalidJavaEEVersion( "Invalid version [" + paramVersion 
+ "]", paramVersion );
+        }
+        return VERSION_MAP.get( paramVersion );
+    }
+
+    /**
+     * Returns the version as a string.
+     * 
+     * @return the version string
+     */
+    public String getVersion()
+    {
+        return version;
+    }
+
+    /**
+     * Specifies if this version is greater or equal to the specified version.
+     * 
+     * @param parmVersion the version to check
+     * @return true if this version is greater or equal to <tt>version</tt>
+     */
+    public boolean ge( JavaEEVersion parmVersion )
+    {
+        return this.compareTo( parmVersion ) >= 0;
+    }
+
+    /**
+     * Specifies if this version is greater than the specified version.
+     * 
+     * @param paramVersion the version to check
+     * @return true if this version is greater to <tt>version</tt>
+     */
+    public boolean gt( JavaEEVersion paramVersion )
+    {
+        return this.compareTo( paramVersion ) > 0;
+    }
+
+    /**
+     * Specifies if this version is equal to the specified version.
+     * 
+     * @param paramVersion the version to check
+     * @return true if this version is equal to <tt>version</tt>
+     */
+    public boolean eq( JavaEEVersion paramVersion )
+    {
+        return this.compareTo( paramVersion ) == 0;
+    }
+
+    /**
+     * Specifies if this version is less or equal to the specified version.
+     * 
+     * @param paramVersion the version to check
+     * @return true if this version is less or equal to <tt>version</tt>
+     */
+    public boolean le( JavaEEVersion paramVersion )
+    {
+        return this.compareTo( paramVersion ) <= 0;
+    }
+
+    /**
+     * Specifies if this version is less than the specified version.
+     * 
+     * @param paramVersion the version to check
+     * @return true if this version is less or equal to <tt>version</tt>
+     */
+    public boolean lt( JavaEEVersion paramVersion )
+    {
+        return this.compareTo( paramVersion ) < 0;
+    }
+
+    /**
+     * Checks if the specified version string is valid.
+     * 
+     * @param paramVersion the version string to check
+     * @return <tt>true</tt> if the version is valid
+     */
+    private static boolean isValid( String paramVersion )
+    {
+        if ( paramVersion == null )
+        {
+            throw new IllegalArgumentException( "version could not be null." );
+        }
+        // @formatter:off
+        return VERSION_1_3.equals( paramVersion ) 
+            || VERSION_1_4.equals( paramVersion )
+            || VERSION_5.equals( paramVersion ) 
+            || VERSION_6.equals( paramVersion ) 
+            || VERSION_7.equals( paramVersion )
+            || VERSION_8.equals( paramVersion );
+        // @formatter:on
+    }
+
+    /** {@inheritDoc} */
+    public int compareTo( JavaEEVersion otherVersion )
+    {
+        if ( otherVersion == null )
+        {
+            throw new IllegalArgumentException( "other object to compare to 
could not be null." );
+        }
+        return index.compareTo( otherVersion.index );
+    }
+}
\ No newline at end of file


Reply via email to