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 AbstractEarMojoBuilds 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.StringapplicationXmlThe location of a custom application.xml file to be used within the EAR file.private org.apache.maven.archiver.MavenArchiveConfigurationarchiveThe archive configuration to use.private org.codehaus.plexus.archiver.manager.ArchiverManagerarchiverManagerThe archive manager.private java.lang.StringclassifierClassifier to add to the artifact generated.private booleanduplicateArtifactsBreakTheBuildThe list of artifacts is checked and if you set this totruethe build will fail if duplicate artifacts have been found within the build configuration.private java.io.FileearSourceDirectorySingle directory for extra files to include in the EAR.private java.lang.StringearSourceExcludesThe comma separated list of tokens to exclude from the EAR.private java.lang.StringearSourceIncludesThe comma separated list of tokens to include in the EAR.private booleanescapedBackslashesInFilePathTo escape interpolated value with Windows path c:\foo\bar will be replaced with c:\\foo\\bar.protected java.lang.StringescapeStringExpression preceded with this String won't be interpolated \${foo} will be replaced with ${foo}.private booleanfilteringSpecify that the EAR sources should be filtered.private java.util.List<java.lang.String>filtersFilters (property files) to include during the interpolation of the pom.xml.private java.util.List<org.apache.maven.shared.utils.io.FileUtils.FilterWrapper>filterWrappersprivate java.lang.StringfinalNameThe name of the EAR file to generate.private org.codehaus.plexus.archiver.jar.JarArchiverjarArchiverThe Jar archiver.private java.io.FilemanifestFileThe location of the manifest file to be used within the EAR file.private org.apache.maven.shared.filtering.MavenFileFiltermavenFileFilterprivate org.apache.maven.shared.filtering.MavenResourcesFilteringmavenResourcesFilteringprivate java.util.List<java.lang.String>nonFilteredFileExtensionsA list of file extensions that should not be filtered if filtering is enabled.private java.lang.StringoutputDirectoryThe directory for the generated EAR.private java.lang.StringpackagingExcludesA comma separated list of tokens to exclude when packaging the EAR.private java.lang.StringpackagingIncludesA comma separated list of tokens to include when packaging the EAR.private org.apache.maven.project.MavenProjectHelperprojectHelperprivate org.apache.maven.execution.MavenSessionsessionprivate booleanskinnyWarsWhether to create skinny WARs or not.private booleanskipClassPathModificationIn case of using theskinnyWarsandAbstractEarMojo.defaultLibBundleDirusually the classpath will be modified.private java.lang.StringunpackTypesThe comma separated list of artifact's type(s) to unpack by default.private booleanuseJvmChmodprivate org.codehaus.plexus.archiver.zip.ZipArchiverzipArchiverThe Zip archiver.private org.codehaus.plexus.archiver.zip.ZipUnArchiverzipUnArchiverThe 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.FilebuildDestinationFile(java.io.File buildDir, java.lang.String uri)private voidchangeManifestClasspath(EarModule module, java.io.File original, JavaEEVersion javaEEVersion)private voidcheckModuleUniqueness()private voidcopyFile(java.io.File source, java.io.File target)private voidcopyModules(JavaEEVersion javaEEVersion, java.util.List<java.lang.String> unpackTypesList)private java.util.List<java.lang.String>createUnpackList()voidexecute()java.lang.StringgetApplicationXml()private static java.io.FilegetEarFile(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.JarArchivergetJarArchiver()Returns theJarArchiverimplementation used to package the EAR file.java.lang.String[]getPackagingExcludes()java.lang.String[]getPackagingIncludes()private voidincludeCustomManifestFile()booleanisNonFilteredExtension(java.lang.String fileName)voidsetApplicationXml(java.lang.String applicationXml)voidsetPackagingExcludes(java.lang.String packagingExcludes)voidsetPackagingIncludes(java.lang.String packagingIncludes)voidunpack(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 earSourceDirectorySingle directory for extra files to include in the EAR.
-
earSourceIncludes
@Parameter(alias="includes", defaultValue="**") private java.lang.String earSourceIncludesThe 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 escapedBackslashesInFilePathTo 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 theskinnyWarsandAbstractEarMojo.defaultLibBundleDirusually the classpath will be modified. By settings this optiontrueyou 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 outputDirectoryThe directory for the generated EAR.
-
finalName
@Parameter(alias="earName", defaultValue="${project.build.finalName}", required=true) private java.lang.String finalNameThe 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 skinnyWarsWhether 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 jarArchiverThe Jar archiver.
-
zipArchiver
@Component(role=org.codehaus.plexus.archiver.Archiver.class, hint="zip") private org.codehaus.plexus.archiver.zip.ZipArchiver zipArchiverThe Zip archiver.
-
zipUnArchiver
@Component(role=org.codehaus.plexus.archiver.UnArchiver.class, hint="zip") private org.codehaus.plexus.archiver.zip.ZipUnArchiver zipUnArchiverThe 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 duplicateArtifactsBreakTheBuildThe list of artifacts is checked and if you set this totruethe 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:
executein interfaceorg.apache.maven.plugin.Mojo- Overrides:
executein classAbstractEarMojo- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.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.MojoExecutionExceptionorg.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.IOExceptionUnpacks 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 theJarArchiverimplementation 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.MavenFilteringExceptionjava.io.IOExceptionorg.apache.maven.plugin.MojoExecutionException
-
isNonFilteredExtension
public boolean isNonFilteredExtension(java.lang.String fileName)
- Parameters:
fileName- The name of the file which should be checked.- Returns:
trueif the name is part of the non filtered extensionsfalseotherwise.
-
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
-
-