Author: rfscholte
Date: Tue Aug 9 19:17:58 2016
New Revision: 1755643
URL: http://svn.apache.org/viewvc?rev=1755643&view=rev
Log:
[MEAR-241] Change package to o.a.m.plugins
Added:
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AbstractEarModule.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AbstractEarMojo.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AbstractXmlWriter.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AppClientModule.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriter.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriterContext.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarExecutionContext.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarModule.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarModuleFactory.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarMojo.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarPluginException.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EjbClientModule.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EjbModule.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EjbRef.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EnvEntry.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/GenerateApplicationXmlMojo.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/HarModule.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/JarModule.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/JbossAppXmlWriter.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/JbossConfiguration.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/JbossEarModule.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/ParModule.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/RarModule.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/SarModule.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/SecurityRole.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/UnknownArtifactTypeException.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/WebModule.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/WsrModule.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/AbstractFileNameMapping.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/FileNameMapping.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/FileNameMappingFactory.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/FullFileNameMapping.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/NoVersionFileNameMapping.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/NoVersionForEjbFileNameMapping.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/output/StandardFileNameMapping.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/ArtifactRepository.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/ArtifactTypeMappingService.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/EarMavenArchiver.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/InvalidJavaEEVersion.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/JavaEEVersion.java
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/util/ModuleIdentifierValidator.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/AbstractEarTestBase.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/EarModuleTest.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/EnvEntryTest.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/it/
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/it/AbstractEarPluginIT.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/it/EarMojoIT.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/AbstractFileNameMappingTestBase.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/FileNameMappingFactoryTest.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/FullFileNameMappingTest.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/NoVersionFileNameMappingTest.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/NoVersionForEjbFileNameMappingTest.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/StandardFileNameMappingTest.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/output/TestAbstractFileNameMapping.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/stub/
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/stub/ArtifactHandlerTestStub.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/stub/ArtifactTestStub.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/util/
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/util/ArtifactRepositoryTest.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/util/ArtifactTypeMappingServiceTest.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/util/EarMavenArchiverTest.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/util/JavaEEVersionTest.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/util/ModuleIdentifierValidatorTest.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugins/ear/util/ResourceEntityResolver.java
Removed:
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/
Added:
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AbstractEarModule.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AbstractEarModule.java?rev=1755643&view=auto
==============================================================================
---
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AbstractEarModule.java
(added)
+++
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AbstractEarModule.java
Tue Aug 9 19:17:58 2016
@@ -0,0 +1,436 @@
+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.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.ear.output.FileNameMappingFactory;
+import org.apache.maven.plugins.ear.util.ArtifactRepository;
+import org.codehaus.plexus.util.xml.XMLWriter;
+
+/**
+ * A base implementation of an {@link EarModule}.
+ *
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: AbstractEarModule.java 1645331 2014-12-13 17:31:09Z
khmarbaise $
+ */
+public abstract class AbstractEarModule
+ implements EarModule
+{
+
+ /**
+ * The module element.
+ */
+ protected static final String MODULE_ELEMENT = "module";
+
+ /**
+ * The java module.
+ */
+ protected static final String JAVA_MODULE = "java";
+
+ /**
+ * The alt-dd module.
+ */
+ protected static final String ALT_DD = "alt-dd";
+
+ private Artifact artifact;
+
+ // Those are set by the configuration
+
+ private String groupId;
+
+ private String artifactId;
+
+ private String classifier;
+
+ /**
+ * The bundleDir.
+ */
+ protected String bundleDir;
+
+ /**
+ * The bundleFileName.
+ */
+ protected String bundleFileName;
+
+ /**
+ * excluded by default {@code false}.
+ */
+ protected Boolean excluded = Boolean.FALSE;
+
+ private String uri;
+
+ /**
+ * unpack
+ */
+ protected Boolean unpack = null;
+
+ /**
+ * The alternate deployment descriptor.
+ */
+ protected String altDeploymentDescriptor;
+
+ private String moduleId;
+
+ // This is injected once the module has been built.
+
+ /**
+ * The {@link EarExecutionContext}
+ */
+ protected EarExecutionContext earExecutionContext;
+
+ /**
+ * Empty constructor to be used when the module is built based on the
configuration.
+ */
+ public AbstractEarModule()
+ {
+ }
+
+ /**
+ * Creates an ear module from the artifact.
+ *
+ * @param a the artifact
+ */
+ public AbstractEarModule( Artifact a )
+ {
+ this.artifact = a;
+ this.groupId = a.getGroupId();
+ this.artifactId = a.getArtifactId();
+ this.classifier = a.getClassifier();
+ this.bundleDir = null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setEarExecutionContext( EarExecutionContext
earExecutionContext )
+ {
+ this.earExecutionContext = earExecutionContext;
+ }
+
+ /** {@inheritDoc} */
+ public void resolveArtifact( Set<Artifact> artifacts )
+ throws EarPluginException, MojoFailureException
+ {
+ // If the artifact is already set no need to resolve it
+ if ( artifact == null )
+ {
+ // Make sure that at least the groupId and the artifactId are
specified
+ if ( groupId == null || artifactId == null )
+ {
+ throw new MojoFailureException( "Could not resolve artifact["
+ groupId + ":" + artifactId + ":"
+ + getType() + "]" );
+ }
+ final ArtifactRepository ar =
earExecutionContext.getArtifactRepository();
+ artifact = ar.getUniqueArtifact( groupId, artifactId, getType(),
classifier );
+ // Artifact has not been found
+ if ( artifact == null )
+ {
+ Set<Artifact> candidates = ar.getArtifacts( groupId,
artifactId, getType() );
+ if ( candidates.size() > 1 )
+ {
+ throw new MojoFailureException( "Artifact[" + this + "]
has " + candidates.size()
+ + " candidates, please provide a classifier." );
+ }
+ else
+ {
+ throw new MojoFailureException( "Artifact[" + this + "] is
not a dependency of the project." );
+ }
+ }
+ }
+ }
+
+ /**
+ * @return {@link #artifact}
+ */
+ public Artifact getArtifact()
+ {
+ return artifact;
+ }
+
+ /**
+ * @return {@link #moduleId}
+ */
+ public String getModuleId()
+ {
+ return moduleId;
+ }
+
+ /**
+ * @return Return the URI.
+ */
+ public String getUri()
+ {
+ if ( uri == null )
+ {
+ if ( getBundleDir() == null )
+ {
+ uri = getBundleFileName();
+ }
+ else
+ {
+ uri = getBundleDir() + getBundleFileName();
+ }
+ }
+ return uri;
+ }
+
+ /**
+ * Returns the artifact's groupId.
+ *
+ * @return {@link #groupId}
+ */
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
+ /**
+ * Returns the artifact's Id.
+ *
+ * @return {@link #artifactId}
+ */
+ public String getArtifactId()
+ {
+ return artifactId;
+ }
+
+ /**
+ * Returns the artifact's classifier.
+ *
+ * @return the artifact classifier
+ */
+ public String getClassifier()
+ {
+ return classifier;
+ }
+
+ /**
+ * Returns the bundle directory. If null, the module is bundled in the
root of the EAR.
+ *
+ * @return the custom bundle directory
+ */
+ public String getBundleDir()
+ {
+ if ( bundleDir != null )
+ {
+ bundleDir = cleanBundleDir( bundleDir );
+ }
+ return bundleDir;
+ }
+
+ /**
+ * Returns the bundle file name. If null, the artifact's file name is
returned.
+ *
+ * @return the bundle file name
+ */
+ public String getBundleFileName()
+ {
+ if ( bundleFileName == null )
+ {
+ bundleFileName =
earExecutionContext.getFileNameMapping().mapFileName( artifact );
+ }
+ return bundleFileName;
+ }
+
+ /**
+ * Based on MEAR-189 we need to get back
+ * the original file name under any circumstances.
+ *
+ * @return The original file name.
+ */
+ public String getOriginalBundleFileName()
+ {
+ return FileNameMappingFactory.getDefaultFileNameMapping().mapFileName(
artifact );
+ }
+
+ /**
+ * The alt-dd element specifies an optional URI to the post-assembly
version of the deployment descriptor file for a
+ * particular Java EE module. The URI must specify the full pathname of
the deployment descriptor file relative to
+ * the application's root directory.
+ *
+ * @return the alternative deployment descriptor for this module
+ */
+ public String getAltDeploymentDescriptor()
+ {
+ return altDeploymentDescriptor;
+ }
+
+ /**
+ * Specify whether this module should be excluded or not.
+ *
+ * @return true if this module should be skipped, false otherwise
+ */
+ public boolean isExcluded()
+ {
+ return excluded;
+ }
+
+ /**
+ * @return {@link #unpack}
+ */
+ public Boolean shouldUnpack()
+ {
+ return unpack;
+ }
+
+ /**
+ * Writes the alternative deployment descriptor if necessary.
+ *
+ * @param writer the writer to use
+ * @param version the java EE version in use
+ */
+ protected void writeAltDeploymentDescriptor( XMLWriter writer, String
version )
+ {
+ if ( getAltDeploymentDescriptor() != null )
+ {
+ writer.startElement( ALT_DD );
+ writer.writeText( getAltDeploymentDescriptor() );
+ writer.endElement();
+ }
+ }
+
+ /**
+ * Starts a new {@link #MODULE_ELEMENT} on the specified writer, possibly
including an id attribute.
+ *
+ * @param writer the XML writer.
+ * @param generateId whether an id should be generated
+ */
+ protected void startModuleElement( XMLWriter writer, Boolean generateId )
+ {
+ writer.startElement( MODULE_ELEMENT );
+
+ // If a moduleId is specified, always include it
+ if ( getModuleId() != null )
+ {
+ writer.addAttribute( "id", getModuleId() );
+ }
+ else if ( generateId )
+ {
+ // No module id was specified but one should be generated.
+ Artifact theArtifact = getArtifact();
+ String generatedId =
+ theArtifact.getType().toUpperCase() + "_" +
theArtifact.getGroupId() + "."
+ + theArtifact.getArtifactId();
+ if ( null != theArtifact.getClassifier() &&
theArtifact.getClassifier().trim().length() > 0 )
+ {
+ generatedId += "-" + theArtifact.getClassifier().trim();
+ }
+ writer.addAttribute( "id", generatedId );
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append( getType() ).append( ":" ).append( groupId ).append( ":"
).append( artifactId );
+ if ( classifier != null )
+ {
+ sb.append( ":" ).append( classifier );
+ }
+ if ( artifact != null )
+ {
+ sb.append( ":" ).append( artifact.getVersion() );
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Cleans the bundle directory so that it might be used properly.
+ *
+ * @param bundleDir the bundle directory to clean
+ * @return the cleaned bundle directory
+ */
+ static String cleanBundleDir( String bundleDir )
+ {
+ if ( bundleDir == null )
+ {
+ return null;
+ }
+
+ // Using slashes
+ bundleDir = bundleDir.replace( '\\', '/' );
+
+ // Remove '/' prefix if any so that directory is a relative path
+ if ( bundleDir.startsWith( "/" ) )
+ {
+ bundleDir = bundleDir.substring( 1, bundleDir.length() );
+ }
+
+ if ( bundleDir.length() > 0 && !bundleDir.endsWith( "/" ) )
+ {
+ // Adding '/' suffix to specify a directory structure if it is not
empty
+ bundleDir = bundleDir + "/";
+ }
+
+ return bundleDir;
+ }
+
+ /**
+ * Specify if the objects are both null or both equal.
+ *
+ * @param first the first object
+ * @param second the second object
+ * @return true if parameters are either both null or equal
+ */
+ static boolean areNullOrEqual( Object first, Object second )
+ {
+ if ( first != null )
+ {
+ return first.equals( second );
+ }
+ else
+ {
+ return second == null;
+ }
+ }
+
+ /**
+ * Sets the URI of the module explicitly for testing purposes.
+ *
+ * @param uri the uri
+ */
+ void setUri( String uri )
+ {
+ this.uri = uri;
+
+ }
+
+ /**
+ * @return always {@code true}
+ */
+ public boolean changeManifestClasspath()
+ {
+ return true;
+ }
+
+ /**
+ * @return always {@code null}
+ */
+ public String getLibDir()
+ {
+ return null;
+ }
+}
Added:
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AbstractEarMojo.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AbstractEarMojo.java?rev=1755643&view=auto
==============================================================================
---
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AbstractEarMojo.java
(added)
+++
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AbstractEarMojo.java
Tue Aug 9 19:17:58 2016
@@ -0,0 +1,390 @@
+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.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.ear.util.ArtifactTypeMappingService;
+import org.apache.maven.plugins.ear.util.JavaEEVersion;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.filtering.MavenResourcesFiltering;
+import org.codehaus.plexus.configuration.PlexusConfiguration;
+import org.codehaus.plexus.configuration.PlexusConfigurationException;
+
+/**
+ * A base class for EAR-processing related tasks.
+ *
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: AbstractEarMojo.java 1742027 2016-05-02 19:11:21Z khmarbaise $
+ */
+public abstract class AbstractEarMojo
+ extends AbstractMojo
+{
+ /**
+ * The application XML URI {@code META-INF/application.xml}
+ */
+ public static final String APPLICATION_XML_URI =
"META-INF/application.xml";
+
+ /**
+ * The {@code META-INF} folder.
+ */
+ public static final String META_INF = "META-INF";
+
+ /**
+ * UTF-8 encoding constant.
+ */
+ public static final String UTF_8 = "UTF-8";
+
+ /**
+ * The version of the application.xml to generate. Valid values are 1.3,
1.4, 5, 6, 7 and 8.
+ */
+ @Parameter( defaultValue = "7" )
+ protected String version;
+
+ /**
+ * Character encoding for the auto-generated deployment file(s).
+ */
+ @Parameter( defaultValue = "UTF-8" )
+ protected String encoding;
+
+ /**
+ * Directory where the deployment descriptor file(s) will be
auto-generated.
+ */
+ @Parameter( defaultValue = "${project.build.directory}" )
+ protected String generatedDescriptorLocation;
+
+ /**
+ * The maven project.
+ */
+ @Parameter( defaultValue = "${project}", readonly = true, required = true )
+ protected MavenProject project;
+
+ /**
+ * The ear modules configuration.
+ */
+ @Parameter
+ private EarModule[] modules;
+
+ /**
+ * The artifact type mappings.
+ */
+ @Parameter
+ protected PlexusConfiguration artifactTypeMappings;
+
+ /**
+ * The default bundle dir for libraries.
+ */
+ @Parameter
+ protected String defaultLibBundleDir;
+
+ /**
+ * Should libraries be added in application.xml
+ */
+ @Parameter( defaultValue = "false" )
+ private Boolean includeLibInApplicationXml = Boolean.FALSE;
+
+ /**
+ * The file name mapping to use for all dependencies included in the EAR
file. The following values are valid
+ * {@code standard}, {@code no-version}, {@code full}, {@code
no-version-for-ejb}. The {@code standard} means the
+ * filename is the artifactId incl. the version of the artifact. The
{@code no-version} means the files is only the
+ * artifactId without the version. The {@code full} means the filename is
the groupId+artifactId+version of the
+ * artifact. The {@code no-version-for-ejb} means the filename is the
artifactId without the version in case of
+ * {@code EJB} type.
+ */
+ @Parameter
+ private String fileNameMapping;
+
+ /**
+ * When using a {@link #fileNameMapping} with versions, either use the
{@code baseVersion} or the {@code version}.
+ * When the artifact is a SNAPSHOT, {@code version} will always return a
value with a {@code -SNAPSHOT} postfix
+ * instead of the possible timestamped value.
+ *
+ * @since 2.9
+ */
+ @Parameter
+ private Boolean useBaseVersion;
+
+ /**
+ * Directory that resources are copied to during the build.
+ */
+ @Parameter( defaultValue =
"${project.build.directory}/${project.build.finalName}", required = true )
+ private File workDirectory;
+
+ /**
+ * The JBoss specific configuration.
+ *
+ * @parameter
+ */
+ @Parameter
+ private PlexusConfiguration jboss;
+
+ /**
+ * The id to use to define the main artifact (e.g. the artifact without a
classifier) when there is multiple
+ * candidates.
+ *
+ * @parameter
+ */
+ @Parameter
+ private String mainArtifactId = "none";
+
+ /**
+ * temp folder location.
+ */
+ @Parameter( defaultValue = "${project.build.directory}", required = true )
+ private File tempFolder;
+
+ @Component
+ private MavenResourcesFiltering mavenResourcesFiltering;
+
+ private List<EarModule> earModules;
+
+ private List<EarModule> allModules;
+
+ private JbossConfiguration jbossConfiguration;
+
+ /** {@inheritDoc} */
+ public void execute()
+ throws MojoExecutionException, MojoFailureException
+ {
+ final JavaEEVersion javaEEVersion = JavaEEVersion.getJavaEEVersion(
version );
+ getLog().debug( "Resolving artifact type mappings ..." );
+ ArtifactTypeMappingService typeMappingService;
+ try
+ {
+ typeMappingService = new ArtifactTypeMappingService();
+ typeMappingService.configure( artifactTypeMappings );
+ }
+ catch ( EarPluginException e )
+ {
+ throw new MojoExecutionException( "Failed to initialize artifact
type mappings", e );
+ }
+ catch ( PlexusConfigurationException e )
+ {
+ throw new MojoExecutionException( "Invalid artifact type mappings
configuration", e );
+ }
+
+ getLog().debug( "Initializing JBoss configuration if necessary ..." );
+ try
+ {
+ initializeJbossConfiguration();
+ }
+ catch ( EarPluginException e )
+ {
+ throw new MojoExecutionException( "Failed to initialize JBoss
configuration", e );
+ }
+
+ getLog().debug( "Initializing ear execution context" );
+ EarExecutionContext earExecutionContext =
+ new EarExecutionContext( project, mainArtifactId,
defaultLibBundleDir, jbossConfiguration, fileNameMapping,
+ typeMappingService );
+
+ if ( useBaseVersion != null )
+ {
+ earExecutionContext.getFileNameMapping().setUseBaseVersion(
useBaseVersion );
+ }
+
+ getLog().debug( "Resolving ear modules ..." );
+ allModules = new ArrayList<EarModule>();
+ try
+ {
+ if ( modules != null && modules.length > 0 )
+ {
+ // Let's validate user-defined modules
+ EarModule module;
+
+ for ( EarModule module1 : modules )
+ {
+ module = module1;
+ getLog().debug( "Resolving ear module[" + module + "]" );
+ module.setEarExecutionContext( earExecutionContext );
+ module.resolveArtifact( project.getArtifacts() );
+ allModules.add( module );
+ }
+ }
+
+ // Let's add other modules
+ Set<Artifact> artifacts = project.getArtifacts();
+ for ( Artifact artifact : artifacts )
+ {
+ // If the artifact's type is POM, ignore and continue
+ // since it's used for transitive deps only.
+ if ( "pom".equals( artifact.getType() ) )
+ {
+ continue;
+ }
+
+ // Artifact is not yet registered and it has neither test, nor
a
+ // provided scope, not is it optional
+ ScopeArtifactFilter filter = new ScopeArtifactFilter(
Artifact.SCOPE_RUNTIME );
+ if ( !isArtifactRegistered( artifact, allModules ) &&
!artifact.isOptional()
+ && filter.include( artifact ) )
+ {
+ EarModule module = EarModuleFactory.newEarModule(
artifact, javaEEVersion, defaultLibBundleDir,
+
includeLibInApplicationXml, typeMappingService );
+ module.setEarExecutionContext( earExecutionContext );
+ allModules.add( module );
+ }
+ }
+ }
+ catch ( EarPluginException e )
+ {
+ throw new MojoExecutionException( "Failed to initialize ear
modules", e );
+ }
+
+ // Now we have everything let's built modules which have not been
excluded
+ earModules = new ArrayList<EarModule>();
+ for ( EarModule earModule : allModules )
+ {
+ if ( earModule.isExcluded() )
+ {
+ getLog().debug( "Skipping ear module[" + earModule + "]" );
+ }
+ else
+ {
+ earModules.add( earModule );
+ }
+ }
+
+ }
+
+ /**
+ * @return The list of {@link #earModules}.
+ */
+ protected List<EarModule> getModules()
+ {
+ if ( earModules == null )
+ {
+ throw new IllegalStateException( "Ear modules have not been
initialized" );
+ }
+ return earModules;
+ }
+
+ /**
+ * @return {@link MavenProject}
+ */
+ protected MavenProject getProject()
+ {
+ return project;
+ }
+
+ /**
+ * @return {@link #workDirectory}
+ */
+ protected File getWorkDirectory()
+ {
+ return workDirectory;
+ }
+
+ /**
+ * @return {@link #jbossConfiguration}
+ */
+ protected JbossConfiguration getJbossConfiguration()
+ {
+ return jbossConfiguration;
+ }
+
+ /**
+ * @return {@link #tempFolder}
+ */
+ public File getTempFolder()
+ {
+ return tempFolder;
+ }
+
+ private static boolean isArtifactRegistered( Artifact a, List<EarModule>
currentList )
+ {
+ for ( EarModule em : currentList )
+ {
+ if ( em.getArtifact().equals( a ) )
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Initializes the JBoss configuration.
+ *
+ * @throws EarPluginException if the configuration is invalid
+ */
+ private void initializeJbossConfiguration()
+ throws EarPluginException
+ {
+ if ( jboss == null )
+ {
+ jbossConfiguration = null;
+ }
+ else
+ {
+ String childVersion = jboss.getChild( JbossConfiguration.VERSION
).getValue();
+ if ( childVersion == null )
+ {
+ getLog().info( "JBoss version not set, using JBoss 4 by
default" );
+ childVersion = JbossConfiguration.VERSION_4;
+ }
+ final String securityDomain = jboss.getChild(
JbossConfiguration.SECURITY_DOMAIN ).getValue();
+ final String unauthenticatedPrincipal =
+ jboss.getChild( JbossConfiguration.UNAUHTHENTICTED_PRINCIPAL
).getValue();
+
+ final PlexusConfiguration loaderRepositoryEl = jboss.getChild(
JbossConfiguration.LOADER_REPOSITORY );
+ final String loaderRepository = loaderRepositoryEl.getValue();
+ final String loaderRepositoryClass =
+ loaderRepositoryEl.getAttribute(
JbossConfiguration.LOADER_REPOSITORY_CLASS_ATTRIBUTE );
+ final PlexusConfiguration loaderRepositoryConfigEl =
+ jboss.getChild( JbossConfiguration.LOADER_REPOSITORY_CONFIG );
+ final String loaderRepositoryConfig =
loaderRepositoryConfigEl.getValue();
+ final String configParserClass =
+ loaderRepositoryConfigEl.getAttribute(
JbossConfiguration.CONFIG_PARSER_CLASS_ATTRIBUTE );
+
+ final String jmxName = jboss.getChild( JbossConfiguration.JMX_NAME
).getValue();
+ final String moduleOrder = jboss.getChild(
JbossConfiguration.MODULE_ORDER ).getValue();
+
+ final List<String> dataSources = new ArrayList<String>();
+ final PlexusConfiguration dataSourcesEl = jboss.getChild(
JbossConfiguration.DATASOURCES );
+ if ( dataSourcesEl != null )
+ {
+
+ final PlexusConfiguration[] dataSourcesConfig =
+ dataSourcesEl.getChildren( JbossConfiguration.DATASOURCE );
+ for ( PlexusConfiguration dataSourceConfig : dataSourcesConfig
)
+ {
+ dataSources.add( dataSourceConfig.getValue() );
+
+ }
+ }
+ final String libraryDirectory = jboss.getChild(
JbossConfiguration.LIBRARY_DIRECTORY ).getValue();
+ jbossConfiguration =
+ new JbossConfiguration( childVersion, securityDomain,
unauthenticatedPrincipal, jmxName,
+ loaderRepository, moduleOrder,
dataSources, libraryDirectory,
+ loaderRepositoryConfig,
loaderRepositoryClass, configParserClass );
+ }
+ }
+}
Added:
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AbstractXmlWriter.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AbstractXmlWriter.java?rev=1755643&view=auto
==============================================================================
---
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AbstractXmlWriter.java
(added)
+++
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AbstractXmlWriter.java
Tue Aug 9 19:17:58 2016
@@ -0,0 +1,91 @@
+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.WriterFactory;
+import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
+import org.codehaus.plexus.util.xml.XMLWriter;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * A base class for deployment descriptor file generators.
+ *
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: AbstractXmlWriter.java 1636449 2014-11-03 21:27:36Z
khmarbaise $
+ */
+abstract class AbstractXmlWriter
+{
+
+ private final String encoding;
+
+ protected static final String MODULE_ELEMENT = "module";
+
+ protected static final String SERVICE_ELEMENT = "service";
+
+ AbstractXmlWriter( String encoding )
+ {
+ this.encoding = encoding;
+ }
+
+ protected Writer initializeWriter( final File destinationFile )
+ throws EarPluginException
+ {
+ try
+ {
+ return WriterFactory.newXmlWriter( destinationFile );
+ }
+ catch ( IOException ex )
+ {
+ // CHECKSTYLE_OFF: LineLength
+ throw new EarPluginException( "Exception while opening file[" +
destinationFile.getAbsolutePath() + "]", ex );
+ // CHECKSTYLE_ON: LineLength
+ }
+ }
+
+ protected XMLWriter initializeXmlWriter( final Writer writer, final String
docType )
+ {
+ return new PrettyPrintXMLWriter( writer, encoding, docType );
+ }
+
+ protected void close( Writer closeable )
+ {
+ if ( closeable == null )
+ {
+ return;
+ }
+
+ try
+ {
+ closeable.close();
+ }
+ catch ( Exception e )
+ {
+ // TODO: warn
+ }
+ }
+
+ public String getEncoding()
+ {
+ return encoding;
+ }
+}
Added:
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AppClientModule.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AppClientModule.java?rev=1755643&view=auto
==============================================================================
---
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AppClientModule.java
(added)
+++
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/AppClientModule.java
Tue Aug 9 19:17:58 2016
@@ -0,0 +1,71 @@
+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 application client module.
+ *
+ * @author Stephane Nicoll
+ */
+public class AppClientModule
+ extends AbstractEarModule
+{
+
+ /**
+ * Create an instance.
+ */
+ public AppClientModule()
+ {
+ }
+
+ /**
+ * @param a {@link Artifact}
+ */
+ public AppClientModule( Artifact a )
+ {
+ super( a );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void appendModule( XMLWriter writer, String version, Boolean
generateId )
+ {
+ startModuleElement( writer, generateId );
+ writer.startElement( JAVA_MODULE );
+ writer.writeText( getUri() );
+ writer.endElement();
+
+ writeAltDeploymentDescriptor( writer, version );
+
+ writer.endElement();
+ }
+
+ /**
+ * @return The type of the module.
+ */
+ public String getType()
+ {
+ return "app-client";
+ }
+}
Added:
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriter.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriter.java?rev=1755643&view=auto
==============================================================================
---
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriter.java
(added)
+++
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriter.java
Tue Aug 9 19:17:58 2016
@@ -0,0 +1,250 @@
+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.io.Writer;
+
+import org.apache.maven.plugins.ear.util.JavaEEVersion;
+import org.codehaus.plexus.util.xml.XMLWriter;
+
+/**
+ * An <tt>XmlWriter</tt> based implementation used to generate an
<tt>application.xml</tt> file
+ *
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: ApplicationXmlWriter.java 1648055 2014-12-27 14:59:45Z
khmarbaise $
+ */
+final class ApplicationXmlWriter
+ extends AbstractXmlWriter
+{
+ public static final String DOCTYPE_1_3 = "application PUBLIC\n"
+ + "\t\"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN\"\n"
+ + "\t\"http://java.sun.com/dtd/application_1_3.dtd\"";
+
+ private static final String APPLICATION_ELEMENT = "application";
+
+ private final JavaEEVersion version;
+
+ private final Boolean generateModuleId;
+
+ ApplicationXmlWriter( JavaEEVersion version, String encoding, Boolean
generateModuleId )
+ {
+ super( encoding );
+ this.version = version;
+ this.generateModuleId = generateModuleId;
+ }
+
+ public void write( ApplicationXmlWriterContext context )
+ throws EarPluginException
+ {
+ Writer w = initializeWriter( context.getDestinationFile() );
+
+ XMLWriter writer = null;
+ if ( JavaEEVersion.ONE_DOT_THREE.eq( version ) )
+ {
+ writer = initializeRootElementOneDotThree( w );
+ }
+ else if ( JavaEEVersion.ONE_DOT_FOUR.eq( version ) )
+ {
+ writer = initializeRootElementOneDotFour( w );
+ }
+ else if ( JavaEEVersion.FIVE.eq( version ) )
+ {
+ writer = initializeRootElementFive( w );
+ }
+ else if ( JavaEEVersion.SIX.eq( version ) )
+ {
+ writer = initializeRootElementSix( w );
+ }
+ else if ( JavaEEVersion.SEVEN.eq( version ) )
+ {
+ writer = initializeRootElementSeven( w );
+ }
+
+ // writer is still on root element, so we can still add this attribute
+ if ( context.getApplicationId() != null )
+ {
+ writer.addAttribute( "id", context.getApplicationId() );
+ }
+
+ // As from JavaEE6
+ if ( version.ge( JavaEEVersion.SIX ) )
+ {
+ writeApplicationName( context.getApplicationName(), writer );
+ }
+
+ // IMPORTANT: the order of the description and display-name elements
was
+ // reversed between J2EE 1.3 and J2EE 1.4.
+ if ( version.eq( JavaEEVersion.ONE_DOT_THREE ) )
+ {
+ writeDisplayName( context.getDisplayName(), writer );
+ writeDescription( context.getDescription(), writer );
+ }
+ else
+ {
+ writeDescription( context.getDescription(), writer );
+ writeDisplayName( context.getDisplayName(), writer );
+ }
+
+ // As from JavaEE6
+ if ( version.ge( JavaEEVersion.SIX ) )
+ {
+ writeInitializeInOrder( context.getInitializeInOrder(), writer );
+ }
+
+ // Do not change this unless you really know what you're doing :)
+ for ( EarModule module : context.getEarModules() )
+ {
+ module.appendModule( writer, version.getVersion(),
generateModuleId );
+ }
+
+ for ( SecurityRole securityRole : context.getSecurityRoles() )
+ {
+ securityRole.appendSecurityRole( writer );
+ }
+
+ if ( version.ge( JavaEEVersion.FIVE ) )
+ {
+ writeLibraryDirectory( context.getLibraryDirectory(), writer );
+ }
+
+ if ( version.ge( JavaEEVersion.SIX ) )
+ {
+ for ( EnvEntry envEntry : context.getEnvEntries() )
+ {
+ envEntry.appendEnvEntry( writer );
+ }
+ for ( EjbRef ejbEntry : context.getEjbEntries() )
+ {
+ ejbEntry.appendEjbRefEntry( writer );
+ }
+ }
+
+ writer.endElement();
+
+ close( w );
+ }
+
+ private void writeApplicationName( String applicationName, XMLWriter
writer )
+ {
+ if ( applicationName != null )
+ {
+ writer.startElement( "application-name" );
+ writer.writeText( applicationName );
+ writer.endElement();
+ }
+ }
+
+ private void writeDescription( String description, XMLWriter writer )
+ {
+ if ( description != null )
+ {
+ writer.startElement( "description" );
+ writer.writeText( description );
+ writer.endElement();
+ }
+ }
+
+ private void writeDisplayName( String displayName, XMLWriter writer )
+ {
+ if ( displayName != null )
+ {
+ writer.startElement( "display-name" );
+ writer.writeText( displayName );
+ writer.endElement();
+ }
+ }
+
+ private void writeInitializeInOrder( Boolean initializeInOrder, XMLWriter
writer )
+ {
+ if ( initializeInOrder != null )
+ {
+ writer.startElement( "initialize-in-order" );
+ writer.writeText( initializeInOrder.toString() );
+ writer.endElement();
+ }
+ }
+
+ private void writeLibraryDirectory( String libraryDirectory, XMLWriter
writer )
+ {
+ if ( libraryDirectory != null )
+ {
+ writer.startElement( "library-directory" );
+ writer.writeText( libraryDirectory );
+ writer.endElement();
+ }
+ }
+
+ private XMLWriter initializeRootElementOneDotThree( Writer w )
+ {
+ XMLWriter writer = initializeXmlWriter( w, DOCTYPE_1_3 );
+ writer.startElement( APPLICATION_ELEMENT );
+ return writer;
+ }
+
+ private XMLWriter initializeRootElementOneDotFour( Writer w )
+ {
+ XMLWriter writer = initializeXmlWriter( w, null );
+ writer.startElement( APPLICATION_ELEMENT );
+ writer.addAttribute( "xmlns", "http://java.sun.com/xml/ns/j2ee" );
+ writer.addAttribute( "xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance" );
+ writer.addAttribute( "xsi:schemaLocation",
+ "http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/application_1_4.xsd" );
+ writer.addAttribute( "version", "1.4" );
+ return writer;
+ }
+
+ private XMLWriter initializeRootElementFive( Writer w )
+ {
+ XMLWriter writer = initializeXmlWriter( w, null );
+ writer.startElement( APPLICATION_ELEMENT );
+ writer.addAttribute( "xmlns", "http://java.sun.com/xml/ns/javaee" );
+ writer.addAttribute( "xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance" );
+ writer.addAttribute( "xsi:schemaLocation",
+ "http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/application_5.xsd" );
+ writer.addAttribute( "version", "5" );
+ return writer;
+ }
+
+ private XMLWriter initializeRootElementSix( Writer w )
+ {
+ XMLWriter writer = initializeXmlWriter( w, null );
+ writer.startElement( APPLICATION_ELEMENT );
+ writer.addAttribute( "xmlns", "http://java.sun.com/xml/ns/javaee" );
+ writer.addAttribute( "xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance" );
+ writer.addAttribute( "xsi:schemaLocation",
+ "http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/application_6.xsd" );
+ writer.addAttribute( "version", "6" );
+ return writer;
+ }
+
+ private XMLWriter initializeRootElementSeven( Writer w )
+ {
+ XMLWriter writer = initializeXmlWriter( w, null );
+ writer.startElement( APPLICATION_ELEMENT );
+ writer.addAttribute( "xmlns", "http://xmlns.jcp.org/xml/ns/javaee" );
+ writer.addAttribute( "xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance" );
+ // CHECKSTYLE_OFF: LineLength
+ writer.addAttribute( "xsi:schemaLocation",
+ "http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" );
+ // CHECKSTYLE_ON: LineLength
+ writer.addAttribute( "version", "7" );
+ return writer;
+ }
+}
Added:
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriterContext.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriterContext.java?rev=1755643&view=auto
==============================================================================
---
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriterContext.java
(added)
+++
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/ApplicationXmlWriterContext.java
Tue Aug 9 19:17:58 2016
@@ -0,0 +1,184 @@
+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.io.File;
+import java.util.List;
+
+/**
+ * A context for the {@link ApplicationXmlWriter}.
+ *
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: ApplicationXmlWriter.java 728546 2008-12-21 22:56:51Z
bentmann $
+ */
+class ApplicationXmlWriterContext
+{
+
+ private String applicationId;
+
+ private final File destinationFile;
+
+ private final List<EarModule> earModules;
+
+ private final List<SecurityRole> securityRoles;
+
+ private final List<EnvEntry> envEntries;
+
+ private final List<EjbRef> ejbEntries;
+
+ private final String displayName;
+
+ private final String description;
+
+ private final String libraryDirectory;
+
+ private final String applicationName;
+
+ private final Boolean initializeInOrder;
+
+ public ApplicationXmlWriterContext( File destinationFile, List<EarModule>
earModules,
+ List<SecurityRole> securityRoles,
List<EnvEntry> envEntries,
+ List<EjbRef> ejbEntries,
+ String displayName, String
description, String libraryDirectory,
+ String applicationName, Boolean
initializeInOrder )
+ {
+ this.destinationFile = destinationFile;
+ this.earModules = earModules;
+ this.securityRoles = securityRoles;
+ this.envEntries = envEntries;
+ this.ejbEntries = ejbEntries;
+ this.displayName = displayName;
+ this.description = description;
+ this.libraryDirectory = libraryDirectory;
+ this.applicationName = applicationName;
+ this.initializeInOrder = initializeInOrder;
+ }
+
+ public final ApplicationXmlWriterContext setApplicationId( String
applicationId )
+ {
+ this.applicationId = applicationId;
+ return this;
+ }
+
+ public final String getApplicationId()
+ {
+ return applicationId;
+ }
+
+ /**
+ * Returns the name of the file to use to write application.xml to.
+ *
+ * @return the output file
+ */
+ public File getDestinationFile()
+ {
+ return destinationFile;
+ }
+
+ /**
+ * Returns the list of {@link EarModule} instances.
+ *
+ * @return the ear modules
+ */
+ public List<EarModule> getEarModules()
+ {
+ return earModules;
+ }
+
+ /**
+ * Returns the list of {@link SecurityRole} instances.
+ *
+ * @return the security roles
+ */
+ public List<SecurityRole> getSecurityRoles()
+ {
+ return securityRoles;
+ }
+
+ /**
+ * Returns the list of {@link EnvEntry} instances (as per JavaEE 6).
+ *
+ * @return the env-entry elements
+ */
+ public List<EnvEntry> getEnvEntries()
+ {
+ return envEntries;
+ }
+
+ /**
+ * Returns the list of {@link EjbRef}.
+ *
+ * @return the env-ref elements
+ */
+ public List<EjbRef> getEjbEntries()
+ {
+ return ejbEntries;
+ }
+
+ /**
+ * Returns the display name.
+ *
+ * @return the display name
+ */
+ public String getDisplayName()
+ {
+ return displayName;
+ }
+
+ /**
+ * Returns the description.
+ *
+ * @return the description
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+ /**
+ * Returns the library directory (as per JavaEE 5).
+ *
+ * @return the library directory
+ */
+ public String getLibraryDirectory()
+ {
+ return libraryDirectory;
+ }
+
+ /**
+ * Returns the application name (as per JavaEE 6).
+ *
+ * @return the application name
+ */
+ public String getApplicationName()
+ {
+ return applicationName;
+ }
+
+ /**
+ * Returns the value of the initialize in order parameter (as per JavaEE
6).
+ *
+ * @return the initialize in order value
+ */
+ public Boolean getInitializeInOrder()
+ {
+ return initializeInOrder;
+ }
+}
Added:
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarExecutionContext.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarExecutionContext.java?rev=1755643&view=auto
==============================================================================
---
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarExecutionContext.java
(added)
+++
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarExecutionContext.java
Tue Aug 9 19:17:58 2016
@@ -0,0 +1,109 @@
+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.plugins.ear.output.FileNameMapping;
+import org.apache.maven.plugins.ear.output.FileNameMappingFactory;
+import org.apache.maven.plugins.ear.util.ArtifactRepository;
+import org.apache.maven.plugins.ear.util.ArtifactTypeMappingService;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Contains various runtime parameters used to customize the generated EAR
file.
+ *
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: EarExecutionContext.java 1755538 2016-08-08 20:32:12Z
rfscholte $
+ */
+public class EarExecutionContext
+{
+ private String defaultLibBundleDir;
+
+ private JbossConfiguration jbossConfiguration;
+
+ private FileNameMapping fileNameMapping;
+
+ private ArtifactRepository artifactRepository;
+
+ /**
+ * @param project {@link MavenProject}
+ * @param mainArtifactId The artifactId.
+ * @param defaultLibBundleDir The defaultLibBundleDir.
+ * @param jbossConfiguration {@link JbossConfiguration}
+ * @param fileNameMappingName file name mapping.
+ * @param typeMappingService {@link ArtifactTypeMappingService}
+ */
+ public EarExecutionContext( MavenProject project, String mainArtifactId,
String defaultLibBundleDir,
+ JbossConfiguration jbossConfiguration, String
fileNameMappingName,
+ ArtifactTypeMappingService typeMappingService )
+ {
+ initialize( project, mainArtifactId, defaultLibBundleDir,
jbossConfiguration, fileNameMappingName,
+ typeMappingService );
+
+ }
+
+ /**
+ * @return {@link #defaultLibBundleDir}
+ */
+ public String getDefaultLibBundleDir()
+ {
+ return defaultLibBundleDir;
+ }
+
+ /**
+ * @return {@link #jbossConfiguration}
+ */
+ public boolean isJbossConfigured()
+ {
+ return jbossConfiguration != null;
+ }
+
+ /**
+ * @return {@link #fileNameMapping}
+ */
+ public FileNameMapping getFileNameMapping()
+ {
+ return fileNameMapping;
+ }
+
+ /**
+ * @return {@link #artifactRepository}
+ */
+ public ArtifactRepository getArtifactRepository()
+ {
+ return artifactRepository;
+ }
+
+ private void initialize( MavenProject project, String mainArtifactId,
String defaultLibBundleDir,
+ JbossConfiguration jbossConfiguration, String
fileNameMappingName,
+ ArtifactTypeMappingService typeMappingService )
+ {
+ this.artifactRepository = new ArtifactRepository(
project.getArtifacts(), mainArtifactId, typeMappingService );
+ this.defaultLibBundleDir = defaultLibBundleDir;
+ this.jbossConfiguration = jbossConfiguration;
+ if ( fileNameMappingName == null ||
fileNameMappingName.trim().length() == 0 )
+ {
+ this.fileNameMapping =
FileNameMappingFactory.getDefaultFileNameMapping();
+ }
+ else
+ {
+ this.fileNameMapping = FileNameMappingFactory.getFileNameMapping(
fileNameMappingName );
+ }
+ }
+}
Added:
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarModule.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarModule.java?rev=1755643&view=auto
==============================================================================
---
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarModule.java
(added)
+++
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarModule.java
Tue Aug 9 19:17:58 2016
@@ -0,0 +1,122 @@
+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 ear module interface.
+ *
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: EarModule.java 1645331 2014-12-13 17:31:09Z khmarbaise $
+ */
+public interface EarModule
+{
+
+ /**
+ * Returns the {@link Artifact} representing this module.
+ * <p/>
+ * Note that this might return <tt>null</tt> till the module has been
resolved.
+ *
+ * @return the artifact
+ * @see #resolveArtifact(java.util.Set)
+ */
+ Artifact getArtifact();
+
+ /**
+ * Returns the <tt>URI</tt> for this module.
+ *
+ * @return the <tt>URI</tt>
+ */
+ String getUri();
+
+ /**
+ * Returns the type associated to the module.
+ *
+ * @return the artifact's type of the module
+ */
+ String getType();
+
+ /**
+ * Specify whether this module should be excluded or not.
+ *
+ * @return true if this module should be skipped, false otherwise
+ */
+ boolean isExcluded();
+
+ /**
+ * Specify whether this module should be unpacked in the EAR archive or
not.
+ * <p/>
+ * Returns null if no configuration was specified so that defaulting may
apply.
+ *
+ * @return true if this module should be bundled unpacked, false otherwise
+ */
+ Boolean shouldUnpack();
+
+ /**
+ * The alt-dd element specifies an optional URI to the post-assembly
version of the deployment descriptor file for a
+ * particular Java EE module. The URI must specify the full pathname of
the deployment descriptor file relative to
+ * the application's root directory.
+ *
+ * @return the alternative deployment descriptor for this module
+ * @since JavaEE 5
+ */
+ String getAltDeploymentDescriptor();
+
+ /**
+ * Appends the <tt>XML</tt> representation of this module.
+ *
+ * @param writer the writer to use
+ * @param version the version of the <tt>application.xml</tt> file
+ * @param generateId whether an id should be generated
+ */
+ void appendModule( XMLWriter writer, String version, Boolean generateId );
+
+ /**
+ * Resolves the {@link Artifact} represented by the module. Note that the
{@link EarExecutionContext} might be used
+ * to customize further the resolution.
+ *
+ * @param artifacts the project's artifacts
+ * @throws EarPluginException if the artifact could not be resolved
+ * @throws MojoFailureException if an unexpected error occurred
+ */
+ void resolveArtifact( Set<Artifact> artifacts )
+ throws EarPluginException, MojoFailureException;
+
+ /**
+ * @param earExecutionContext The execution context.
+ */
+ void setEarExecutionContext( EarExecutionContext earExecutionContext );
+
+ /**
+ * @return the state if manifest classpath will be changed or not.
+ */
+ boolean changeManifestClasspath();
+
+ /**
+ * @return The libDir.
+ */
+ String getLibDir();
+
+}
Added:
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarModuleFactory.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarModuleFactory.java?rev=1755643&view=auto
==============================================================================
---
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarModuleFactory.java
(added)
+++
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugins/ear/EarModuleFactory.java
Tue Aug 9 19:17:58 2016
@@ -0,0 +1,164 @@
+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.plugins.ear.util.ArtifactTypeMappingService;
+import org.apache.maven.plugins.ear.util.JavaEEVersion;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Builds an {@link EarModule} based on an <tt>Artifact</tt>.
+ *
+ * @author <a href="[email protected]">Stephane Nicoll</a>
+ * @version $Id: EarModuleFactory.java 1755538 2016-08-08 20:32:12Z rfscholte $
+ */
+public final class EarModuleFactory
+{
+ /**
+ * The list of artifact types.
+ */
+ public static final List<String> STANDARD_ARTIFACT_TYPE;
+
+ static
+ {
+ List<String> temp = new ArrayList<String>();
+ temp.add( "jar" );
+ temp.add( "ejb" );
+ temp.add( "par" );
+ temp.add( "ejb-client" );
+ temp.add( "app-client" );
+ temp.add( "rar" );
+ temp.add( "war" );
+ temp.add( "sar" );
+ temp.add( "wsr" );
+ temp.add( "har" );
+ STANDARD_ARTIFACT_TYPE = Collections.unmodifiableList( temp );
+ }
+
+ /**
+ * Creates a new {@link EarModule} based on the specified {@link Artifact}
and the specified execution
+ * configuration.
+ *
+ * @param artifact the artifact
+ * @param javaEEVersion the javaEE version to use
+ * @param defaultLibBundleDir the default bundle dir for {@link
org.apache.maven.plugins.ear.JarModule}
+ * @param includeInApplicationXml should {@link
org.apache.maven.plugins.ear.JarModule} be included in application
+ * Xml
+ * @param typeMappingService The artifact type mapping service
+ * @return an ear module for this artifact
+ * @throws UnknownArtifactTypeException if the artifact is not handled
+ */
+ // CHECKSTYLE_OFF: LineLength
+ public static EarModule newEarModule( Artifact artifact, JavaEEVersion
javaEEVersion, String defaultLibBundleDir,
+ Boolean includeInApplicationXml,
ArtifactTypeMappingService typeMappingService )
+ // CHECKSTYLE_ON: LineLength
+ throws UnknownArtifactTypeException
+ {
+ // Get the standard artifact type based on default config and
user-defined mapping(s)
+ final String artifactType;
+ try
+ {
+ artifactType = typeMappingService.getStandardType(
artifact.getType() );
+ }
+ catch ( UnknownArtifactTypeException e )
+ {
+ throw new UnknownArtifactTypeException( e.getMessage() + " for " +
artifact.getArtifactId() );
+ }
+
+ if ( "jar".equals( artifactType ) )
+ {
+ return new JarModule( artifact, defaultLibBundleDir,
includeInApplicationXml );
+ }
+ else if ( "ejb".equals( artifactType ) )
+ {
+ return new EjbModule( artifact );
+ }
+ else if ( "par".equals( artifactType ) )
+ {
+ return new ParModule( artifact );
+ }
+ else if ( "ejb-client".equals( artifactType ) )
+ {
+ // Somewhat weird way to tackle the problem described in MEAR-85
+ if ( javaEEVersion.le( JavaEEVersion.ONE_DOT_FOUR ) )
+ {
+ return new EjbClientModule( artifact, null );
+ }
+ else
+ {
+ return new EjbClientModule( artifact, defaultLibBundleDir );
+ }
+ }
+ else if ( "app-client".equals( artifactType ) )
+ {
+ return new AppClientModule( artifact );
+ }
+ else if ( "rar".equals( artifactType ) )
+ {
+ return new RarModule( artifact );
+ }
+ else if ( "war".equals( artifactType ) )
+ {
+ return new WebModule( artifact );
+ }
+ else if ( "sar".equals( artifactType ) )
+ {
+ return new SarModule( artifact );
+ }
+ else if ( "wsr".equals( artifactType ) )
+ {
+ return new WsrModule( artifact );
+ }
+ else if ( "har".equals( artifactType ) )
+ {
+ return new HarModule( artifact );
+ }
+ else
+ {
+ throw new IllegalStateException( "Could not handle artifact type["
+ artifactType + "]" );
+ }
+ }
+
+ /**
+ * Returns a list of standard artifact types.
+ *
+ * @return the standard artifact types
+ */
+ public static List<String> getStandardArtifactTypes()
+ {
+ return STANDARD_ARTIFACT_TYPE;
+ }
+
+ /**
+ * Specify whether the specified type is standard artifact type.
+ *
+ * @param type the type to check
+ * @return true if the specified type is a standard artifact type
+ */
+ public static boolean isStandardArtifactType( final String type )
+ {
+ return STANDARD_ARTIFACT_TYPE.contains( type );
+ }
+
+}