Package org.apache.maven.plugin.ear
Class EarMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugin.ear.AbstractEarMojo
-
- org.apache.maven.plugin.ear.EarMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="ear", defaultPhase=PACKAGE, threadSafe=true, requiresDependencyResolution=TEST) public class EarMojo extends AbstractEarMojo
Builds J2EE Enterprise Archive (EAR) files.- Version:
- $Id: EarMojo.java 1645331 2014-12-13 17:31:09Z khmarbaise $
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
applicationXml
The location of a custom application.xml file to be used within the EAR file.private org.apache.maven.archiver.MavenArchiveConfiguration
archive
The archive configuration to use.private org.codehaus.plexus.archiver.manager.ArchiverManager
archiverManager
The archive manager.private java.lang.String
classifier
Classifier to add to the artifact generated.private boolean
duplicateArtifactsBreakTheBuild
The list of artifacts is checked and if you set this totrue
the build will fail if duplicate artifacts have been found within the build configuration.private java.io.File
earSourceDirectory
Single directory for extra files to include in the EAR.private java.lang.String
earSourceExcludes
The comma separated list of tokens to exclude from the EAR.private java.lang.String
earSourceIncludes
The comma separated list of tokens to include in the EAR.private boolean
escapedBackslashesInFilePath
To escape interpolated value with Windows path c:\foo\bar will be replaced with c:\\foo\\bar.protected java.lang.String
escapeString
Expression preceded with this String won't be interpolated \${foo} will be replaced with ${foo}.private boolean
filtering
Specify that the EAR sources should be filtered.private java.util.List<java.lang.String>
filters
Filters (property files) to include during the interpolation of the pom.xml.private java.util.List<org.apache.maven.shared.utils.io.FileUtils.FilterWrapper>
filterWrappers
private java.lang.String
finalName
The name of the EAR file to generate.private org.codehaus.plexus.archiver.jar.JarArchiver
jarArchiver
The Jar archiver.private java.io.File
manifestFile
The location of the manifest file to be used within the EAR file.private org.apache.maven.shared.filtering.MavenFileFilter
mavenFileFilter
private org.apache.maven.shared.filtering.MavenResourcesFiltering
mavenResourcesFiltering
private java.util.List<java.lang.String>
nonFilteredFileExtensions
A list of file extensions that should not be filtered if filtering is enabled.private java.lang.String
outputDirectory
The directory for the generated EAR.private java.lang.String
packagingExcludes
A comma separated list of tokens to exclude when packaging the EAR.private java.lang.String
packagingIncludes
A comma separated list of tokens to include when packaging the EAR.private org.apache.maven.project.MavenProjectHelper
projectHelper
private org.apache.maven.execution.MavenSession
session
private boolean
skinnyWars
Whether to create skinny WARs or not.private boolean
skipClassPathModification
In case of using theskinnyWars
andAbstractEarMojo.defaultLibBundleDir
usually the classpath will be modified.private java.lang.String
unpackTypes
The comma separated list of artifact's type(s) to unpack by default.private boolean
useJvmChmod
private org.codehaus.plexus.archiver.zip.ZipArchiver
zipArchiver
The Zip archiver.private org.codehaus.plexus.archiver.zip.ZipUnArchiver
zipUnArchiver
The Zip Un archiver.-
Fields inherited from class org.apache.maven.plugin.ear.AbstractEarMojo
APPLICATION_XML_URI, artifactTypeMappings, defaultLibBundleDir, encoding, generatedDescriptorLocation, META_INF, project, UTF_8, version
-
-
Constructor Summary
Constructors Constructor Description EarMojo()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.io.File
buildDestinationFile(java.io.File buildDir, java.lang.String uri)
private void
changeManifestClasspath(EarModule module, java.io.File original, JavaEEVersion javaEEVersion)
private void
checkModuleUniqueness()
private void
copyFile(java.io.File source, java.io.File target)
private void
copyModules(JavaEEVersion javaEEVersion, java.util.List<java.lang.String> unpackTypesList)
private java.util.List<java.lang.String>
createUnpackList()
void
execute()
java.lang.String
getApplicationXml()
private static java.io.File
getEarFile(java.lang.String basedir, java.lang.String finalName, java.lang.String classifier)
Returns the EAR file to generate, based on an optional classifier.private java.lang.String[]
getEarFiles(java.io.File sourceDir)
Returns a list of filenames that should be copied over to the destination directory.protected java.lang.String[]
getExcludes()
Returns a string array of the excludes to be used when assembling/copying the ear.private java.util.List<org.apache.maven.shared.utils.io.FileUtils.FilterWrapper>
getFilterWrappers()
protected java.lang.String[]
getIncludes()
Returns a string array of the includes to be used when assembling/copying the ear.protected org.codehaus.plexus.archiver.jar.JarArchiver
getJarArchiver()
Returns theJarArchiver
implementation used to package the EAR file.java.lang.String[]
getPackagingExcludes()
java.lang.String[]
getPackagingIncludes()
private void
includeCustomManifestFile()
boolean
isNonFilteredExtension(java.lang.String fileName)
void
setApplicationXml(java.lang.String applicationXml)
void
setPackagingExcludes(java.lang.String packagingExcludes)
void
setPackagingIncludes(java.lang.String packagingIncludes)
void
unpack(java.io.File source, java.io.File destDir)
Unpacks the module into the EAR structure.-
Methods inherited from class org.apache.maven.plugin.ear.AbstractEarMojo
getJbossConfiguration, getModules, getProject, getTempFolder, getWorkDirectory
-
-
-
-
Field Detail
-
earSourceDirectory
@Parameter(defaultValue="${basedir}/src/main/application", required=true) private java.io.File earSourceDirectory
Single directory for extra files to include in the EAR.
-
earSourceIncludes
@Parameter(alias="includes", defaultValue="**") private java.lang.String earSourceIncludes
The comma separated list of tokens to include in the EAR.
-
earSourceExcludes
@Parameter(alias="excludes") private java.lang.String earSourceExcludes
The comma separated list of tokens to exclude from the EAR.
-
filtering
@Parameter(defaultValue="false") private boolean filtering
Specify that the EAR sources should be filtered.- Since:
- 2.3.2
-
filters
@Parameter private java.util.List<java.lang.String> filters
Filters (property files) to include during the interpolation of the pom.xml.- Since:
- 2.3.2
-
nonFilteredFileExtensions
@Parameter private java.util.List<java.lang.String> nonFilteredFileExtensions
A list of file extensions that should not be filtered if filtering is enabled.- Since:
- 2.3.2
-
escapedBackslashesInFilePath
@Parameter(property="maven.ear.escapedBackslashesInFilePath", defaultValue="false") private boolean escapedBackslashesInFilePath
To escape interpolated value with Windows path c:\foo\bar will be replaced with c:\\foo\\bar.- Since:
- 2.3.2
-
escapeString
@Parameter(property="maven.ear.escapeString") protected java.lang.String escapeString
Expression preceded with this String won't be interpolated \${foo} will be replaced with ${foo}.- Since:
- 2.3.2
-
skipClassPathModification
@Parameter(defaultValue="false") private boolean skipClassPathModification
In case of using theskinnyWars
andAbstractEarMojo.defaultLibBundleDir
usually the classpath will be modified. By settings this optiontrue
you can change this and keep the classpath untouched. This option has been introduced to keep the backward compatibility with earlier versions of the plugin.- Since:
- 2.10
-
manifestFile
@Parameter private java.io.File manifestFile
The location of the manifest file to be used within the EAR file. If no value if specified, the default location in the workDirectory is taken. If the file does not exist, a manifest will be generated automatically.
-
applicationXml
@Parameter private java.lang.String applicationXml
The location of a custom application.xml file to be used within the EAR file.
-
outputDirectory
@Parameter(defaultValue="${project.build.directory}", required=true) private java.lang.String outputDirectory
The directory for the generated EAR.
-
finalName
@Parameter(alias="earName", defaultValue="${project.build.finalName}", required=true) private java.lang.String finalName
The name of the EAR file to generate.
-
unpackTypes
@Parameter private java.lang.String unpackTypes
The comma separated list of artifact's type(s) to unpack by default.
-
classifier
@Parameter private java.lang.String classifier
Classifier to add to the artifact generated. If given, the artifact will be an attachment instead.
-
packagingExcludes
@Parameter private java.lang.String packagingExcludes
A comma separated list of tokens to exclude when packaging the EAR. By default nothing is excluded. Note that you can use the Java Regular Expressions engine to include and exclude specific pattern using the expression %regex[]. Hint: read the about (?!Pattern).- Since:
- 2.7
-
packagingIncludes
@Parameter private java.lang.String packagingIncludes
A comma separated list of tokens to include when packaging the EAR. By default everything is included. Note that you can use the Java Regular Expressions engine to include and exclude specific pattern using the expression %regex[].- Since:
- 2.7
-
skinnyWars
@Parameter(property="maven.ear.skinnyWars", defaultValue="false") private boolean skinnyWars
Whether to create skinny WARs or not. A skinny WAR is a WAR that does not have all of its dependencies in WEB-INF/lib. Instead those dependencies are shared between the WARs through the EAR.- Since:
- 2.7
-
jarArchiver
@Component(role=org.codehaus.plexus.archiver.Archiver.class, hint="jar") private org.codehaus.plexus.archiver.jar.JarArchiver jarArchiver
The Jar archiver.
-
zipArchiver
@Component(role=org.codehaus.plexus.archiver.Archiver.class, hint="zip") private org.codehaus.plexus.archiver.zip.ZipArchiver zipArchiver
The Zip archiver.
-
zipUnArchiver
@Component(role=org.codehaus.plexus.archiver.UnArchiver.class, hint="zip") private org.codehaus.plexus.archiver.zip.ZipUnArchiver zipUnArchiver
The Zip Un archiver.
-
archive
@Parameter private org.apache.maven.archiver.MavenArchiveConfiguration archive
The archive configuration to use. See Maven Archiver Reference.
-
projectHelper
@Component private org.apache.maven.project.MavenProjectHelper projectHelper
-
archiverManager
@Component private org.codehaus.plexus.archiver.manager.ArchiverManager archiverManager
The archive manager.
-
mavenFileFilter
@Component(role=org.apache.maven.shared.filtering.MavenFileFilter.class, hint="default") private org.apache.maven.shared.filtering.MavenFileFilter mavenFileFilter
-
mavenResourcesFiltering
@Component(role=org.apache.maven.shared.filtering.MavenResourcesFiltering.class, hint="default") private org.apache.maven.shared.filtering.MavenResourcesFiltering mavenResourcesFiltering
-
session
@Parameter(defaultValue="${session}", readonly=true, required=true) private org.apache.maven.execution.MavenSession session
- Since:
- 2.3.2
-
filterWrappers
private java.util.List<org.apache.maven.shared.utils.io.FileUtils.FilterWrapper> filterWrappers
-
useJvmChmod
@Parameter(property="maven.ear.useJvmChmod", defaultValue="true") private boolean useJvmChmod
- Since:
- 2.9
-
duplicateArtifactsBreakTheBuild
@Parameter(defaultValue="false", property="maven.ear.duplicateArtifactsBreakTheBuild") private boolean duplicateArtifactsBreakTheBuild
The list of artifacts is checked and if you set this totrue
the build will fail if duplicate artifacts have been found within the build configuration.- Since:
- 2.10
-
-
Method Detail
-
checkModuleUniqueness
private void checkModuleUniqueness() throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Specified by:
execute
in interfaceorg.apache.maven.plugin.Mojo
- Overrides:
execute
in classAbstractEarMojo
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
copyModules
private void copyModules(JavaEEVersion javaEEVersion, java.util.List<java.lang.String> unpackTypesList) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
createUnpackList
private java.util.List<java.lang.String> createUnpackList() throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getApplicationXml
public java.lang.String getApplicationXml()
- Returns:
applicationXml
-
setApplicationXml
public void setApplicationXml(java.lang.String applicationXml)
- Parameters:
applicationXml
-applicationXml
-
getExcludes
protected java.lang.String[] getExcludes()
Returns a string array of the excludes to be used when assembling/copying the ear.- Returns:
- an array of tokens to exclude
-
getIncludes
protected java.lang.String[] getIncludes()
Returns a string array of the includes to be used when assembling/copying the ear.- Returns:
- an array of tokens to include
-
getPackagingExcludes
public java.lang.String[] getPackagingExcludes()
- Returns:
- The array with the packaging excludes.
-
setPackagingExcludes
public void setPackagingExcludes(java.lang.String packagingExcludes)
- Parameters:
packagingExcludes
-packagingExcludes
-
getPackagingIncludes
public java.lang.String[] getPackagingIncludes()
- Returns:
- The arrays with the includes.
-
setPackagingIncludes
public void setPackagingIncludes(java.lang.String packagingIncludes)
- Parameters:
packagingIncludes
-packagingIncludes
-
buildDestinationFile
private static java.io.File buildDestinationFile(java.io.File buildDir, java.lang.String uri)
-
includeCustomManifestFile
private void includeCustomManifestFile()
-
getEarFile
private static java.io.File getEarFile(java.lang.String basedir, java.lang.String finalName, java.lang.String classifier)
Returns the EAR file to generate, based on an optional classifier.- Parameters:
basedir
- the output directoryfinalName
- the name of the ear fileclassifier
- an optional classifier- Returns:
- the EAR file to generate
-
getEarFiles
private java.lang.String[] getEarFiles(java.io.File sourceDir)
Returns a list of filenames that should be copied over to the destination directory.- Parameters:
sourceDir
- the directory to be scanned- Returns:
- the array of filenames, relative to the sourceDir
-
unpack
public void unpack(java.io.File source, java.io.File destDir) throws org.codehaus.plexus.archiver.manager.NoSuchArchiverException, java.io.IOException
Unpacks the module into the EAR structure.- Parameters:
source
- File to be unpacked.destDir
- Location where to put the unpacked files.- Throws:
org.codehaus.plexus.archiver.manager.NoSuchArchiverException
- In case of we don't have an appropriate archiver.java.io.IOException
- In case of a general IOException.
-
getJarArchiver
protected org.codehaus.plexus.archiver.jar.JarArchiver getJarArchiver()
Returns theJarArchiver
implementation used to package the EAR file. By default the archiver is obtained from the Plexus container.- Returns:
- the archiver
-
copyFile
private void copyFile(java.io.File source, java.io.File target) throws org.apache.maven.shared.filtering.MavenFilteringException, java.io.IOException, org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.shared.filtering.MavenFilteringException
java.io.IOException
org.apache.maven.plugin.MojoExecutionException
-
isNonFilteredExtension
public boolean isNonFilteredExtension(java.lang.String fileName)
- Parameters:
fileName
- The name of the file which should be checked.- Returns:
true
if the name is part of the non filtered extensionsfalse
otherwise.
-
getFilterWrappers
private java.util.List<org.apache.maven.shared.utils.io.FileUtils.FilterWrapper> getFilterWrappers() throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
changeManifestClasspath
private void changeManifestClasspath(EarModule module, java.io.File original, JavaEEVersion javaEEVersion) throws org.apache.maven.plugin.MojoFailureException
- Throws:
org.apache.maven.plugin.MojoFailureException
-
-