[MWAR-325]
- Cleaned up several Checkstyle (errors, warnings)
- CPD issues.
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1628849 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java b/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
index 5cebaf6..0ce6504 100644
--- a/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
+++ b/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
@@ -84,9 +84,9 @@
private File classesDirectory;
/**
- * Whether a JAR file will be created for the classes in the webapp. Using this optional configuration
- * parameter will make the compiled classes to be archived into a JAR file
- * and the classes directory will then be excluded from the webapp.
+ * Whether a JAR file will be created for the classes in the webapp. Using this optional configuration parameter
+ * will make the compiled classes to be archived into a JAR file and the classes directory will then be excluded
+ * from the webapp.
*
* @since 2.0.1
*/
@@ -114,8 +114,7 @@
private File webappDirectory;
/**
- * Single directory for extra files to include in the WAR. This is where
- * you place your JSP files.
+ * Single directory for extra files to include in the WAR. This is where you place your JSP files.
*/
@Parameter( defaultValue = "${basedir}/src/main/webapp", required = true )
private File warSourceDirectory;
@@ -139,10 +138,9 @@
private File webXml;
/**
- * The path to a configuration file for the servlet container. Note that
- * the file name may be different for different servlet containers.
- * Apache Tomcat uses a configuration file named context.xml. The file will
- * be copied to the META-INF directory.
+ * The path to a configuration file for the servlet container. Note that the file name may be different for
+ * different servlet containers. Apache Tomcat uses a configuration file named context.xml. The file will be copied
+ * to the META-INF directory.
*/
@Parameter( property = "maven.war.containerConfigXML" )
private File containerConfigXML;
@@ -154,8 +152,8 @@
private File workDirectory;
/**
- * The file name mapping to use when copying libraries and TLDs. If no file mapping is
- * set (default) the files are copied with their standard names.
+ * The file name mapping to use when copying libraries and TLDs. If no file mapping is set (default) the files are
+ * copied with their standard names.
*
* @since 2.1-alpha-1
*/
@@ -171,8 +169,8 @@
private File cacheFile;
/**
- * Whether the cache should be used to save the status of the webapp
- * across multiple runs. Experimental feature so disabled by default.
+ * Whether the cache should be used to save the status of the webapp across multiple runs. Experimental feature so
+ * disabled by default.
*
* @since 2.1-alpha-1
*/
@@ -201,23 +199,19 @@
private MavenResourcesFiltering mavenResourcesFiltering;
/**
- * The comma separated list of tokens to include when copying the content
- * of the warSourceDirectory.
+ * The comma separated list of tokens to include when copying the content of the warSourceDirectory.
*/
@Parameter( alias = "includes", defaultValue = "**" )
private String warSourceIncludes;
/**
- * The comma separated list of tokens to exclude when copying the content
- * of the warSourceDirectory.
+ * The comma separated list of tokens to exclude when copying the content of the warSourceDirectory.
*/
@Parameter( alias = "excludes" )
private String warSourceExcludes;
/**
- * The comma separated list of tokens to include when doing
- * a WAR overlay.
- * Default is '**'
+ * The comma separated list of tokens to include when doing a WAR overlay. Default is '**'
*
* @deprecated Use <overlay>/<includes> instead
*/
@@ -225,8 +219,7 @@
private String dependentWarIncludes = "**/**";
/**
- * The comma separated list of tokens to exclude when doing
- * a WAR overlay.
+ * The comma separated list of tokens to exclude when doing a WAR overlay.
*
* @deprecated Use <overlay>/<excludes> instead
*/
@@ -234,33 +227,28 @@
private String dependentWarExcludes = "META-INF/**";
/**
- * The overlays to apply.
- *
- * Each <overlay> element may contain:
+ * The overlays to apply. Each <overlay> element may contain:
* <ul>
- * <li>id (defaults to <tt>currentBuild</tt>)</li>
- * <li>groupId (if this and artifactId are null, then the current project is treated as its own overlay)</li>
- * <li>artifactId (see above)</li>
- * <li>classifier</li>
- * <li>type</li>
- * <li>includes (a list of string patterns)</li>
- * <li>excludes (a list of string patterns)</li>
- * <li>filtered (defaults to false)</li>
- * <li>skip (defaults to false)</li>
- * <li>targetPath (defaults to root of webapp structure)</li>
- *
+ * <li>id (defaults to <tt>currentBuild</tt>)</li>
+ * <li>groupId (if this and artifactId are null, then the current project is treated as its own overlay)</li>
+ * <li>artifactId (see above)</li>
+ * <li>classifier</li>
+ * <li>type</li>
+ * <li>includes (a list of string patterns)</li>
+ * <li>excludes (a list of string patterns)</li>
+ * <li>filtered (defaults to false)</li>
+ * <li>skip (defaults to false)</li>
+ * <li>targetPath (defaults to root of webapp structure)</li>
* </ul>
*
- *
- *
* @since 2.1-alpha-1
*/
@Parameter
private List<Overlay> overlays = new ArrayList<Overlay>();
/**
- * A list of file extensions that should not be filtered.
- * <b>Will be used when filtering webResources and overlays.</b>
+ * A list of file extensions that should not be filtered. <b>Will be used when filtering webResources and
+ * overlays.</b>
*
* @since 2.1-alpha-2
*/
@@ -282,8 +270,8 @@
private boolean filteringDeploymentDescriptors = false;
/**
- * To escape interpolated values with Windows path
- * <code>c:\foo\bar</code> will be replaced with <code>c:\\foo\\bar</code>.
+ * To escape interpolated values with Windows path <code>c:\foo\bar</code> will be replaced with
+ * <code>c:\\foo\\bar</code>.
*
* @since 2.1-alpha-2
*/
@@ -291,8 +279,8 @@
private boolean escapedBackslashesInFilePath = false;
/**
- * Expression preceded with this String won't be interpolated.
- * <code>\${foo}</code> will be replaced with <code>${foo}</code>.
+ * Expression preceded with this String won't be interpolated. <code>\${foo}</code> will be replaced with
+ * <code>${foo}</code>.
*
* @since 2.1-beta-1
*/
@@ -300,15 +288,14 @@
protected String escapeString;
/**
- * Indicates if zip archives (jar,zip etc) being added to the war should be
- * compressed again. Compressing again can result in smaller archive size, but
- * gives noticeably longer execution time.
+ * Indicates if zip archives (jar,zip etc) being added to the war should be compressed again. Compressing again can
+ * result in smaller archive size, but gives noticeably longer execution time.
*
* @since 2.3
*/
@Parameter( defaultValue = "true" )
private boolean recompressZippedFiles;
-
+
/**
* @since 2.4
*/
@@ -317,22 +304,23 @@
/**
* Stop searching endToken at the end of line
+ *
* @since 2.4
*/
- @Parameter(property = "maven.war.supportMultiLineFiltering", defaultValue = "false" )
+ @Parameter( property = "maven.war.supportMultiLineFiltering", defaultValue = "false" )
private boolean supportMultiLineFiltering = false;
/**
* use jvmChmod rather that cli chmod and forking process
+ *
* @since 2.4
*/
- @Parameter(property = "maven.war.useJvmChmod", defaultValue = "true" )
+ @Parameter( property = "maven.war.useJvmChmod", defaultValue = "true" )
private boolean useJvmChmod;
-
/**
- * The archive configuration to use.
- * See <a href="http://maven.apache.org/shared/maven-archiver/index.html">Maven Archiver Reference</a>.
+ * The archive configuration to use. See <a href="http://maven.apache.org/shared/maven-archiver/index.html">Maven
+ * Archiver Reference</a>.
*/
@Parameter
private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
@@ -341,15 +329,13 @@
private final Overlay currentProjectOverlay = Overlay.createInstance();
-
public Overlay getCurrentProjectOverlay()
{
return currentProjectOverlay;
}
/**
- * Returns a string array of the excludes to be used
- * when copying the content of the WAR source directory.
+ * Returns a string array of the excludes to be used when copying the content of the WAR source directory.
*
* @return an array of tokens to exclude
*/
@@ -373,12 +359,11 @@
excludeList.add( "**/" + META_INF + "/" + containerConfigXML.getName() );
}
- return excludeList.toArray(new String[excludeList.size()]);
+ return excludeList.toArray( new String[excludeList.size()] );
}
/**
- * Returns a string array of the includes to be used
- * when assembling/copying the WAR.
+ * Returns a string array of the includes to be used when assembling/copying the WAR.
*
* @return an array of tokens to include
*/
@@ -388,8 +373,7 @@
}
/**
- * Returns a string array of the excludes to be used
- * when adding dependent WAR as an overlay onto this WAR.
+ * Returns a string array of the excludes to be used when adding dependent WAR as an overlay onto this WAR.
*
* @return an array of tokens to exclude
*/
@@ -408,8 +392,7 @@
}
/**
- * Returns a string array of the includes to be used
- * when adding dependent WARs as an overlay onto this WAR.
+ * Returns a string array of the includes to be used when adding dependent WARs as an overlay onto this WAR.
*
* @return an array of tokens to include
*/
@@ -418,14 +401,14 @@
return StringUtils.split( StringUtils.defaultString( dependentWarIncludes ), "," );
}
- public void buildExplodedWebapp( File webappDirectory )
+ public void buildExplodedWebapp( File webapplicationDirectory )
throws MojoExecutionException, MojoFailureException
{
- webappDirectory.mkdirs();
+ webapplicationDirectory.mkdirs();
try
{
- buildWebapp( project, webappDirectory );
+ buildWebapp( project, webapplicationDirectory );
}
catch ( IOException e )
{
@@ -433,40 +416,37 @@
}
}
-
/**
- * Builds the webapp for the specified project with the new packaging task
- * thingy
+ * Builds the webapp for the specified project with the new packaging task thingy
* <p/>
- * Classes, libraries and tld files are copied to
- * the <tt>webappDirectory</tt> during this phase.
+ * Classes, libraries and tld files are copied to the <tt>webappDirectory</tt> during this phase.
*
- * @param project the maven project
- * @param webappDirectory the target directory
+ * @param mavenProject the maven project
+ * @param webapplicationDirectory the target directory
* @throws MojoExecutionException if an error occurred while packaging the webapp
- * @throws MojoFailureException if an unexpected error occurred while packaging the webapp
- * @throws IOException if an error occurred while copying the files
+ * @throws MojoFailureException if an unexpected error occurred while packaging the webapp
+ * @throws IOException if an error occurred while copying the files
*/
@SuppressWarnings( "unchecked" )
- public void buildWebapp( MavenProject project, File webappDirectory )
+ public void buildWebapp( MavenProject mavenProject, File webapplicationDirectory )
throws MojoExecutionException, MojoFailureException, IOException
{
WebappStructure cache;
if ( useCache && cacheFile.exists() )
{
- cache = new WebappStructure( project.getDependencies(), webappStructureSerialier.fromXml( cacheFile ) );
+ cache = new WebappStructure( mavenProject.getDependencies(), webappStructureSerialier.fromXml( cacheFile ) );
}
else
{
- cache = new WebappStructure( project.getDependencies(), null );
+ cache = new WebappStructure( mavenProject.getDependencies(), null );
}
final long startTime = System.currentTimeMillis();
- getLog().info( "Assembling webapp [" + project.getArtifactId() + "] in [" + webappDirectory + "]" );
+ getLog().info( "Assembling webapp [" + mavenProject.getArtifactId() + "] in [" + webapplicationDirectory + "]" );
final OverlayManager overlayManager =
- new OverlayManager( overlays, project, dependentWarIncludes, dependentWarExcludes, currentProjectOverlay );
+ new OverlayManager( overlays, mavenProject, dependentWarIncludes, dependentWarExcludes, currentProjectOverlay );
final List<WarPackagingTask> packagingTasks = getPackagingTasks( overlayManager );
List<FileUtils.FilterWrapper> defaultFilterWrappers;
try
@@ -474,8 +454,9 @@
MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution();
mavenResourcesExecution.setEscapeString( escapeString );
mavenResourcesExecution.setSupportMultiLineFiltering( supportMultiLineFiltering );
- mavenResourcesExecution.setMavenProject( project );
- if (filters == null) {
+ mavenResourcesExecution.setMavenProject( mavenProject );
+ if ( filters == null )
+ {
filters = getProject().getBuild().getFilters();
}
mavenResourcesExecution.setFilters( filters );
@@ -493,12 +474,10 @@
throw new MojoExecutionException( e.getMessage(), e );
}
- final WarPackagingContext context = new DefaultWarPackagingContext( webappDirectory, cache, overlayManager,
- defaultFilterWrappers,
- getNonFilteredFileExtensions(),
- filteringDeploymentDescriptors,
- this.artifactFactory, resourceEncoding,
- useJvmChmod);
+ final WarPackagingContext context =
+ new DefaultWarPackagingContext( webapplicationDirectory, cache, overlayManager, defaultFilterWrappers,
+ getNonFilteredFileExtensions(), filteringDeploymentDescriptors,
+ this.artifactFactory, resourceEncoding, useJvmChmod );
for ( WarPackagingTask warPackagingTask : packagingTasks )
{
warPackagingTask.performPackaging( context );
@@ -515,8 +494,8 @@
}
/**
- * Returns a <tt>List</tt> of the {@link org.apache.maven.plugin.war.packaging.WarPackagingTask}
- * instances to invoke to perform the packaging.
+ * Returns a <tt>List</tt> of the {@link org.apache.maven.plugin.war.packaging.WarPackagingTask} instances to invoke
+ * to perform the packaging.
*
* @param overlayManager the overlay manager
* @return the list of packaging tasks
@@ -547,10 +526,9 @@
return packagingTasks;
}
-
/**
- * Returns a <tt>List</tt> of the {@link org.apache.maven.plugin.war.packaging.WarPostPackagingTask}
- * instances to invoke to perform the post-packaging.
+ * Returns a <tt>List</tt> of the {@link org.apache.maven.plugin.war.packaging.WarPostPackagingTask} instances to
+ * invoke to perform the post-packaging.
*
* @return the list of post packaging tasks
*/
@@ -591,9 +569,11 @@
private boolean useJvmChmod = true;
public DefaultWarPackagingContext( File webappDirectory, final WebappStructure webappStructure,
- final OverlayManager overlayManager, List<FileUtils.FilterWrapper> filterWrappers,
- List<String> nonFilteredFileExtensions, boolean filteringDeploymentDescriptors,
- ArtifactFactory artifactFactory, String resourceEncoding, boolean useJvmChmod )
+ final OverlayManager overlayManager,
+ List<FileUtils.FilterWrapper> filterWrappers,
+ List<String> nonFilteredFileExtensions,
+ boolean filteringDeploymentDescriptors, ArtifactFactory artifactFactory,
+ String resourceEncoding, boolean useJvmChmod )
{
this.webappDirectory = webappDirectory;
this.webappStructure = webappStructure;
@@ -601,8 +581,8 @@
this.filterWrappers = filterWrappers;
this.artifactFactory = artifactFactory;
this.filteringDeploymentDescriptors = filteringDeploymentDescriptors;
- this.nonFilteredFileExtensions = nonFilteredFileExtensions == null ? Collections.<String>emptyList()
- : nonFilteredFileExtensions;
+ this.nonFilteredFileExtensions =
+ nonFilteredFileExtensions == null ? Collections.<String> emptyList() : nonFilteredFileExtensions;
this.resourceEncoding = resourceEncoding;
// This is kinda stupid but if we loop over the current overlays and we request the path structure
// it will register it. This will avoid wrong warning messages in a later phase
@@ -652,7 +632,7 @@
{
return getExcludes();
}
-
+
public boolean isWebappSourceIncludeEmptyDirectories()
{
return includeEmptyDirectories;
@@ -904,7 +884,6 @@
this.warSourceExcludes = warSourceExcludes;
}
-
public boolean isUseCache()
{
return useCache;
@@ -939,7 +918,7 @@
{
this.artifactFactory = artifactFactory;
}
-
+
protected MavenSession getSession()
{
return this.session;
@@ -949,7 +928,7 @@
{
return recompressZippedFiles;
}
-
+
protected boolean isIncludeEmptyDirectories()
{
return includeEmptyDirectories;
diff --git a/src/main/java/org/apache/maven/plugin/war/Overlay.java b/src/main/java/org/apache/maven/plugin/war/Overlay.java
index 448d5e8..2946a41 100644
--- a/src/main/java/org/apache/maven/plugin/war/Overlay.java
+++ b/src/main/java/org/apache/maven/plugin/war/Overlay.java
@@ -26,16 +26,14 @@
import java.util.List;
/**
- * An overlay is a skeleton WAR added to another WAR project in order to inject a
- * functionality, resources or any other shared component.
+ * An overlay is a skeleton WAR added to another WAR project in order to inject a functionality, resources or any other
+ * shared component.
* <p/>
- * Note that a particular WAR dependency can be added multiple times as an overlay
- * with different includes/excludes filter; this allows building a fine grained
- * overwriting policy.
+ * Note that a particular WAR dependency can be added multiple times as an overlay with different includes/excludes
+ * filter; this allows building a fine grained overwriting policy.
* <p/>
- * The current project can also be described as an overlay and can not be specified
- * twice. An overlay with no groupId and no artifactId represents the
- * current project.
+ * The current project can also be described as an overlay and can not be specified twice. An overlay with no groupId
+ * and no artifactId represents the current project.
*
* @author Stephane Nicoll
* @version $Id$
@@ -43,9 +41,9 @@
public class Overlay
{
- public static final String[] DEFAULT_INCLUDES = new String[]{"**/**"};
+ public static final String[] DEFAULT_INCLUDES = new String[] { "**/**" };
- public static final String[] DEFAULT_EXCLUDES = new String[]{"META-INF/MANIFEST.MF"};
+ public static final String[] DEFAULT_EXCLUDES = new String[] { "META-INF/MANIFEST.MF" };
private String id;
@@ -64,10 +62,10 @@
private boolean skip = false;
private Artifact artifact;
-
+
private String targetPath;
-
- /** default overlay type is war */
+
+ /** default overlay type is war */
private String type = "war";
public Overlay()
@@ -75,7 +73,6 @@
super();
}
-
public Overlay( String groupId, String artifactId )
{
this();
@@ -217,7 +214,6 @@
return targetPath;
}
-
public void setTargetPath( String targetPath )
{
this.targetPath = targetPath;
@@ -228,18 +224,16 @@
return type;
}
-
public void setType( String type )
{
this.type = type;
}
-
+
public String toString()
{
return " id " + getId();
}
-
public boolean equals( Object o )
{
if ( this == o )
diff --git a/src/main/java/org/apache/maven/plugin/war/WarExplodedMojo.java b/src/main/java/org/apache/maven/plugin/war/WarExplodedMojo.java
index 79a07ef..fc5ac79 100644
--- a/src/main/java/org/apache/maven/plugin/war/WarExplodedMojo.java
+++ b/src/main/java/org/apache/maven/plugin/war/WarExplodedMojo.java
@@ -30,8 +30,7 @@
*
* @version $Id$
*/
-@Mojo( name = "exploded", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true,
- requiresDependencyResolution = ResolutionScope.RUNTIME )
+@Mojo( name = "exploded", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true, requiresDependencyResolution = ResolutionScope.RUNTIME )
public class WarExplodedMojo
extends AbstractWarMojo
{
diff --git a/src/main/java/org/apache/maven/plugin/war/WarInPlaceMojo.java b/src/main/java/org/apache/maven/plugin/war/WarInPlaceMojo.java
index c663399..cfe63ed 100644
--- a/src/main/java/org/apache/maven/plugin/war/WarInPlaceMojo.java
+++ b/src/main/java/org/apache/maven/plugin/war/WarInPlaceMojo.java
@@ -29,7 +29,7 @@
*
* @version $Id$
*/
-@Mojo( name = "inplace", requiresDependencyResolution = ResolutionScope.RUNTIME , threadSafe = true )
+@Mojo( name = "inplace", requiresDependencyResolution = ResolutionScope.RUNTIME, threadSafe = true )
public class WarInPlaceMojo
extends AbstractWarMojo
{
diff --git a/src/main/java/org/apache/maven/plugin/war/WarManifestMojo.java b/src/main/java/org/apache/maven/plugin/war/WarManifestMojo.java
index da537e4..82bfa36 100644
--- a/src/main/java/org/apache/maven/plugin/war/WarManifestMojo.java
+++ b/src/main/java/org/apache/maven/plugin/war/WarManifestMojo.java
@@ -38,14 +38,12 @@
import java.io.PrintWriter;
/**
- * Generate a manifest for this webapp. The manifest file is created in the
- * <code>warSourceDirectory</code>.
+ * Generate a manifest for this webapp. The manifest file is created in the <code>warSourceDirectory</code>.
*
* @author Mike Perham
* @version $Id$
*/
-@Mojo( name = "manifest", defaultPhase = LifecyclePhase.PROCESS_RESOURCES, threadSafe = true,
- requiresDependencyResolution = ResolutionScope.RUNTIME )
+@Mojo( name = "manifest", defaultPhase = LifecyclePhase.PROCESS_RESOURCES, threadSafe = true, requiresDependencyResolution = ResolutionScope.RUNTIME )
public class WarManifestMojo
extends AbstractWarMojo
{
@@ -55,7 +53,6 @@
@Component( role = Archiver.class, hint = "war" )
private WarArchiver warArchiver;
-
/**
* Executes this mojo on the current project.
*
diff --git a/src/main/java/org/apache/maven/plugin/war/WarMojo.java b/src/main/java/org/apache/maven/plugin/war/WarMojo.java
index 42ff750..4513765 100644
--- a/src/main/java/org/apache/maven/plugin/war/WarMojo.java
+++ b/src/main/java/org/apache/maven/plugin/war/WarMojo.java
@@ -48,8 +48,11 @@
* @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id$
*/
-@Mojo( name = "war", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = true,
- requiresDependencyResolution = ResolutionScope.RUNTIME )
+@Mojo(
+ name = "war",
+ defaultPhase = LifecyclePhase.PACKAGE,
+ threadSafe = true,
+ requiresDependencyResolution = ResolutionScope.RUNTIME )
public class WarMojo
extends AbstractWarMojo
{
@@ -66,18 +69,16 @@
private String warName;
/**
- * Classifier to add to the generated WAR. If given, the artifact will be an attachment instead.
- * The classifier will not be applied to the JAR file of the project - only to the WAR file.
+ * Classifier to add to the generated WAR. If given, the artifact will be an attachment instead. The classifier will
+ * not be applied to the JAR file of the project - only to the WAR file.
*/
@Parameter
private String classifier;
/**
- * The comma separated list of tokens to exclude from the WAR before
- * packaging. This option may be used to implement the skinny WAR use
- * case. 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).
+ * The comma separated list of tokens to exclude from the WAR before packaging. This option may be used to implement
+ * the skinny WAR use case. 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.1-alpha-2
*/
@@ -85,11 +86,9 @@
private String packagingExcludes;
/**
- * The comma separated list of tokens to include in the WAR before
- * packaging. By default everything is included. This option may be used
- * to implement the skinny WAR use case. Note that you can use the
- * Java Regular Expressions engine to include and exclude specific pattern
- * using the expression %regex[].
+ * The comma separated list of tokens to include in the WAR before packaging. By default everything is included.
+ * This option may be used to implement the skinny WAR use case. Note that you can use the Java Regular Expressions
+ * engine to include and exclude specific pattern using the expression %regex[].
*
* @since 2.1-beta-1
*/
@@ -108,16 +107,16 @@
private MavenProjectHelper projectHelper;
/**
- * Whether this is the main artifact being built. Set to <code>false</code> if you don't want to install or
- * deploy it to the local repository instead of the default one in an execution.
+ * Whether this is the main artifact being built. Set to <code>false</code> if you don't want to install or deploy
+ * it to the local repository instead of the default one in an execution.
*/
@Parameter( property = "primaryArtifact", defaultValue = "true" )
private boolean primaryArtifact = true;
/**
- * Whether or not to fail the build if the <code>web.xml</code> file is missing. Set to <code>false</code>
- * if you want you WAR built without a <code>web.xml</code> file.
- * This may be useful if you are building an overlay that has no web.xml file.
+ * Whether or not to fail the build if the <code>web.xml</code> file is missing. Set to <code>false</code> if you
+ * want you WAR built without a <code>web.xml</code> file. This may be useful if you are building an overlay that
+ * has no web.xml file.
*
* @since 2.1-alpha-2
*/
@@ -125,22 +124,25 @@
private boolean failOnMissingWebXml = true;
/**
- * Whether classes (that is the content of the WEB-INF/classes directory) should be attached to the
- * project as an additional artifact.
- * <p>By default the
- * classifier for the additional artifact is 'classes'.
- * You can change it with the
- * <code><![CDATA[<classesClassifier>someclassifier</classesClassifier>]]></code>
- * parameter.
- * </p><p>
- * If this parameter true, another project can depend on the classes
- * by writing something like:
- * <pre><![CDATA[<dependency>
+ * Whether classes (that is the content of the WEB-INF/classes directory) should be attached to the project as an
+ * additional artifact.
+ * <p>
+ * By default the classifier for the additional artifact is 'classes'. You can change it with the
+ * <code><![CDATA[<classesClassifier>someclassifier</classesClassifier>]]></code> parameter.
+ * </p>
+ * <p>
+ * If this parameter true, another project can depend on the classes by writing something like:
+ *
+ * <pre>
+ * <![CDATA[<dependency>
* <groupId>myGroup</groupId>
* <artifactId>myArtifact</artifactId>
* <version>myVersion</myVersion>
* <classifier>classes</classifier>
- * </dependency>]]></pre></p>
+ * </dependency>]]>
+ * </pre>
+ *
+ * </p>
*
* @since 2.1-alpha-2
*/
@@ -159,7 +161,6 @@
// Implementation
// ----------------------------------------------------------------------
-
/**
* Executes the WarMojo on the current project.
*
@@ -196,16 +197,15 @@
* Generates the webapp according to the <tt>mode</tt> attribute.
*
* @param warFile the target WAR file
- * @throws IOException if an error occurred while copying files
- * @throws ArchiverException if the archive could not be created
- * @throws ManifestException if the manifest could not be created
- * @throws DependencyResolutionRequiredException
- * if an error occurred while resolving the dependencies
+ * @throws IOException if an error occurred while copying files
+ * @throws ArchiverException if the archive could not be created
+ * @throws ManifestException if the manifest could not be created
+ * @throws DependencyResolutionRequiredException if an error occurred while resolving the dependencies
* @throws MojoExecutionException if the execution failed
- * @throws MojoFailureException if a fatal exception occurred
+ * @throws MojoFailureException if a fatal exception occurred
*/
private void performPackaging( File warFile )
- throws IOException, ArchiverException, ManifestException, DependencyResolutionRequiredException,
+ throws IOException, ManifestException, DependencyResolutionRequiredException,
MojoExecutionException, MojoFailureException
{
getLog().info( "Packaging webapp" );
@@ -218,10 +218,8 @@
archiver.setOutputFile( warFile );
- getLog().debug(
- "Excluding " + Arrays.asList( getPackagingExcludes() ) + " from the generated webapp archive." );
- getLog().debug(
- "Including " + Arrays.asList( getPackagingIncludes() ) + " in the generated webapp archive." );
+ getLog().debug( "Excluding " + Arrays.asList( getPackagingExcludes() ) + " from the generated webapp archive." );
+ getLog().debug( "Including " + Arrays.asList( getPackagingIncludes() ) + " in the generated webapp archive." );
warArchiver.addDirectory( getWebappDirectory(), getPackagingIncludes(), getPackagingExcludes() );
@@ -231,8 +229,8 @@
warArchiver.setWebxml( webXmlFile );
}
- warArchiver.setRecompressAddedZips( isRecompressZippedFiles() );
-
+ warArchiver.setRecompressAddedZips( isRecompressZippedFiles() );
+
warArchiver.setIncludeEmptyDirs( isIncludeEmptyDirectories() );
if ( !failOnMissingWebXml )
@@ -252,7 +250,7 @@
{
// special handling in case of archived classes: MWAR-240
File targetClassesFile = getTargetClassesFile();
- FileUtils.copyFile(getJarArchiver().getDestFile(), targetClassesFile);
+ FileUtils.copyFile( getJarArchiver().getDestFile(), targetClassesFile );
projectHelper.attachArtifact( getProject(), "jar", getClassesClassifier(), targetClassesFile );
}
else
@@ -269,10 +267,9 @@
}
}
- String classifier = this.classifier;
- if ( classifier != null )
+ if ( this.classifier != null )
{
- projectHelper.attachArtifact( getProject(), "war", classifier, warFile );
+ projectHelper.attachArtifact( getProject(), "war", this.classifier, warFile );
}
else
{
@@ -288,7 +285,6 @@
}
}
-
protected static File getTargetFile( File basedir, String finalName, String classifier, String type )
{
if ( classifier == null )
@@ -303,7 +299,6 @@
return new File( basedir, finalName + classifier + "." + type );
}
-
protected File getTargetWarFile()
{
return getTargetFile( new File( getOutputDirectory() ), getWarName(), getClassifier(), "war" );
@@ -348,7 +343,7 @@
{
if ( StringUtils.isEmpty( packagingIncludes ) )
{
- return new String[]{"**"};
+ return new String[] { "**" };
}
else
{
diff --git a/src/main/java/org/apache/maven/plugin/war/overlay/DefaultOverlay.java b/src/main/java/org/apache/maven/plugin/war/overlay/DefaultOverlay.java
index af0d6e6..4c86e94 100644
--- a/src/main/java/org/apache/maven/plugin/war/overlay/DefaultOverlay.java
+++ b/src/main/java/org/apache/maven/plugin/war/overlay/DefaultOverlay.java
@@ -26,7 +26,6 @@
* A default overlay implementation based on an {@link Artifact}.
*
* @author Stephane Nicoll
- *
* @version $Id$
*/
public class DefaultOverlay
@@ -51,7 +50,7 @@
/**
* Creates an overlay for the specified artifact.
*
- * @param a the artifact
+ * @param a the artifact
* @param includes the includes to use
* @param excludes the excludes to use
*/
diff --git a/src/main/java/org/apache/maven/plugin/war/overlay/InvalidOverlayConfigurationException.java b/src/main/java/org/apache/maven/plugin/war/overlay/InvalidOverlayConfigurationException.java
index 69bfb2e..0920d5e 100644
--- a/src/main/java/org/apache/maven/plugin/war/overlay/InvalidOverlayConfigurationException.java
+++ b/src/main/java/org/apache/maven/plugin/war/overlay/InvalidOverlayConfigurationException.java
@@ -21,13 +21,10 @@
import org.apache.maven.plugin.MojoExecutionException;
-
-
/**
* Thrown if the overlay configuration is invalid.
*
* @author Stephane Nicoll
- *
* @version $Id$
*/
public class InvalidOverlayConfigurationException
diff --git a/src/main/java/org/apache/maven/plugin/war/overlay/OverlayManager.java b/src/main/java/org/apache/maven/plugin/war/overlay/OverlayManager.java
index 067276f..e89c577 100644
--- a/src/main/java/org/apache/maven/plugin/war/overlay/OverlayManager.java
+++ b/src/main/java/org/apache/maven/plugin/war/overlay/OverlayManager.java
@@ -35,7 +35,6 @@
* Manages the overlays.
*
* @author Stephane Nicoll
- *
* @version $Id$
*/
public class OverlayManager
@@ -49,19 +48,17 @@
/**
* Creates a manager with the specified overlays.
* <p/>
- * Note that the list is potentially updated by the
- * manager so a new list is created based on the overlays.
+ * Note that the list is potentially updated by the manager so a new list is created based on the overlays.
*
- * @param overlays the overlays
- * @param project the maven project
+ * @param overlays the overlays
+ * @param project the maven project
* @param defaultIncludes the default includes to use
* @param defaultExcludes the default excludes to use
* @param currentProjectOverlay the overlay for the current project
- * @throws InvalidOverlayConfigurationException
- * if the config is invalid
+ * @throws InvalidOverlayConfigurationException if the config is invalid
*/
- public OverlayManager( List<Overlay> overlays, MavenProject project, String defaultIncludes, String defaultExcludes,
- Overlay currentProjectOverlay )
+ public OverlayManager( List<Overlay> overlays, MavenProject project, String defaultIncludes,
+ String defaultExcludes, Overlay currentProjectOverlay )
throws InvalidOverlayConfigurationException
{
this.overlays = new ArrayList<Overlay>();
@@ -78,7 +75,6 @@
}
-
/**
* Returns the resolved overlays.
*
@@ -110,9 +106,8 @@
*
* @param defaultIncludes the default includes to use
* @param defaultExcludes the default excludes to use
- * @param currentProjectOverlay the overlay for the current project
- * @throws InvalidOverlayConfigurationException
- * if the configuration is invalid
+ * @param currentProjectOverlay the overlay for the current project
+ * @throws InvalidOverlayConfigurationException if the configuration is invalid
*/
void initialize( String defaultIncludes, String defaultExcludes, Overlay currentProjectOverlay )
throws InvalidOverlayConfigurationException
@@ -176,14 +171,13 @@
/**
* Returns the Artifact associated to the specified overlay.
* <p/>
- * If the overlay defines the current project, <tt>null</tt> is
- * returned. If no artifact could not be found for the overlay
- * a InvalidOverlayConfigurationException is thrown.
+ * If the overlay defines the current project, <tt>null</tt> is returned. If no artifact could not be found for the
+ * overlay a InvalidOverlayConfigurationException is thrown.
*
* @param overlay an overlay
* @return the artifact associated to the overlay
- * @throws org.apache.maven.plugin.war.overlay.InvalidOverlayConfigurationException
- * if the overlay does not have an associated artifact
+ * @throws org.apache.maven.plugin.war.overlay.InvalidOverlayConfigurationException if the overlay does not have an
+ * associated artifact
*/
Artifact getAssociatedArtifact( final Overlay overlay )
throws InvalidOverlayConfigurationException
@@ -215,8 +209,7 @@
}
}
}
- throw new InvalidOverlayConfigurationException(
- "overlay [" + overlay + "] is not a dependency of the project." );
+ throw new InvalidOverlayConfigurationException( "overlay [" + overlay + "] is not a dependency of the project." );
}
@@ -232,13 +225,13 @@
return ( StringUtils.equals( overlay.getGroupId(), artifact.getGroupId() )
&& StringUtils.equals( overlay.getArtifactId(), artifact.getArtifactId() )
&& StringUtils.equals( overlay.getType(), artifact.getType() )
- // MWAR-241 Make sure to treat null and "" as equal when comparing the classifier
- && StringUtils.equals( StringUtils.defaultString( overlay.getClassifier() ), StringUtils.defaultString( artifact.getClassifier() ) ) );
+ // MWAR-241 Make sure to treat null and "" as equal when comparing the classifier
+ && StringUtils.equals( StringUtils.defaultString( overlay.getClassifier() ),
+ StringUtils.defaultString( artifact.getClassifier() ) ) );
}
/**
- * Returns a list of WAR {@link org.apache.maven.artifact.Artifact} describing
- * the overlays of the current project.
+ * Returns a list of WAR {@link org.apache.maven.artifact.Artifact} describing the overlays of the current project.
*
* @return the overlays as artifacts objects
*/
diff --git a/src/main/java/org/apache/maven/plugin/war/packaging/AbstractWarPackagingTask.java b/src/main/java/org/apache/maven/plugin/war/packaging/AbstractWarPackagingTask.java
index fb6ed58..2a74c8f 100644
--- a/src/main/java/org/apache/maven/plugin/war/packaging/AbstractWarPackagingTask.java
+++ b/src/main/java/org/apache/maven/plugin/war/packaging/AbstractWarPackagingTask.java
@@ -45,7 +45,7 @@
public abstract class AbstractWarPackagingTask
implements WarPackagingTask
{
- public static final String[] DEFAULT_INCLUDES = {"**/**"};
+ public static final String[] DEFAULT_INCLUDES = { "**/**" };
public static final String WEB_INF_PATH = "WEB-INF";
@@ -58,20 +58,18 @@
/**
* Copies the files if possible with an optional target prefix.
* <p/>
- * Copy uses a first-win strategy: files that have already been copied by previous
- * tasks are ignored. This method makes sure to update the list of protected files
- * which gives the list of files that have already been copied.
+ * Copy uses a first-win strategy: files that have already been copied by previous tasks are ignored. This method
+ * makes sure to update the list of protected files which gives the list of files that have already been copied.
* <p/>
- * If the structure of the source directory is not the same as the root of the
- * webapp, use the <tt>targetPrefix</tt> parameter to specify in which particular
- * directory the files should be copied. Use <tt>null</tt> to copy the files with
- * the same structure
+ * If the structure of the source directory is not the same as the root of the webapp, use the <tt>targetPrefix</tt>
+ * parameter to specify in which particular directory the files should be copied. Use <tt>null</tt> to copy the
+ * files with the same structure
*
- * @param sourceId the source id
- * @param context the context to use
- * @param sourceBaseDir the base directory from which the <tt>sourceFilesSet</tt> will be copied
+ * @param sourceId the source id
+ * @param context the context to use
+ * @param sourceBaseDir the base directory from which the <tt>sourceFilesSet</tt> will be copied
* @param sourceFilesSet the files to be copied
- * @param targetPrefix the prefix to add to the target file name
+ * @param targetPrefix the prefix to add to the target file name
* @throws IOException if an error occurred while copying the files
*/
protected void copyFiles( String sourceId, WarPackagingContext context, File sourceBaseDir, PathSet sourceFilesSet,
@@ -92,9 +90,7 @@
destinationFileName = targetPrefix + fileToCopyName;
}
-
- if ( filtered
- && !context.isNonFilteredExtension( sourceFile.getName() ) )
+ if ( filtered && !context.isNonFilteredExtension( sourceFile.getName() ) )
{
copyFilteredFile( sourceId, context, sourceFile, destinationFileName );
}
@@ -108,13 +104,12 @@
/**
* Copies the files if possible as is.
* <p/>
- * Copy uses a first-win strategy: files that have already been copied by previous
- * tasks are ignored. This method makes sure to update the list of protected files
- * which gives the list of files that have already been copied.
+ * Copy uses a first-win strategy: files that have already been copied by previous tasks are ignored. This method
+ * makes sure to update the list of protected files which gives the list of files that have already been copied.
*
- * @param sourceId the source id
- * @param context the context to use
- * @param sourceBaseDir the base directory from which the <tt>sourceFilesSet</tt> will be copied
+ * @param sourceId the source id
+ * @param context the context to use
+ * @param sourceBaseDir the base directory from which the <tt>sourceFilesSet</tt> will be copied
* @param sourceFilesSet the files to be copied
* @throws IOException if an error occurred while copying the files
*/
@@ -128,62 +123,79 @@
/**
* Copy the specified file if the target location has not yet already been used.
* <p/>
- * The <tt>targetFileName</tt> is the relative path according to the root of
- * the generated web application.
+ * The <tt>targetFileName</tt> is the relative path according to the root of the generated web application.
*
- * @param sourceId the source id
- * @param context the context to use
- * @param file the file to copy
+ * @param sourceId the source id
+ * @param context the context to use
+ * @param file the file to copy
* @param targetFilename the relative path according to the root of the webapp
* @throws IOException if an error occurred while copying
*/
- protected void copyFile( String sourceId, final WarPackagingContext context, final File file,
- String targetFilename )
+ protected void copyFile( String sourceId, final WarPackagingContext context, final File file, String targetFilename )
throws IOException
{
final File targetFile = new File( context.getWebappDirectory(), targetFilename );
-
- if( file.isFile() )
+
+ if ( file.isFile() )
{
- context.getWebappStructure().registerFile( sourceId, targetFilename, new WebappStructure.RegistrationCallback()
- {
- public void registered( String ownerId, String targetFilename )
- throws IOException
- {
- copyFile( context, file, targetFile, targetFilename, false );
- }
-
- public void alreadyRegistered( String ownerId, String targetFilename )
- throws IOException
- {
- copyFile( context, file, targetFile, targetFilename, true );
- }
-
- public void refused( String ownerId, String targetFilename, String actualOwnerId )
- throws IOException
- {
- context.getLog().debug( " - " + targetFilename + " wasn't copied because it has "
- + "already been packaged for overlay [" + actualOwnerId + "]." );
- }
-
- public void superseded( String ownerId, String targetFilename, String deprecatedOwnerId )
- throws IOException
- {
- context.getLog().info( "File [" + targetFilename + "] belonged to overlay [" + deprecatedOwnerId
- + "] so it will be overwritten." );
- copyFile( context, file, targetFile, targetFilename, false );
- }
-
- public void supersededUnknownOwner( String ownerId, String targetFilename, String unknownOwnerId )
- throws IOException
- {
- context.getLog()
- .warn( "File [" + targetFilename + "] belonged to overlay [" + unknownOwnerId
- + "] which does not exist anymore in the current project. It is recommended to invoke "
- + "clean if the dependencies of the project changed." );
- copyFile( context, file, targetFile, targetFilename, false );
- }
- } );
+ context.getWebappStructure().registerFile( sourceId, targetFilename,
+ new WebappStructure.RegistrationCallback()
+ {
+ public void registered( String ownerId, String targetFilename )
+ throws IOException
+ {
+ copyFile( context, file, targetFile, targetFilename,
+ false );
+ }
+
+ public void alreadyRegistered( String ownerId,
+ String targetFilename )
+ throws IOException
+ {
+ copyFile( context, file, targetFile, targetFilename,
+ true );
+ }
+
+ public void refused( String ownerId, String targetFilename,
+ String actualOwnerId )
+ throws IOException
+ {
+ context.getLog().debug( " - "
+ + targetFilename
+ + " wasn't copied because it has "
+ + "already been packaged for overlay ["
+ + actualOwnerId + "]." );
+ }
+
+ public void superseded( String ownerId,
+ String targetFilename,
+ String deprecatedOwnerId )
+ throws IOException
+ {
+ context.getLog().info( "File ["
+ + targetFilename
+ + "] belonged to overlay ["
+ + deprecatedOwnerId
+ + "] so it will be overwritten." );
+ copyFile( context, file, targetFile, targetFilename,
+ false );
+ }
+
+ public void supersededUnknownOwner( String ownerId,
+ String targetFilename,
+ String unknownOwnerId )
+ throws IOException
+ {
+ context.getLog().warn( "File ["
+ + targetFilename
+ + "] belonged to overlay ["
+ + unknownOwnerId
+ + "] which does not exist anymore in the current project. It is recommended to invoke "
+ + "clean if the dependencies of the project changed." );
+ copyFile( context, file, targetFile, targetFilename,
+ false );
+ }
+ } );
}
else if ( !targetFile.exists() && !targetFile.mkdirs() )
{
@@ -192,18 +204,17 @@
}
/**
- * Copy the specified file if the target location has not yet already been
- * used and filter its content with the configured filter properties.
+ * Copy the specified file if the target location has not yet already been used and filter its content with the
+ * configured filter properties.
* <p/>
- * The <tt>targetFileName</tt> is the relative path according to the root of
- * the generated web application.
+ * The <tt>targetFileName</tt> is the relative path according to the root of the generated web application.
*
- * @param sourceId the source id
- * @param context the context to use
- * @param file the file to copy
+ * @param sourceId the source id
+ * @param context the context to use
+ * @param file the file to copy
* @param targetFilename the relative path according to the root of the webapp
* @return true if the file has been copied, false otherwise
- * @throws IOException if an error occurred while copying
+ * @throws IOException if an error occurred while copying
* @throws MojoExecutionException if an error occurred while retrieving the filter properties
*/
protected boolean copyFilteredFile( String sourceId, final WarPackagingContext context, File file,
@@ -229,8 +240,8 @@
}
// fix for MWAR-36, ensures that the parent dir are created first
targetFile.getParentFile().mkdirs();
-
- context.getMavenFileFilter().copyFile( file, targetFile, true, context.getFilterWrappers(), encoding);
+
+ context.getMavenFileFilter().copyFile( file, targetFile, true, context.getFilterWrappers(), encoding );
}
catch ( MavenFilteringException e )
{
@@ -242,8 +253,8 @@
}
else
{
- context.getLog().debug(
- " - " + targetFilename + " wasn't copied because it has already been packaged (filtered)." );
+ context.getLog().debug( " - " + targetFilename
+ + " wasn't copied because it has already been packaged (filtered)." );
return false;
}
}
@@ -251,8 +262,8 @@
/**
* Unpacks the specified file to the specified directory.
*
- * @param context the packaging context
- * @param file the file to unpack
+ * @param context the packaging context
+ * @param file the file to unpack
* @param unpackDirectory the directory to use for th unpacked file
* @throws MojoExecutionException if an error occurred while unpacking the file
*/
@@ -278,25 +289,25 @@
catch ( NoSuchArchiverException e )
{
context.getLog().warn( "Skip unpacking dependency file [" + file.getAbsolutePath()
- + " with unknown extension [" + archiveExt + "]" );
+ + " with unknown extension [" + archiveExt + "]" );
}
}
/**
- * Copy file from source to destination. The directories up to <code>destination</code>
- * will be created if they don't already exist. if the <code>onlyIfModified</code> flag
- * is <tt>false</tt>, <code>destination</code> will be overwritten if it already exists. If the
- * flag is <tt>true</tt> destination will be overwritten if it's not up to date.
+ * Copy file from source to destination. The directories up to <code>destination</code> will be created if they
+ * don't already exist. if the <code>onlyIfModified</code> flag is <tt>false</tt>, <code>destination</code> will be
+ * overwritten if it already exists. If the flag is <tt>true</tt> destination will be overwritten if it's not up to
+ * date.
* <p/>
*
- * @param context the packaging context
- * @param source an existing non-directory <code>File</code> to copy bytes from
- * @param destination a non-directory <code>File</code> to write bytes to (possibly overwriting).
+ * @param context the packaging context
+ * @param source an existing non-directory <code>File</code> to copy bytes from
+ * @param destination a non-directory <code>File</code> to write bytes to (possibly overwriting).
* @param targetFilename the relative path of the file from the webapp root directory
* @param onlyIfModified if true, copy the file only if the source has changed, always copy otherwise
* @return true if the file has been copied/updated, false otherwise
- * @throws IOException if <code>source</code> does not exist, <code>destination</code> cannot
- * be written to, or an IO error occurs during copying
+ * @throws IOException if <code>source</code> does not exist, <code>destination</code> cannot be written to, or an
+ * IO error occurs during copying
*/
protected boolean copyFile( WarPackagingContext context, File source, File destination, String targetFilename,
boolean onlyIfModified )
@@ -360,12 +371,11 @@
IOUtil.close( xmlReader );
}
}
-
+
/**
- * Returns the file to copy. If the includes are <tt>null</tt> or empty, the
- * default includes are used.
+ * Returns the file to copy. If the includes are <tt>null</tt> or empty, the default includes are used.
*
- * @param baseDir the base directory to start from
+ * @param baseDir the base directory to start from
* @param includes the includes
* @param excludes the excludes
* @return the files to copy
@@ -376,10 +386,9 @@
}
/**
- * Returns the file to copy. If the includes are <tt>null</tt> or empty, the
- * default includes are used.
+ * Returns the file to copy. If the includes are <tt>null</tt> or empty, the default includes are used.
*
- * @param baseDir the base directory to start from
+ * @param baseDir the base directory to start from
* @param includes the includes
* @param excludes the excludes
* @return the files to copy
@@ -407,22 +416,21 @@
scanner.scan();
PathSet pathSet = new PathSet( scanner.getIncludedFiles() );
-
+
if ( includeDirectories )
{
pathSet.addAll( scanner.getIncludedDirectories() );
}
-
+
return pathSet;
}
/**
* Returns the final name of the specified artifact.
* <p/>
- * If the <tt>outputFileNameMapping</tt> is set, it is used, otherwise
- * the standard naming scheme is used.
+ * If the <tt>outputFileNameMapping</tt> is set, it is used, otherwise the standard naming scheme is used.
*
- * @param context the packaging context
+ * @param context the packaging context
* @param artifact the artifact
* @return the converted filename of the artifact
*/
@@ -437,8 +445,7 @@
String classifier = artifact.getClassifier();
if ( ( classifier != null ) && !( "".equals( classifier.trim() ) ) )
{
- return MappingUtils.evaluateFileNameMapping( MappingUtils.DEFAULT_FILE_NAME_MAPPING_CLASSIFIER,
- artifact );
+ return MappingUtils.evaluateFileNameMapping( MappingUtils.DEFAULT_FILE_NAME_MAPPING_CLASSIFIER, artifact );
}
else
{
@@ -448,9 +455,8 @@
}
/**
- * Returns <code>true</code> if the <code>File</code>-object is a file (not
- * a directory) that is not <code>null</code> and has a file name that ends
- * in ".xml".
+ * Returns <code>true</code> if the <code>File</code>-object is a file (not a directory) that is not
+ * <code>null</code> and has a file name that ends in ".xml".
*
* @param file The file to check
* @return <code>true</code> if the file is an xml-file, otherwise <code>false</code>
diff --git a/src/main/java/org/apache/maven/plugin/war/packaging/ArtifactsPackagingTask.java b/src/main/java/org/apache/maven/plugin/war/packaging/ArtifactsPackagingTask.java
index 6732f3e..904d32e 100644
--- a/src/main/java/org/apache/maven/plugin/war/packaging/ArtifactsPackagingTask.java
+++ b/src/main/java/org/apache/maven/plugin/war/packaging/ArtifactsPackagingTask.java
@@ -34,7 +34,6 @@
* Handles the artifacts that needs to be packaged in the web application.
*
* @author Stephane Nicoll
- *
* @version $Id$
*/
public class ArtifactsPackagingTask
@@ -53,90 +52,90 @@
private final String id;
-
public ArtifactsPackagingTask( Set<Artifact> artifacts, Overlay currentProjectOverlay )
{
this.artifacts = artifacts;
this.id = currentProjectOverlay.getId();
}
-
public void performPackaging( WarPackagingContext context )
throws MojoExecutionException
{
try
{
- final ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME );
- final List<String> duplicates = findDuplicates( context, artifacts );
+ final ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME );
+ final List<String> duplicates = findDuplicates( context, artifacts );
- for ( Artifact artifact : artifacts )
- {
- String targetFileName = getArtifactFinalName( context, artifact );
-
- context.getLog().debug( "Processing: " + targetFileName );
-
- if ( duplicates.contains( targetFileName ) )
+ for ( Artifact artifact : artifacts )
{
- context.getLog().debug( "Duplicate found: " + targetFileName );
- targetFileName = artifact.getGroupId() + "-" + targetFileName;
- context.getLog().debug( "Renamed to: " + targetFileName );
- }
- context.getWebappStructure().registerTargetFileName( artifact, targetFileName );
+ String targetFileName = getArtifactFinalName( context, artifact );
- if ( !artifact.isOptional() && filter.include( artifact ) )
- {
- try
+ context.getLog().debug( "Processing: " + targetFileName );
+
+ if ( duplicates.contains( targetFileName ) )
{
- String type = artifact.getType();
- if ( "tld".equals( type ) )
+ context.getLog().debug( "Duplicate found: " + targetFileName );
+ targetFileName = artifact.getGroupId() + "-" + targetFileName;
+ context.getLog().debug( "Renamed to: " + targetFileName );
+ }
+ context.getWebappStructure().registerTargetFileName( artifact, targetFileName );
+
+ if ( !artifact.isOptional() && filter.include( artifact ) )
+ {
+ try
{
- copyFile( id, context, artifact.getFile(), TLD_PATH + targetFileName );
+ String type = artifact.getType();
+ if ( "tld".equals( type ) )
+ {
+ copyFile( id, context, artifact.getFile(), TLD_PATH + targetFileName );
+ }
+ else if ( "aar".equals( type ) )
+ {
+ copyFile( id, context, artifact.getFile(), SERVICES_PATH + targetFileName );
+ }
+ else if ( "mar".equals( type ) )
+ {
+ copyFile( id, context, artifact.getFile(), MODULES_PATH + targetFileName );
+ }
+ else if ( "xar".equals( type ) )
+ {
+ copyFile( id, context, artifact.getFile(), EXTENSIONS_PATH + targetFileName );
+ }
+ else if ( "jar".equals( type ) || "ejb".equals( type ) || "ejb-client".equals( type )
+ || "test-jar".equals( type ) || "bundle".equals( type ) )
+ {
+ copyFile( id, context, artifact.getFile(), LIB_PATH + targetFileName );
+ }
+ else if ( "par".equals( type ) )
+ {
+ targetFileName = targetFileName.substring( 0, targetFileName.lastIndexOf( '.' ) ) + ".jar";
+ copyFile( id, context, artifact.getFile(), LIB_PATH + targetFileName );
+ }
+ else if ( "war".equals( type ) )
+ {
+ // Nothing to do here, it is an overlay and it's already handled
+ context.getLog().debug( "war artifacts are handled as overlays, ignoring [" + artifact
+ + "]" );
+ }
+ else if ( "zip".equals( type ) )
+ {
+ // Nothing to do here, it is an overlay and it's already handled
+ context.getLog().debug( "zip artifacts are handled as overlays, ignoring [" + artifact
+ + "]" );
+ }
+ else
+ {
+ context.getLog().debug( "Artifact of type [" + type + "] is not supported, ignoring ["
+ + artifact + "]" );
+ }
}
- else if ( "aar".equals( type ) )
+ catch ( IOException e )
{
- copyFile( id, context, artifact.getFile(), SERVICES_PATH + targetFileName );
- }
- else if ( "mar".equals( type ) )
- {
- copyFile( id, context, artifact.getFile(), MODULES_PATH + targetFileName );
- }
- else if ( "xar".equals( type ) )
- {
- copyFile( id, context, artifact.getFile(), EXTENSIONS_PATH + targetFileName );
- }
- else if ( "jar".equals( type ) || "ejb".equals( type ) || "ejb-client".equals( type )
- || "test-jar".equals( type ) || "bundle".equals( type ) )
- {
- copyFile( id, context, artifact.getFile(), LIB_PATH + targetFileName );
- }
- else if ( "par".equals( type ) )
- {
- targetFileName = targetFileName.substring( 0, targetFileName.lastIndexOf( '.' ) ) + ".jar";
- copyFile( id, context, artifact.getFile(), LIB_PATH + targetFileName );
- }
- else if ( "war".equals( type ) )
- {
- // Nothing to do here, it is an overlay and it's already handled
- context.getLog().debug( "war artifacts are handled as overlays, ignoring [" + artifact + "]" );
- }
- else if ( "zip".equals( type ) )
- {
- // Nothing to do here, it is an overlay and it's already handled
- context.getLog().debug( "zip artifacts are handled as overlays, ignoring [" + artifact + "]" );
- }
- else
- {
- context.getLog().debug(
- "Artifact of type [" + type + "] is not supported, ignoring [" + artifact + "]" );
+ throw new MojoExecutionException( "Failed to copy file for artifact [" + artifact + "]", e );
}
}
- catch ( IOException e )
- {
- throw new MojoExecutionException( "Failed to copy file for artifact [" + artifact + "]", e );
- }
}
}
- }
catch ( InterpolationException e )
{
throw new MojoExecutionException( e.getMessage(), e );
@@ -144,10 +143,9 @@
}
/**
- * Searches a set of artifacts for duplicate filenames and returns a list
- * of duplicates.
+ * Searches a set of artifacts for duplicate filenames and returns a list of duplicates.
*
- * @param context the packaging context
+ * @param context the packaging context
* @param artifacts set of artifacts
* @return List of duplicated artifacts as bundling file names
*/
diff --git a/src/main/java/org/apache/maven/plugin/war/packaging/ClassesPackagingTask.java b/src/main/java/org/apache/maven/plugin/war/packaging/ClassesPackagingTask.java
index 0e014da..b29996a 100644
--- a/src/main/java/org/apache/maven/plugin/war/packaging/ClassesPackagingTask.java
+++ b/src/main/java/org/apache/maven/plugin/war/packaging/ClassesPackagingTask.java
@@ -34,12 +34,10 @@
/**
* Handles the classes directory that needs to be packaged in the web application.
* <p/>
- * Based on the {@link WarPackagingContext#archiveClasses()} flag the resources
- * either copied into to <tt>WEB-INF/classes</tt> directory or archived in a jar
- * within the <tt>WEB-INF/lib</tt> directory.
+ * Based on the {@link WarPackagingContext#archiveClasses()} flag the resources either copied into to
+ * <tt>WEB-INF/classes</tt> directory or archived in a jar within the <tt>WEB-INF/lib</tt> directory.
*
* @author Stephane Nicoll
- *
* @version $Id$
*/
public class ClassesPackagingTask
@@ -72,13 +70,13 @@
final PathSet sources = getFilesToIncludes( context.getClassesDirectory(), null, null );
try
{
- copyFiles( currentProjectOverlay.getId(), context, context.getClassesDirectory(),
- sources, CLASSES_PATH, false );
+ copyFiles( currentProjectOverlay.getId(), context, context.getClassesDirectory(), sources,
+ CLASSES_PATH, false );
}
catch ( IOException e )
{
- throw new MojoExecutionException(
- "Could not copy webapp classes [" + context.getClassesDirectory().getAbsolutePath() + "]", e );
+ throw new MojoExecutionException( "Could not copy webapp classes ["
+ + context.getClassesDirectory().getAbsolutePath() + "]", e );
}
}
}
@@ -89,8 +87,8 @@
{
MavenProject project = context.getProject();
ArtifactFactory factory = context.getArtifactFactory();
- Artifact artifact = factory.createBuildArtifact( project.getGroupId(), project.getArtifactId(),
- project.getVersion(), "jar" );
+ Artifact artifact =
+ factory.createBuildArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(), "jar" );
String archiveName;
try
{
@@ -98,9 +96,8 @@
}
catch ( InterpolationException e )
{
- throw new MojoExecutionException(
- "Could not get the final name of the artifact [" + artifact.getGroupId() + ":" + artifact.getArtifactId()
- + ":" + artifact.getVersion() + "]", e );
+ throw new MojoExecutionException( "Could not get the final name of the artifact [" + artifact.getGroupId()
+ + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() + "]", e );
}
final String targetFilename = LIB_PATH + archiveName;
@@ -114,8 +111,8 @@
}
else
{
- context.getLog().warn(
- "Could not generate archive classes file [" + targetFilename + "] has already been copied." );
+ context.getLog().warn( "Could not generate archive classes file [" + targetFilename
+ + "] has already been copied." );
}
}
}
diff --git a/src/main/java/org/apache/maven/plugin/war/packaging/DependenciesAnalysisPackagingTask.java b/src/main/java/org/apache/maven/plugin/war/packaging/DependenciesAnalysisPackagingTask.java
index fe74788..e950566 100644
--- a/src/main/java/org/apache/maven/plugin/war/packaging/DependenciesAnalysisPackagingTask.java
+++ b/src/main/java/org/apache/maven/plugin/war/packaging/DependenciesAnalysisPackagingTask.java
@@ -28,11 +28,9 @@
import java.io.File;
/**
- * Analyzes the dependencies of the project with its previous state and update
- * the target directory accordingly.
+ * Analyzes the dependencies of the project with its previous state and update the target directory accordingly.
*
* @author Stephane Nicoll
- *
* @version $Id$
*/
public class DependenciesAnalysisPackagingTask
@@ -55,7 +53,8 @@
{
context.getLog().debug( notBundledMessage );
}
- else {
+ else
+ {
handleDependencyScope( context, dependency, warOrZipMessage, standardMessage, removeFile );
}
}
@@ -139,7 +138,6 @@
}
}
-
class DependenciesAnalysisCallbackImpl
implements WebappStructure.DependenciesAnalysisCallback
{
@@ -172,23 +170,20 @@
public void updatedVersion( Dependency dependency, String previousVersion )
{
handleDependency( context, dependency, "Version of dependency [" + dependency + "] has changed ("
- + previousVersion + " -> " + dependency.getVersion() + ") but it was not bundled anyway.",
- "Version of dependency [" + dependency + "] has changed ("
- + previousVersion + " -> " + dependency.getVersion()
- + "). If it was included in the build as an overlay, "
- + "consider "
- + "cleaning the target directory of the project (mvn clean)",
- "Version of dependency [" + dependency + "] has changed ("
- + previousVersion + " -> " + dependency.getVersion() + ").",
- true );
+ + previousVersion + " -> " + dependency.getVersion()
+ + ") but it was not bundled anyway.",
+ "Version of dependency [" + dependency + "] has changed (" + previousVersion + " -> "
+ + dependency.getVersion() + "). If it was included in the build as an overlay, "
+ + "consider " + "cleaning the target directory of the project (mvn clean)",
+ "Version of dependency [" + dependency + "] has changed (" + previousVersion + " -> "
+ + dependency.getVersion() + ").", true );
}
public void updatedScope( Dependency dependency, String previousScope )
{
- if ( Artifact.SCOPE_PROVIDED.equals( dependency.getScope() ) || Artifact.SCOPE_TEST.equals(
- dependency.getScope() )
- && ( !Artifact.SCOPE_PROVIDED.equals( previousScope )
- && !Artifact.SCOPE_TEST.equals( previousScope ) ) )
+ if ( Artifact.SCOPE_PROVIDED.equals( dependency.getScope() )
+ || Artifact.SCOPE_TEST.equals( dependency.getScope() )
+ && ( !Artifact.SCOPE_PROVIDED.equals( previousScope ) && !Artifact.SCOPE_TEST.equals( previousScope ) ) )
{
// It's now provided or test so it should be removed
handleDependencyScope( context, dependency, "Scope of dependency [" + dependency + "] has changed ("
@@ -200,19 +195,16 @@
}
-
public void updatedOptionalFlag( Dependency dependency, boolean previousOptional )
{
if ( !previousOptional && dependency.isOptional() )
{
// It wasn't optional but now it is anymore
- handleDependency( context, dependency,
- "Dependency [" + dependency + "] is now optional but it was not bundled anyway.",
- "Dependency [" + dependency
- + "] is now optional. If it was included in the build as an overlay, "
- + "consider cleaning the target directory of the project (mvn clean)",
- "Dependency [" + dependency + "] is now optional", true );
-
+ handleDependency( context, dependency, "Dependency [" + dependency
+ + "] is now optional but it was not bundled anyway.", "Dependency [" + dependency
+ + "] is now optional. If it was included in the build as an overlay, "
+ + "consider cleaning the target directory of the project (mvn clean)", "Dependency [" + dependency
+ + "] is now optional", true );
}
}
diff --git a/src/main/java/org/apache/maven/plugin/war/packaging/OverlayPackagingTask.java b/src/main/java/org/apache/maven/plugin/war/packaging/OverlayPackagingTask.java
index 56f01e4..f2e14d6 100644
--- a/src/main/java/org/apache/maven/plugin/war/packaging/OverlayPackagingTask.java
+++ b/src/main/java/org/apache/maven/plugin/war/packaging/OverlayPackagingTask.java
@@ -31,7 +31,6 @@
* Handles an overlay.
*
* @author Stephane Nicoll
- *
* @version $Id$
*/
public class OverlayPackagingTask
@@ -39,7 +38,6 @@
{
private final Overlay overlay;
-
public OverlayPackagingTask( Overlay overlay, Overlay currentProjectOverlay )
{
if ( overlay == null )
@@ -53,12 +51,11 @@
this.overlay = overlay;
}
-
public void performPackaging( WarPackagingContext context )
throws MojoExecutionException
{
- context.getLog().debug(
- "OverlayPackagingTask performPackaging overlay.getTargetPath() " + overlay.getTargetPath() );
+ context.getLog().debug( "OverlayPackagingTask performPackaging overlay.getTargetPath() "
+ + overlay.getTargetPath() );
if ( overlay.shouldSkip() )
{
context.getLog().info( "Skipping overlay [" + overlay + "]" );
@@ -102,8 +99,7 @@
/**
* Unpacks the specified overlay.
* <p/>
- * Makes sure to skip the unpack process if the overlay has
- * already been unpacked.
+ * Makes sure to skip the unpack process if the overlay has already been unpacked.
*
* @param context the packaging context
* @param overlay the overlay
diff --git a/src/main/java/org/apache/maven/plugin/war/packaging/SaveWebappStructurePostPackagingTask.java b/src/main/java/org/apache/maven/plugin/war/packaging/SaveWebappStructurePostPackagingTask.java
index 140a13f..4bd6273 100644
--- a/src/main/java/org/apache/maven/plugin/war/packaging/SaveWebappStructurePostPackagingTask.java
+++ b/src/main/java/org/apache/maven/plugin/war/packaging/SaveWebappStructurePostPackagingTask.java
@@ -30,7 +30,6 @@
* Saves the webapp structure cache.
*
* @author Stephane Nicoll
- *
* @version $Id$
*/
public class SaveWebappStructurePostPackagingTask
@@ -41,7 +40,6 @@
private final WebappStructureSerializer serialier;
-
public SaveWebappStructurePostPackagingTask( File targetFile )
{
this.targetFile = targetFile;
diff --git a/src/main/java/org/apache/maven/plugin/war/packaging/WarPackagingContext.java b/src/main/java/org/apache/maven/plugin/war/packaging/WarPackagingContext.java
index 196bb92..c4ac44c 100644
--- a/src/main/java/org/apache/maven/plugin/war/packaging/WarPackagingContext.java
+++ b/src/main/java/org/apache/maven/plugin/war/packaging/WarPackagingContext.java
@@ -49,8 +49,7 @@
MavenProject getProject();
/**
- * Returns the webapp directory. Packaging tasks should use this
- * directory to generate the webapp.
+ * Returns the webapp directory. Packaging tasks should use this directory to generate the webapp.
*
* @return the webapp directory
*/
@@ -92,8 +91,7 @@
File getClassesDirectory();
/**
- * Specify whether the classes resources should be archived in
- * the <tt>WEB-INF/lib</tt> of the generated web app.
+ * Specify whether the classes resources should be archived in the <tt>WEB-INF/lib</tt> of the generated web app.
*
* @return true if the classes should be archived, false otherwise
*/
@@ -128,16 +126,14 @@
MavenArchiveConfiguration getArchive();
/**
- * Returns the Jar archiver needed for archiving classes directory into
- * jar file under WEB-INF/lib.
+ * Returns the Jar archiver needed for archiving classes directory into jar file under WEB-INF/lib.
*
* @return the jar archiver to user
*/
JarArchiver getJarArchiver();
/**
- * Returns the output file name mapping to use, if any. Returns <tt>null</tt>
- * if no file name mapping is set.
+ * Returns the output file name mapping to use, if any. Returns <tt>null</tt> if no file name mapping is set.
*
* @return the output file name mapping or <tt>null</tt>
*/
@@ -158,15 +154,14 @@
WebappStructure getWebappStructure();
/**
- * Returns the list of registered overlays for this session. This list might
- * differ from the one returned by the cache; in this case, it means that the
- * project's configuration has changed. The plugin will handle those cases nicely
- * but it would be better in general to invoke the clean goal.
+ * Returns the list of registered overlays for this session. This list might differ from the one returned by the
+ * cache; in this case, it means that the project's configuration has changed. The plugin will handle those cases
+ * nicely but it would be better in general to invoke the clean goal.
*
* @return the list of registered overlays, including the current project
*/
List<String> getOwnerIds();
-
+
/**
* Returns the {@link MavenFileFilter} instance to use.
*
@@ -174,25 +169,24 @@
* @since 2.1-alpha-2
*/
MavenFileFilter getMavenFileFilter();
-
+
/**
* @return {@link List} of {@link FilterWrapper}
* @since 2.1-alpha-2
*/
List<FilterWrapper> getFilterWrappers();
-
+
/**
- * Specify if the given <tt>fileName</tt> belongs to the list of extensions
- * that must not be filtered
+ * Specify if the given <tt>fileName</tt> belongs to the list of extensions that must not be filtered
*
* @param fileName the name of file
* @return <tt>true</tt> if it should not be filtered, <tt>false</tt> otherwise
* @since 2.1-alpha-2
*/
boolean isNonFilteredExtension( String fileName );
-
+
boolean isFilteringDeploymentDescriptors();
-
+
ArtifactFactory getArtifactFactory();
/**
@@ -212,7 +206,6 @@
String getResourceEncoding();
/**
- *
* @return to use jvmChmod rather than forking chmod cli
* @since 2.4
*/
diff --git a/src/main/java/org/apache/maven/plugin/war/packaging/WarPackagingTask.java b/src/main/java/org/apache/maven/plugin/war/packaging/WarPackagingTask.java
index b049b77..6e766c4 100644
--- a/src/main/java/org/apache/maven/plugin/war/packaging/WarPackagingTask.java
+++ b/src/main/java/org/apache/maven/plugin/war/packaging/WarPackagingTask.java
@@ -34,15 +34,13 @@
/**
* Performs the packaging for the specified task.
* <p/>
- * The task is responsible to update the packaging context, namely
- * with the files that have been copied.
+ * The task is responsible to update the packaging context, namely with the files that have been copied.
*
* @param context the packaging context
* @throws MojoExecutionException if an error occurred
- * @throws MojoFailureException if the project configuration is invalid
+ * @throws MojoFailureException if the project configuration is invalid
*/
void performPackaging( WarPackagingContext context )
throws MojoExecutionException, MojoFailureException;
-
}
diff --git a/src/main/java/org/apache/maven/plugin/war/packaging/WarPostPackagingTask.java b/src/main/java/org/apache/maven/plugin/war/packaging/WarPostPackagingTask.java
index 59283a2..276d7bd 100644
--- a/src/main/java/org/apache/maven/plugin/war/packaging/WarPostPackagingTask.java
+++ b/src/main/java/org/apache/maven/plugin/war/packaging/WarPostPackagingTask.java
@@ -34,12 +34,11 @@
/**
* Executes the post packaging task.
* <p/>
- * The packaging context hold all information regarding the webapp that
- * has been packaged.
+ * The packaging context hold all information regarding the webapp that has been packaged.
*
* @param context the packaging context
* @throws MojoExecutionException if an error occurred
- * @throws MojoFailureException if a failure occurred
+ * @throws MojoFailureException if a failure occurred
*/
void performPostPackaging( WarPackagingContext context )
throws MojoExecutionException, MojoFailureException;
diff --git a/src/main/java/org/apache/maven/plugin/war/packaging/WarProjectPackagingTask.java b/src/main/java/org/apache/maven/plugin/war/packaging/WarProjectPackagingTask.java
index 5e179fa..e7c6a4b 100644
--- a/src/main/java/org/apache/maven/plugin/war/packaging/WarProjectPackagingTask.java
+++ b/src/main/java/org/apache/maven/plugin/war/packaging/WarProjectPackagingTask.java
@@ -32,14 +32,9 @@
import org.codehaus.plexus.util.StringUtils;
/**
- * Handles the project own resources, that is:
- * <ul
- * <li>The list of web resources, if any</li>
- * <li>The content of the webapp directory if it exists</li>
- * <li>The custom deployment descriptor(s), if any</li>
- * <li>The content of the classes directory if it exists</li>
- * <li>The dependencies of the project</li>
- * </ul>
+ * Handles the project own resources, that is: <ul <li>The list of web resources, if any</li> <li>The content of the
+ * webapp directory if it exists</li> <li>The custom deployment descriptor(s), if any</li> <li>The content of the
+ * classes directory if it exists</li> <li>The dependencies of the project</li> </ul>
*
* @author Stephane Nicoll
* @version $Id$
@@ -57,7 +52,6 @@
private Overlay currentProjectOverlay;
-
public WarProjectPackagingTask( Resource[] webResources, File webXml, File containerConfigXml,
Overlay currentProjectOverlay )
{
@@ -106,7 +100,6 @@
handleArtifacts( context );
}
-
/**
* Handles the web resources.
*
@@ -159,8 +152,7 @@
{
context.getLog().debug( "webapp sources directory does not exist - skipping." );
}
- else if ( !context.getWebappSourceDirectory().getAbsolutePath().equals(
- context.getWebappDirectory().getPath() ) )
+ else if ( !context.getWebappSourceDirectory().getAbsolutePath().equals( context.getWebappDirectory().getPath() ) )
{
context.getLog().info( "Copying webapp resources [" + context.getWebappSourceDirectory() + "]" );
final PathSet sources =
@@ -173,8 +165,8 @@
}
catch ( IOException e )
{
- throw new MojoExecutionException(
- "Could not copy webapp sources [" + context.getWebappDirectory().getAbsolutePath() + "]", e );
+ throw new MojoExecutionException( "Could not copy webapp sources ["
+ + context.getWebappDirectory().getAbsolutePath() + "]", e );
}
}
}
@@ -189,8 +181,8 @@
throws MojoExecutionException
{
@SuppressWarnings( "unchecked" )
- ArtifactsPackagingTask task = new ArtifactsPackagingTask( context.getProject().getArtifacts(),
- currentProjectOverlay );
+ ArtifactsPackagingTask task =
+ new ArtifactsPackagingTask( context.getProject().getArtifacts(), currentProjectOverlay );
task.performPackaging( context );
}
@@ -208,14 +200,13 @@
}
/**
- * Handles the deployment descriptors, if specified. Note that the behavior
- * here is slightly different since the customized entry always win, even if
- * an overlay has already packaged a web.xml previously.
+ * Handles the deployment descriptors, if specified. Note that the behavior here is slightly different since the
+ * customized entry always win, even if an overlay has already packaged a web.xml previously.
*
- * @param context the packaging context
- * @param webinfDir the web-inf directory
+ * @param context the packaging context
+ * @param webinfDir the web-inf directory
* @param metainfDir the meta-inf directory
- * @throws MojoFailureException if the web.xml is specified but does not exist
+ * @throws MojoFailureException if the web.xml is specified but does not exist
* @throws MojoExecutionException if an error occurred while copying the descriptors
*/
protected void handleDeploymentDescriptors( WarPackagingContext context, File webinfDir, File metainfDir )
@@ -270,8 +261,8 @@
}
else
{
- copyFile( context, containerConfigXML, new File( metainfDir, xmlFileName ),
- "META-INF/" + xmlFileName, true );
+ copyFile( context, containerConfigXML, new File( metainfDir, xmlFileName ), "META-INF/"
+ + xmlFileName, true );
}
}
}
@@ -288,9 +279,9 @@
/**
* Copies webapp webResources from the specified directory.
*
- * @param context the WAR packaging context to use
+ * @param context the WAR packaging context to use
* @param resource the resource to copy
- * @throws IOException if an error occurred while copying the resources
+ * @throws IOException if an error occurred while copying the resources
* @throws MojoExecutionException if an error occurred while retrieving the filter properties
*/
public void copyResources( WarPackagingContext context, Resource resource )
@@ -298,38 +289,42 @@
{
if ( !context.getWebappDirectory().exists() )
{
- context.getLog().warn(
- "Not copying webapp webResources [" + resource.getDirectory() + "]: webapp directory ["
- + context.getWebappDirectory().getAbsolutePath() + "] does not exist!" );
+ context.getLog().warn( "Not copying webapp webResources [" + resource.getDirectory()
+ + "]: webapp directory [" + context.getWebappDirectory().getAbsolutePath()
+ + "] does not exist!" );
}
context.getLog().info( "Copying webapp webResources [" + resource.getDirectory() + "] to ["
- + context.getWebappDirectory().getAbsolutePath() + "]" );
+ + context.getWebappDirectory().getAbsolutePath() + "]" );
String[] fileNames = getFilesToCopy( resource );
- for (String fileName : fileNames) {
+ for ( String fileName : fileNames )
+ {
String targetFileName = fileName;
- if (resource.getTargetPath() != null) {
- //TODO make sure this thing is 100% safe
+ if ( resource.getTargetPath() != null )
+ {
+ // TODO make sure this thing is 100% safe
// MWAR-129 if targetPath is only a dot <targetPath>.</targetPath> or ./
// and the Resource is in a part of the warSourceDirectory the file from sources will override this
// that's we don't have to add the targetPath yep not nice but works
- if (!StringUtils.equals(".", resource.getTargetPath())
- && !StringUtils.equals("./", resource.getTargetPath())) {
+ if ( !StringUtils.equals( ".", resource.getTargetPath() )
+ && !StringUtils.equals( "./", resource.getTargetPath() ) )
+ {
targetFileName = resource.getTargetPath() + File.separator + targetFileName;
}
}
- if (resource.isFiltering() && !context.isNonFilteredExtension(fileName)) {
- copyFilteredFile(id, context, new File(resource.getDirectory(), fileName), targetFileName);
- } else {
- copyFile(id, context, new File(resource.getDirectory(), fileName), targetFileName);
+ if ( resource.isFiltering() && !context.isNonFilteredExtension( fileName ) )
+ {
+ copyFilteredFile( id, context, new File( resource.getDirectory(), fileName ), targetFileName );
+ }
+ else
+ {
+ copyFile( id, context, new File( resource.getDirectory(), fileName ), targetFileName );
}
}
}
-
/**
- * Returns a list of filenames that should be copied
- * over to the destination directory.
+ * Returns a list of filenames that should be copied over to the destination directory.
*
* @param resource the resource to be scanned
* @return the array of filenames, relative to the sourceDir
@@ -340,8 +335,7 @@
scanner.setBasedir( resource.getDirectory() );
if ( resource.getIncludes() != null && !resource.getIncludes().isEmpty() )
{
- scanner.setIncludes(
- (String[]) resource.getIncludes().toArray( new String[resource.getIncludes().size()] ) );
+ scanner.setIncludes( (String[]) resource.getIncludes().toArray( new String[resource.getIncludes().size()] ) );
}
else
{
@@ -349,8 +343,7 @@
}
if ( resource.getExcludes() != null && !resource.getExcludes().isEmpty() )
{
- scanner.setExcludes(
- (String[]) resource.getExcludes().toArray( new String[resource.getExcludes().size()] ) );
+ scanner.setExcludes( (String[]) resource.getExcludes().toArray( new String[resource.getExcludes().size()] ) );
}
scanner.addDefaultExcludes();
diff --git a/src/main/java/org/apache/maven/plugin/war/util/ClassesPackager.java b/src/main/java/org/apache/maven/plugin/war/util/ClassesPackager.java
index 15399ea..bd526c0 100644
--- a/src/main/java/org/apache/maven/plugin/war/util/ClassesPackager.java
+++ b/src/main/java/org/apache/maven/plugin/war/util/ClassesPackager.java
@@ -53,11 +53,11 @@
/**
* Package the classes
*
- * @param classesDirectory the classes directory
- * @param targetFile the target file
- * @param jarArchiver the jar archiver to use
- * @param session the current session
- * @param project the related project
+ * @param classesDirectory the classes directory
+ * @param targetFile the target file
+ * @param jarArchiver the jar archiver to use
+ * @param session the current session
+ * @param project the related project
* @param archiveConfiguration the archive configuration to use
* @throws MojoExecutionException if an error occurred while creating the archive
*/
diff --git a/src/main/java/org/apache/maven/plugin/war/util/DependencyInfo.java b/src/main/java/org/apache/maven/plugin/war/util/DependencyInfo.java
index de1dba9..31f0ffb 100644
--- a/src/main/java/org/apache/maven/plugin/war/util/DependencyInfo.java
+++ b/src/main/java/org/apache/maven/plugin/war/util/DependencyInfo.java
@@ -30,7 +30,6 @@
public class DependencyInfo
{
-
private final Dependency dependency;
private String targetFileName;
@@ -56,8 +55,7 @@
}
/**
- * Returns the target filen ame of the dependency. If no target file name
- * is associated, returns <tt>null</tt>.
+ * Returns the target filen ame of the dependency. If no target file name is associated, returns <tt>null</tt>.
*
* @return the target file name or <tt>null</tt>
*/
diff --git a/src/main/java/org/apache/maven/plugin/war/util/PathSet.java b/src/main/java/org/apache/maven/plugin/war/util/PathSet.java
index 7ff0b0b..7987c26 100644
--- a/src/main/java/org/apache/maven/plugin/war/util/PathSet.java
+++ b/src/main/java/org/apache/maven/plugin/war/util/PathSet.java
@@ -32,15 +32,15 @@
/**
* Set of file's paths.
* <p/>
- * The class extends functionality of a "normal" set of strings by a process of
- * the paths normalization. All paths are converted to unix form (slashes) and
- * they don't start with starting /.
+ * The class extends functionality of a "normal" set of strings by a process of the paths normalization. All paths are
+ * converted to unix form (slashes) and they don't start with starting /.
*
* @author Piotr Tabor
* @version $Id$
*/
-public class PathSet implements Iterable<String>
+public class PathSet
+ implements Iterable<String>
{
/**
@@ -71,12 +71,11 @@
*/
public PathSet()
{
- /*Empty default constructor*/
+ /* Empty default constructor */
}
/**
- * Creates paths set and normalizate and adds all 'paths'.
- * The source 'paths' will not be changed
+ * Creates paths set and normalizate and adds all 'paths'. The source 'paths' will not be changed
*
* @param paths to be added
*/
@@ -86,8 +85,7 @@
}
/**
- * Creates paths set and normalizate and adds all 'paths'.
- * The source 'paths' will not be changed
+ * Creates paths set and normalizate and adds all 'paths'. The source 'paths' will not be changed
*
* @param paths to be added
*/
@@ -107,10 +105,9 @@
}
/**
- * Normalizes and adds given paths (collection of strings)
- * to the set. The source collection will not be changed
+ * Normalizes and adds given paths (collection of strings) to the set. The source collection will not be changed
*
- * @param paths - collection of strings to be added
+ * @param paths - collection of strings to be added
* @param prefix added to all given paths
*/
public void addAll( Collection<String> paths, String prefix )
@@ -122,10 +119,9 @@
}
/**
- * Normalizes and adds given paths to the set.
- * The source collection will not be changed
+ * Normalizes and adds given paths to the set. The source collection will not be changed
*
- * @param paths to be added
+ * @param paths to be added
* @param prefix added to all given paths
*/
public void addAll( String[] paths, String prefix )
@@ -137,10 +133,9 @@
}
/**
- * Adds given paths to the set.
- * The source collection will not be changed
+ * Adds given paths to the set. The source collection will not be changed
*
- * @param paths to be added
+ * @param paths to be added
* @param prefix added to all given paths
*/
public void addAll( PathSet paths, String prefix )
@@ -152,8 +147,7 @@
}
/**
- * Normalizes and adds given paths (collection of strings)
- * to the set. The source collection will not be changed
+ * Normalizes and adds given paths (collection of strings) to the set. The source collection will not be changed
*
* @param paths - collection of strings to be added
*/
@@ -163,8 +157,7 @@
}
/**
- * Normalizes and adds given paths to the set.
- * The source collection will not be changed
+ * Normalizes and adds given paths to the set. The source collection will not be changed
*
* @param paths to be added
*/
@@ -174,8 +167,7 @@
}
/**
- * Adds given paths to the set.
- * The source collection will not be changed
+ * Adds given paths to the set. The source collection will not be changed
*
* @param paths to be added
*/
@@ -185,8 +177,7 @@
}
/**
- * Checks if the set constains given path. The path is normalized
- * before check.
+ * Checks if the set constains given path. The path is normalized before check.
*
* @param path we are looking for in the set.
* @return information if the set constains the path.
@@ -255,7 +246,7 @@
* Adds to the set all files in the given directory
*
* @param directory that will be searched for file's paths to add
- * @param prefix to be added to all found files
+ * @param prefix to be added to all found files
*/
public void addAllFilesInDirectory( File directory, String prefix )
{
diff --git a/src/main/java/org/apache/maven/plugin/war/util/WarUtils.java b/src/main/java/org/apache/maven/plugin/war/util/WarUtils.java
index 916af7c..57817cc 100644
--- a/src/main/java/org/apache/maven/plugin/war/util/WarUtils.java
+++ b/src/main/java/org/apache/maven/plugin/war/util/WarUtils.java
@@ -25,25 +25,28 @@
import org.codehaus.plexus.util.StringUtils;
/**
- *
* @author Stephane Nicoll
* @version $Id$
*/
public class WarUtils
{
-
public static Artifact getArtifact( MavenProject project, Dependency dependency )
{
- for (Object o : project.getArtifacts()) {
+ for ( Object o : project.getArtifacts() )
+ {
Artifact artifact = (Artifact) o;
- if (artifact.getGroupId().equals(dependency.getGroupId())
- && artifact.getArtifactId().equals(dependency.getArtifactId())
- && artifact.getType().equals(dependency.getType())) {
- if (artifact.getClassifier() == null && dependency.getClassifier() == null) {
+ if ( artifact.getGroupId().equals( dependency.getGroupId() )
+ && artifact.getArtifactId().equals( dependency.getArtifactId() )
+ && artifact.getType().equals( dependency.getType() ) )
+ {
+ if ( artifact.getClassifier() == null && dependency.getClassifier() == null )
+ {
return artifact;
- } else if (dependency.getClassifier() != null
- && dependency.getClassifier().equals(artifact.getClassifier())) {
+ }
+ else if ( dependency.getClassifier() != null
+ && dependency.getClassifier().equals( artifact.getClassifier() ) )
+ {
return artifact;
}
}
@@ -67,22 +70,22 @@
return false;
}
if ( artifact.getVersion() != null ? !artifact.getVersion().equals( dependency.getVersion() )
- : dependency.getVersion() != null )
+ : dependency.getVersion() != null )
{
return false;
}
if ( artifact.getType() != null ? !artifact.getType().equals( dependency.getType() )
- : dependency.getType() != null )
+ : dependency.getType() != null )
{
return false;
}
if ( artifact.getClassifier() != null ? !artifact.getClassifier().equals( dependency.getClassifier() )
- : dependency.getClassifier() != null )
+ : dependency.getClassifier() != null )
{
return false;
}
if ( artifact.getScope() != null ? !artifact.getScope().equals( dependency.getScope() )
- : dependency.getScope() != null )
+ : dependency.getScope() != null )
{
return false;
}
@@ -110,12 +113,12 @@
return false;
}
if ( first.getClassifier() != null ? !first.getClassifier().equals( second.getClassifier() )
- : second.getClassifier() != null )
+ : second.getClassifier() != null )
{
return false;
}
if ( first.getExclusions() != null ? !first.getExclusions().equals( second.getExclusions() )
- : second.getExclusions() != null )
+ : second.getExclusions() != null )
{
return false;
}
@@ -128,7 +131,7 @@
return false;
}
if ( first.getSystemPath() != null ? !first.getSystemPath().equals( second.getSystemPath() )
- : second.getSystemPath() != null )
+ : second.getSystemPath() != null )
{
return false;
}
@@ -137,12 +140,11 @@
return false;
}
if ( first.getVersion() != null ? !first.getVersion().equals( second.getVersion() )
- : second.getVersion() != null )
+ : second.getVersion() != null )
{
return false;
}
return true;
}
-
}
diff --git a/src/main/java/org/apache/maven/plugin/war/util/WebappStructure.java b/src/main/java/org/apache/maven/plugin/war/util/WebappStructure.java
index f7239f0..f842519 100644
--- a/src/main/java/org/apache/maven/plugin/war/util/WebappStructure.java
+++ b/src/main/java/org/apache/maven/plugin/war/util/WebappStructure.java
@@ -33,12 +33,10 @@
import java.util.Set;
/**
- * Represents the structure of a web application composed of multiple
- * overlays. Each overlay is registered within this structure with the
- * set of files it holds.
+ * Represents the structure of a web application composed of multiple overlays. Each overlay is registered within this
+ * structure with the set of files it holds.
* <p/>
- * Note that this structure is persisted to disk at each invocation to
- * store which owner holds which path (file).
+ * Note that this structure is persisted to disk at each invocation to store which owner holds which path (file).
*
* @author Stephane Nicoll
* @version $Id$
@@ -70,7 +68,7 @@
* Creates a new instance with the specified cache.
*
* @param dependencies the dependencies of the project
- * @param cache the cache
+ * @param cache the cache
*/
public WebappStructure( List<Dependency> dependencies, WebappStructure cache )
{
@@ -115,7 +113,6 @@
return result;
}
-
/**
* Specify if the specified <tt>path</tt> is registered or not.
*
@@ -129,10 +126,10 @@
}
/**
- * Registers the specified path for the specified owner. Returns <tt>true</tt>
- * if the path is not already registered, <tt>false</tt> otherwise.
+ * Registers the specified path for the specified owner. Returns <tt>true</tt> if the path is not already
+ * registered, <tt>false</tt> otherwise.
*
- * @param id the owner of the path
+ * @param id the owner of the path
* @param path the relative path from the webapp root directory
* @return true if the file was registered successfully
*/
@@ -150,16 +147,14 @@
}
/**
- * Forces the registration of the specified path for the specified owner. If
- * the file is not registered yet, a simple registration is performed. If the
- * file already exists, the owner changes to the specified one.
+ * Forces the registration of the specified path for the specified owner. If the file is not registered yet, a
+ * simple registration is performed. If the file already exists, the owner changes to the specified one.
* <p/>
- * Beware that the semantic of the return boolean is different than the one
- * from {@link #registerFile(String, String)}; returns <tt>true</tt> if an
- * owner replacement was made and <tt>false</tt> if the file was simply registered
- * for the first time.
+ * Beware that the semantic of the return boolean is different than the one from
+ * {@link #registerFile(String, String)}; returns <tt>true</tt> if an owner replacement was made and <tt>false</tt>
+ * if the file was simply registered for the first time.
*
- * @param id the owner of the path
+ * @param id the owner of the path
* @param path the relative path from the webapp root directory
* @return false if the file did not exist, true if the owner was replaced
*/
@@ -181,11 +176,11 @@
}
/**
- * Registers the specified path for the specified owner. Invokes
- * the <tt>callback</tt> with the result of the registration.
+ * Registers the specified path for the specified owner. Invokes the <tt>callback</tt> with the result of the
+ * registration.
*
- * @param id the owner of the path
- * @param path the relative path from the webapp root directory
+ * @param id the owner of the path
+ * @param path the relative path from the webapp root directory
* @param callback the callback to invoke with the result of the registration
* @throws IOException if the callback invocation throws an IOException
*/
@@ -223,8 +218,7 @@
}
/**
- * Returns the owner of the specified <tt>path</tt>. If the file is not
- * registered, returns <tt>null</tt>
+ * Returns the owner of the specified <tt>path</tt>. If the file is not registered, returns <tt>null</tt>
*
* @param path the relative path from the webapp root directory
* @return the owner or <tt>null</tt>.
@@ -246,20 +240,18 @@
}
}
- throw new IllegalStateException(
- "Should not happen, path [" + path + "] is flagged as being registered but was not found." );
+ throw new IllegalStateException( "Should not happen, path [" + path
+ + "] is flagged as being registered but was not found." );
}
}
/**
- * Returns the owners. Note that this the returned {@link Set} may be
- * inconsistent since it represents a persistent cache across multiple
- * invocations.
+ * Returns the owners. Note that this the returned {@link Set} may be inconsistent since it represents a persistent
+ * cache across multiple invocations.
* <p/>
- * For instance, if an overlay was removed in this execution, it will be
- * still be there till the cache is cleaned. This happens when the clean
- * mojo is invoked.
+ * For instance, if an overlay was removed in this execution, it will be still be there till the cache is cleaned.
+ * This happens when the clean mojo is invoked.
*
* @return the list of owners
*/
@@ -295,7 +287,6 @@
return pathSet;
}
-
/**
* Analyze the dependencies of the project using the specified callback.
*
@@ -373,14 +364,14 @@
/**
* Registers the target file name for the specified artifact.
*
- * @param artifact the artifact
+ * @param artifact the artifact
* @param targetFileName the target file name
*/
public void registerTargetFileName( Artifact artifact, String targetFileName )
{
if ( dependenciesInfo != null )
{
- for ( DependencyInfo dependencyInfo : dependenciesInfo )
+ for ( DependencyInfo dependencyInfo : dependenciesInfo )
{
if ( WarUtils.isRelated( artifact, dependencyInfo.getDependency() ) )
{
@@ -391,11 +382,10 @@
}
/**
- * Returns the cached target file name that matches the specified
- * dependency, that is the target file name of the previous run.
+ * Returns the cached target file name that matches the specified dependency, that is the target file name of the
+ * previous run.
* <p/>
- * The dependency object may have changed so the comparison is
- * based on basic attributes of the dependency.
+ * The dependency object may have changed so the comparison is based on basic attributes of the dependency.
*
* @param dependency a dependency
* @return the target file name of the last run for this dependency
@@ -406,7 +396,7 @@
{
return null;
}
- for ( DependencyInfo dependencyInfo : cache.getDependenciesInfo() )
+ for ( DependencyInfo dependencyInfo : cache.getDependenciesInfo() )
{
final Dependency dependency2 = dependencyInfo.getDependency();
if ( StringUtils.equals( dependency.getGroupId(), dependency2.getGroupId() )
@@ -433,7 +423,7 @@
/**
* Find a dependency that is similar from the specified dependency.
*
- * @param dependency the dependency to find
+ * @param dependency the dependency to find
* @param dependencies a list of dependencies
* @return a similar dependency or <tt>null</tt> if no similar dependency is found
*/
@@ -444,7 +434,9 @@
if ( dependency.getGroupId().equals( dep.getGroupId() )
&& dependency.getArtifactId().equals( dep.getArtifactId() )
&& dependency.getType().equals( dep.getType() )
- && ( ( dependency.getClassifier() == null && dep.getClassifier() == null ) || ( dependency.getClassifier() != null && dependency.getClassifier().equals( dep.getClassifier() ) ) ) )
+ && (
+ ( dependency.getClassifier() == null && dep.getClassifier() == null )
+ || ( dependency.getClassifier() != null && dependency.getClassifier().equals( dep.getClassifier() ) ) ) )
{
return dep;
}
@@ -454,7 +446,7 @@
private Dependency matchDependency( List<Dependency> dependencies, Dependency dependency )
{
- for ( Dependency dep : dependencies)
+ for ( Dependency dep : dependencies )
{
if ( WarUtils.dependencyEquals( dep, dependency ) )
{
@@ -465,7 +457,6 @@
return null;
}
-
private List<DependencyInfo> createDependenciesInfoList( List<Dependency> dependencies )
{
if ( dependencies == null )
@@ -473,14 +464,13 @@
return Collections.emptyList();
}
final List<DependencyInfo> result = new ArrayList<DependencyInfo>();
- for ( Dependency dependency : dependencies )
+ for ( Dependency dependency : dependencies )
{
result.add( new DependencyInfo( dependency ) );
}
return result;
}
-
private Object readResolve()
{
// the full structure should be resolved so let's rebuild it
@@ -493,21 +483,17 @@
}
/**
- * Callback interface to handle events related to filepath registration in
- * the webapp.
+ * Callback interface to handle events related to filepath registration in the webapp.
*/
public interface RegistrationCallback
{
-
/**
- * Called if the <tt>targetFilename</tt> for the specified <tt>ownerId</tt>
- * has been registered successfully.
+ * Called if the <tt>targetFilename</tt> for the specified <tt>ownerId</tt> has been registered successfully.
* <p/>
- * This means that the <tt>targetFilename</tt> was unknown and has been
- * registered successfully.
+ * This means that the <tt>targetFilename</tt> was unknown and has been registered successfully.
*
- * @param ownerId the ownerId
+ * @param ownerId the ownerId
* @param targetFilename the relative path according to the root of the webapp
* @throws IOException if an error occurred while handling this event
*/
@@ -515,13 +501,11 @@
throws IOException;
/**
- * Called if the <tt>targetFilename</tt> for the specified <tt>ownerId</tt>
- * has already been registered.
+ * Called if the <tt>targetFilename</tt> for the specified <tt>ownerId</tt> has already been registered.
* <p/>
- * This means that the <tt>targetFilename</tt> was known and belongs to the
- * specified owner.
+ * This means that the <tt>targetFilename</tt> was known and belongs to the specified owner.
*
- * @param ownerId the ownerId
+ * @param ownerId the ownerId
* @param targetFilename the relative path according to the root of the webapp
* @throws IOException if an error occurred while handling this event
*/
@@ -529,32 +513,28 @@
throws IOException;
/**
- * Called if the registration of the <tt>targetFilename</tt> for the
- * specified <tt>ownerId</tt> has been refused since the path already
- * belongs to the <tt>actualOwnerId</tt>.
+ * Called if the registration of the <tt>targetFilename</tt> for the specified <tt>ownerId</tt> has been refused
+ * since the path already belongs to the <tt>actualOwnerId</tt>.
* <p/>
- * This means that the <tt>targetFilename</tt> was known and does not
- * belong to the specified owner.
+ * This means that the <tt>targetFilename</tt> was known and does not belong to the specified owner.
*
- * @param ownerId the ownerId
+ * @param ownerId the ownerId
* @param targetFilename the relative path according to the root of the webapp
- * @param actualOwnerId the actual owner
+ * @param actualOwnerId the actual owner
* @throws IOException if an error occurred while handling this event
*/
void refused( String ownerId, String targetFilename, String actualOwnerId )
throws IOException;
/**
- * Called if the <tt>targetFilename</tt> for the specified <tt>ownerId</tt>
- * has been registered successfully by superseding a <tt>deprecatedOwnerId</tt>,
- * that is the previous owner of the file.
+ * Called if the <tt>targetFilename</tt> for the specified <tt>ownerId</tt> has been registered successfully by
+ * superseding a <tt>deprecatedOwnerId</tt>, that is the previous owner of the file.
* <p/>
- * This means that the <tt>targetFilename</tt> was known but for another
- * owner. This usually happens after a project's configuration change. As a
- * result, the file has been registered successfully to the new owner.
+ * This means that the <tt>targetFilename</tt> was known but for another owner. This usually happens after a
+ * project's configuration change. As a result, the file has been registered successfully to the new owner.
*
- * @param ownerId the ownerId
- * @param targetFilename the relative path according to the root of the webapp
+ * @param ownerId the ownerId
+ * @param targetFilename the relative path according to the root of the webapp
* @param deprecatedOwnerId the previous owner that does not exist anymore
* @throws IOException if an error occurred while handling this event
*/
@@ -562,15 +542,13 @@
throws IOException;
/**
- * Called if the <tt>targetFilename</tt> for the specified <tt>ownerId</tt>
- * has been registered successfully by superseding a <tt>unknownOwnerId</tt>,
- * that is an owner that does not exist anymore in the current project.
+ * Called if the <tt>targetFilename</tt> for the specified <tt>ownerId</tt> has been registered successfully by
+ * superseding a <tt>unknownOwnerId</tt>, that is an owner that does not exist anymore in the current project.
* <p/>
- * This means that the <tt>targetFilename</tt> was known but for an owner that
- * does not exist anymore. Hence the file has been registered successfully to
- * the new owner.
+ * This means that the <tt>targetFilename</tt> was known but for an owner that does not exist anymore. Hence the
+ * file has been registered successfully to the new owner.
*
- * @param ownerId the ownerId
+ * @param ownerId the ownerId
* @param targetFilename the relative path according to the root of the webapp
* @param unknownOwnerId the previous owner that does not exist anymore
* @throws IOException if an error occurred while handling this event
@@ -609,7 +587,7 @@
/**
* Called if the version of the dependency has changed since the last build.
*
- * @param dependency the dependency
+ * @param dependency the dependency
* @param previousVersion the previous version of the dependency
*/
void updatedVersion( Dependency dependency, String previousVersion );
@@ -617,16 +595,15 @@
/**
* Called if the scope of the dependency has changed since the last build.
*
- * @param dependency the dependency
+ * @param dependency the dependency
* @param previousScope the previous scope
*/
void updatedScope( Dependency dependency, String previousScope );
/**
- * Called if the optional flag of the dependency has changed since the
- * last build.
+ * Called if the optional flag of the dependency has changed since the last build.
*
- * @param dependency the dependency
+ * @param dependency the dependency
* @param previousOptional the previous optional flag
*/
void updatedOptionalFlag( Dependency dependency, boolean previousOptional );
@@ -634,7 +611,7 @@
/**
* Called if the dependency has been updated for unknown reason.
*
- * @param dependency the dependency
+ * @param dependency the dependency
* @param previousDep the previous dependency
*/
void updatedUnknown( Dependency dependency, Dependency previousDep );
diff --git a/src/main/java/org/apache/maven/plugin/war/util/WebappStructureSerializer.java b/src/main/java/org/apache/maven/plugin/war/util/WebappStructureSerializer.java
index fdcfd34..04935f6 100644
--- a/src/main/java/org/apache/maven/plugin/war/util/WebappStructureSerializer.java
+++ b/src/main/java/org/apache/maven/plugin/war/util/WebappStructureSerializer.java
@@ -40,16 +40,16 @@
public class WebappStructureSerializer
{
- private static final XStream xStream;
+ private static final XStream xstream;
static
{
- xStream = new XStream( new DomDriver() );
+ xstream = new XStream( new DomDriver() );
// Register aliases
- xStream.alias( "webapp-structure", WebappStructure.class );
- xStream.alias( "path-set", PathSet.class );
- xStream.alias( "dependency", Dependency.class );
+ xstream.alias( "webapp-structure", WebappStructure.class );
+ xstream.alias( "path-set", PathSet.class );
+ xstream.alias( "dependency", Dependency.class );
}
@@ -60,7 +60,6 @@
{
}
-
/**
* Reads the {@link WebappStructure} from the specified file.
*
@@ -76,7 +75,7 @@
try
{
reader = ReaderFactory.newXmlReader( file );
- return (WebappStructure) xStream.fromXML( reader );
+ return (WebappStructure) xstream.fromXML( reader );
}
finally
{
@@ -88,7 +87,7 @@
* Saves the {@link WebappStructure} to the specified file.
*
* @param webappStructure the structure to save
- * @param targetFile the file to use to save the structure
+ * @param targetFile the file to use to save the structure
* @throws IOException if an error occurred while saving the webapp structure
*/
public void toXml( WebappStructure webappStructure, File targetFile )
@@ -99,8 +98,7 @@
{
if ( !targetFile.getParentFile().exists() && !targetFile.getParentFile().mkdirs() )
{
- throw new IOException(
- "Could not create parent [" + targetFile.getParentFile().getAbsolutePath() + "]" );
+ throw new IOException( "Could not create parent [" + targetFile.getParentFile().getAbsolutePath() + "]" );
}
if ( !targetFile.exists() && !targetFile.createNewFile() )
@@ -108,7 +106,7 @@
throw new IOException( "Could not create file [" + targetFile.getAbsolutePath() + "]" );
}
writer = WriterFactory.newXmlWriter( targetFile );
- xStream.toXML( webappStructure, writer );
+ xstream.toXML( webappStructure, writer );
}
finally
{
diff --git a/src/test/java/org/apache/maven/plugin/war/AbstractWarExplodedMojoTest.java b/src/test/java/org/apache/maven/plugin/war/AbstractWarExplodedMojoTest.java
index c8ac119..d7902a7 100644
--- a/src/test/java/org/apache/maven/plugin/war/AbstractWarExplodedMojoTest.java
+++ b/src/test/java/org/apache/maven/plugin/war/AbstractWarExplodedMojoTest.java
@@ -48,7 +48,6 @@
mojo = (WarExplodedMojo) lookupMojo( "exploded", getPomFile() );
}
-
/**
* Returns the pom configuration to use.
*
@@ -66,12 +65,11 @@
/**
* Configures the exploded mojo for the specified test.
* <p/>
- * If the <tt>sourceFiles</tt> parameter is <tt>null</tt>, sample
- * JSPs are created by default.
+ * If the <tt>sourceFiles</tt> parameter is <tt>null</tt>, sample JSPs are created by default.
*
- * @param testId the id of the test
+ * @param testId the id of the test
* @param artifactStubs the dependencies (may be null)
- * @param sourceFiles the source files to create (may be null)
+ * @param sourceFiles the source files to create (may be null)
* @return the webapp directory
* @throws Exception if an error occurs while configuring the mojo
*/
@@ -90,9 +88,10 @@
else
{
webAppSource = createWebAppSource( testId, false );
- for (String sourceFile : sourceFiles) {
- File sample = new File(webAppSource, sourceFile);
- createFile(sample);
+ for ( String sourceFile : sourceFiles )
+ {
+ File sample = new File( webAppSource, sourceFile );
+ createFile( sample );
}
@@ -104,8 +103,9 @@
if ( artifactStubs != null )
{
- for (ArtifactStub artifactStub : artifactStubs) {
- project.addArtifact(artifactStub);
+ for ( ArtifactStub artifactStub : artifactStubs )
+ {
+ project.addArtifact( artifactStub );
}
}
@@ -115,11 +115,10 @@
return webAppDirectory;
}
-
/**
* Configures the exploded mojo for the specified test.
*
- * @param testId the id of the test
+ * @param testId the id of the test
* @param artifactStubs the dependencies (may be null)
* @return the webapp directory
* @throws Exception if an error occurs while configuring the mojo
@@ -146,8 +145,7 @@
}
/**
- * Asserts the default content of the war based on the specified
- * webapp directory.
+ * Asserts the default content of the war based on the specified webapp directory.
*
* @param webAppDirectory the webapp directory
* @return a list of File objects that have been asserted
@@ -168,10 +166,8 @@
return content;
}
-
/**
- * Asserts the web.xml file of the war based on the specified
- * webapp directory.
+ * Asserts the web.xml file of the war based on the specified webapp directory.
*
* @param webAppDirectory the webapp directory
* @return a list with the web.xml File object
@@ -188,25 +184,28 @@
}
/**
- * Asserts custom content of the war based on the specified webapp
- * directory.
+ * Asserts custom content of the war based on the specified webapp directory.
*
* @param webAppDirectory the webapp directory
- * @param filePaths an array of file paths relative to the webapp directory
- * @param customMessage a custom message if an assertion fails
+ * @param filePaths an array of file paths relative to the webapp directory
+ * @param customMessage a custom message if an assertion fails
* @return a list of File objects that have been inspected
*/
protected List<File> assertCustomContent( File webAppDirectory, String[] filePaths, String customMessage )
{
final List<File> content = new ArrayList<File>();
- for (String filePath : filePaths) {
- final File expectedFile = new File(webAppDirectory, filePath);
- if (customMessage != null) {
- assertTrue(customMessage + " - " + expectedFile.toString(), expectedFile.exists());
- } else {
- assertTrue("source file not found: " + expectedFile.toString(), expectedFile.exists());
+ for ( String filePath : filePaths )
+ {
+ final File expectedFile = new File( webAppDirectory, filePath );
+ if ( customMessage != null )
+ {
+ assertTrue( customMessage + " - " + expectedFile.toString(), expectedFile.exists() );
}
- content.add(expectedFile);
+ else
+ {
+ assertTrue( "source file not found: " + expectedFile.toString(), expectedFile.exists() );
+ }
+ content.add( expectedFile );
}
return content;
}
@@ -215,8 +214,8 @@
* Asserts that the webapp contains only the specified files.
*
* @param webAppDirectory the webapp directory
- * @param expectedFiles the expected files
- * @param filter an optional filter to ignore some resources
+ * @param expectedFiles the expected files
+ * @param filter an optional filter to ignore some resources
*/
protected void assertWebAppContent( File webAppDirectory, List<File> expectedFiles, FileFilter filter )
{
@@ -233,34 +232,36 @@
// Now we have the files, sort them.
Collections.sort( expectedFiles );
Collections.sort( webAppContent );
- assertEquals( "Invalid webapp content, expected " + expectedFiles.size() + "file(s) " + expectedFiles +
- " but got " + webAppContent.size() + " file(s) " + webAppContent, expectedFiles, webAppContent );
+ assertEquals( "Invalid webapp content, expected " + expectedFiles.size() + "file(s) " + expectedFiles
+ + " but got " + webAppContent.size() + " file(s) " + webAppContent, expectedFiles, webAppContent );
}
/**
* Builds the list of files and directories from the specified dir.
* <p/>
- * Note that the filter is not used the usual way. If the filter does
- * not accept the current file, it's not added but yet the subdirectories
- * are added if any.
+ * Note that the filter is not used the usual way. If the filter does not accept the current file, it's not added
+ * but yet the subdirectories are added if any.
*
- * @param dir the base directory
- * @param filter the filter
+ * @param dir the base directory
+ * @param filter the filter
* @param content the current content, updated recursivly
*/
private void buildFilesList( final File dir, FileFilter filter, final List<File> content )
{
final File[] files = dir.listFiles();
- for (File file : files) {
+ for ( File file : files )
+ {
// Add the file if the filter is ok with it
- if (filter.accept(file)) {
- content.add(file);
+ if ( filter.accept( file ) )
+ {
+ content.add( file );
}
// Even if the file is not accepted and is a directory, add it
- if (file.isDirectory()) {
- buildFilesList(file, filter, content);
+ if ( file.isDirectory() )
+ {
+ buildFilesList( file, filter, content );
}
}
@@ -274,7 +275,6 @@
private final int webAppDirIndex;
-
public FileFilterImpl( File webAppDirectory, String[] rejectedFilePaths )
{
if ( rejectedFilePaths != null )
diff --git a/src/test/java/org/apache/maven/plugin/war/AbstractWarMojoTest.java b/src/test/java/org/apache/maven/plugin/war/AbstractWarMojoTest.java
index be0d2bd..5b01b07 100644
--- a/src/test/java/org/apache/maven/plugin/war/AbstractWarMojoTest.java
+++ b/src/test/java/org/apache/maven/plugin/war/AbstractWarMojoTest.java
@@ -66,7 +66,8 @@
setVariableValueToObject( mojo, "useCache", Boolean.FALSE );
setVariableValueToObject( mojo, "mavenFileFilter", lookup( MavenFileFilter.class.getName() ) );
setVariableValueToObject( mojo, "useJvmChmod", Boolean.TRUE );
- MavenSession mavenSession = new MavenSession( null, null, null, null, null, null, null, System.getProperties(), null );
+ MavenSession mavenSession =
+ new MavenSession( null, null, null, null, null, null, null, System.getProperties(), null );
setVariableValueToObject( mojo, "session", mavenSession );
mojo.setClassesDirectory( classesDir );
mojo.setWarSourceDirectory( webAppSource );
@@ -92,9 +93,10 @@
if ( xmlFiles != null )
{
- for (String o : xmlFiles) {
- XMLFile = new File(xmlConfigDir, o);
- createFile(XMLFile);
+ for ( String o : xmlFiles )
+ {
+ XMLFile = new File( xmlConfigDir, o );
+ createFile( XMLFile );
}
}
@@ -142,7 +144,6 @@
return createWebAppSource( id, true );
}
-
/**
* create a class directory with or without a sample class
*
@@ -247,12 +248,14 @@
// Archive was not yet created for that id so let's create it
final File rootDir = new File( OVERLAYS_ROOT_DIR, id );
rootDir.mkdirs();
- String[] filePaths = new String[]{"jsp/d/a.jsp", "jsp/d/b.jsp", "jsp/d/c.jsp", "jsp/a.jsp", "jsp/b.jsp",
- "jsp/c.jsp", "WEB-INF/classes/a.class", "WEB-INF/classes/b.class", "WEB-INF/classes/c.class",
- "WEB-INF/lib/a.jar", "WEB-INF/lib/b.jar", "WEB-INF/lib/c.jar", "WEB-INF/web.xml"};
+ String[] filePaths =
+ new String[] { "jsp/d/a.jsp", "jsp/d/b.jsp", "jsp/d/c.jsp", "jsp/a.jsp", "jsp/b.jsp", "jsp/c.jsp",
+ "WEB-INF/classes/a.class", "WEB-INF/classes/b.class", "WEB-INF/classes/c.class", "WEB-INF/lib/a.jar",
+ "WEB-INF/lib/b.jar", "WEB-INF/lib/c.jar", "WEB-INF/web.xml" };
- for (String filePath : filePaths) {
- createFile(new File(rootDir, filePath), id + "-" + filePath);
+ for ( String filePath : filePaths )
+ {
+ createFile( new File( rootDir, filePath ), id + "-" + filePath );
}
createArchive( rootDir, destFile );
@@ -261,7 +264,6 @@
// Overlay utilities
-
/**
* Builds a test overlay.
*
@@ -296,7 +298,7 @@
{
try
{
- //WarArchiver archiver = new WarArchiver();
+ // WarArchiver archiver = new WarArchiver();
Archiver archiver = new JarArchiver();
@@ -305,7 +307,7 @@
archiver.setDestFile( destinationFile );
archiver.addDirectory( directory );
- //archiver.setWebxml( new File(directory, "WEB-INF/web.xml"));
+ // archiver.setWebxml( new File(directory, "WEB-INF/web.xml"));
// create archive
archiver.createArchive();
@@ -323,5 +325,4 @@
}
}
-
}
\ No newline at end of file
diff --git a/src/test/java/org/apache/maven/plugin/war/WarDependenciesAnalysisTest.java b/src/test/java/org/apache/maven/plugin/war/WarDependenciesAnalysisTest.java
index a35acce..e7cce82 100644
--- a/src/test/java/org/apache/maven/plugin/war/WarDependenciesAnalysisTest.java
+++ b/src/test/java/org/apache/maven/plugin/war/WarDependenciesAnalysisTest.java
@@ -30,8 +30,6 @@
import java.util.List;
/**
- *
- *
* @author Stephane Nicoll
*/
public class WarDependenciesAnalysisTest
@@ -47,7 +45,6 @@
return new File( getBasedir(), "target/test-classes/unit/dependenciesanalysis/test-dir" );
}
-
public void testNoChange()
throws Exception
{
@@ -58,9 +55,10 @@
jarArtifact.setArtifactId( "lib-test" );
jarArtifact.setVersion( "1.0" );
- doTestTwiceWithUpdatedDependency( testId, new ArtifactStub[]{jarArtifact}, new ArtifactStub[]{jarArtifact},
- new String[]{"WEB-INF/lib/lib-test-1.0.jar"},
- new String[]{"WEB-INF/lib/lib-test-1.0.jar"} );
+ doTestTwiceWithUpdatedDependency( testId, new ArtifactStub[] { jarArtifact },
+ new ArtifactStub[] { jarArtifact },
+ new String[] { "WEB-INF/lib/lib-test-1.0.jar" },
+ new String[] { "WEB-INF/lib/lib-test-1.0.jar" } );
}
@@ -74,8 +72,8 @@
jarArtifact.setArtifactId( "lib-test" );
jarArtifact.setVersion( "1.0" );
- doTestTwiceWithUpdatedDependency( testId, new ArtifactStub[]{jarArtifact}, null,
- new String[]{"WEB-INF/lib/lib-test-1.0.jar"}, null );
+ doTestTwiceWithUpdatedDependency( testId, new ArtifactStub[] { jarArtifact }, null,
+ new String[] { "WEB-INF/lib/lib-test-1.0.jar" }, null );
}
@@ -93,9 +91,10 @@
jarArtifact2.setArtifactId( "lib-test" );
jarArtifact2.setVersion( "2.0" );
- doTestTwiceWithUpdatedDependency( testId, new ArtifactStub[]{jarArtifact}, new ArtifactStub[]{jarArtifact2},
- new String[]{"WEB-INF/lib/lib-test-1.0.jar"},
- new String[]{"WEB-INF/lib/lib-test-2.0.jar"} );
+ doTestTwiceWithUpdatedDependency( testId, new ArtifactStub[] { jarArtifact },
+ new ArtifactStub[] { jarArtifact2 },
+ new String[] { "WEB-INF/lib/lib-test-1.0.jar" },
+ new String[] { "WEB-INF/lib/lib-test-2.0.jar" } );
}
@@ -114,8 +113,9 @@
jarArtifact2.setVersion( "1.0" );
jarArtifact2.setScope( Artifact.SCOPE_PROVIDED );
- doTestTwiceWithUpdatedDependency( testId, new ArtifactStub[]{jarArtifact}, new ArtifactStub[]{jarArtifact2},
- new String[]{"WEB-INF/lib/lib-test-1.0.jar"}, null );
+ doTestTwiceWithUpdatedDependency( testId, new ArtifactStub[] { jarArtifact },
+ new ArtifactStub[] { jarArtifact2 },
+ new String[] { "WEB-INF/lib/lib-test-1.0.jar" }, null );
}
@@ -125,7 +125,7 @@
throws Exception
{
// setup test data
- final File xmlSource = createXMLConfigDir( testId, new String[]{"web.xml"} );
+ final File xmlSource = createXMLConfigDir( testId, new String[] { "web.xml" } );
final File webAppDirectory = setUpMojoWithCache( testId, firstStubs );
try
{
@@ -138,7 +138,7 @@
assertedFiles.addAll( assertCustomContent( webAppDirectory, firstCustomContent, "library not found" ) );
// Ok now check that there is no more files/directories
- final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[]{MANIFEST_PATH} );
+ final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] { MANIFEST_PATH } );
assertWebAppContent( webAppDirectory, assertedFiles, filter );
// Run the thing again and check it's ok
@@ -151,8 +151,7 @@
assertedFiles2.addAll( assertWebXml( webAppDirectory ) );
if ( secondCustomContent != null )
{
- assertedFiles2.addAll(
- assertCustomContent( webAppDirectory, secondCustomContent, "library not found" ) );
+ assertedFiles2.addAll( assertCustomContent( webAppDirectory, secondCustomContent, "library not found" ) );
}
assertWebAppContent( webAppDirectory, assertedFiles2, filter );
@@ -169,7 +168,7 @@
/**
* Configures the exploded mojo for the specified test.
*
- * @param testId the id of the test
+ * @param testId the id of the test
* @param artifactStubs the dependencies (may be null)
* @return the webapp directory
* @throws Exception if an error occurs while configuring the mojo
@@ -185,5 +184,4 @@
return webappDir;
}
-
}
diff --git a/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoFilteringTest.java b/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoFilteringTest.java
index 8aec4a4..fbb3019 100644
--- a/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoFilteringTest.java
+++ b/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoFilteringTest.java
@@ -47,7 +47,6 @@
{
return new File( getBasedir(), "target/test-classes/unit/warexplodedmojo/test-dir" );
}
-
/**
* @throws Exception
@@ -65,7 +64,7 @@
File sampleResource = new File( webAppResource, "custom-setting.cfg" );
File sampleResourceWDir = new File( webAppResource, "custom-config/custom-setting.cfg" );
List<String> filterList = new LinkedList<String>();
- ResourceStub[] resources = new ResourceStub[]{new ResourceStub()};
+ ResourceStub[] resources = new ResourceStub[] { new ResourceStub() };
createFile( sampleResource );
createFile( sampleResourceWDir );
@@ -119,7 +118,7 @@
assertEquals( "error in filtering using System properties", "system_key_1=" + System.getProperty( "user.dir" ),
line );
line = reader.readLine();
- System.out.println(" line " + line );
+ System.out.println( " line " + line );
assertEquals( "error in filtering using System properties", "system_key_2=" + System.getProperty( "user.dir" ),
line );
@@ -132,7 +131,7 @@
assertEquals( "error in filtering using System properties", "system_property_1=system-property-value",
reader.readLine() );
assertEquals( "error in filtering using System properties", "system_property_2=system-property-value",
- reader.readLine() );
+ reader.readLine() );
// update property, and generate again
System.setProperty( "system.property", "new-system-property-value" );
@@ -148,7 +147,7 @@
assertEquals( "error in filtering using System properties", "system_key_1=" + System.getProperty( "user.dir" ),
reader.readLine() );
assertEquals( "error in filtering using System properties", "system_key_2=" + System.getProperty( "user.dir" ),
- reader.readLine() );
+ reader.readLine() );
assertEquals( "error in filtering using project properties", "project_key_1=i_think_so", reader.readLine() );
assertEquals( "error in filtering using project properties", "project_key_2=i_think_so", reader.readLine() );
@@ -159,7 +158,7 @@
assertEquals( "error in filtering using System properties", "system_property_1=new-system-property-value",
reader.readLine() );
assertEquals( "error in filtering using System properties", "system_property_2=new-system-property-value",
- reader.readLine() );
+ reader.readLine() );
// update property, and generate again
File filterFile = new File( getTestDirectory(), testId + "-test-data/filters/filter.properties" );
@@ -184,7 +183,7 @@
assertEquals( "error in filtering using System properties", "system_key_1=" + System.getProperty( "user.dir" ),
reader.readLine() );
assertEquals( "error in filtering using System properties", "system_key_2=" + System.getProperty( "user.dir" ),
- reader.readLine() );
+ reader.readLine() );
assertEquals( "error in filtering using project properties", "project_key_1=i_think_so", reader.readLine() );
assertEquals( "error in filtering using project properties", "project_key_2=i_think_so", reader.readLine() );
@@ -195,7 +194,7 @@
assertEquals( "error in filtering using System properties", "system_property_1=new-system-property-value",
reader.readLine() );
assertEquals( "error in filtering using System properties", "system_property_2=new-system-property-value",
- reader.readLine() );
+ reader.readLine() );
assertEquals( "error in filtering using filter files", "resource_key_1=this_is_filtered", reader.readLine() );
assertEquals( "error in filtering using filter files", "resource_key_2=this_is_filtered", reader.readLine() );
@@ -205,6 +204,6 @@
expectedWebSource2File.delete();
expectedResourceFile.delete();
expectedResourceWDirFile.delete();
- }
+ }
}
diff --git a/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java b/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java
index 6e962d5..90a0835 100644
--- a/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java
+++ b/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java
@@ -70,7 +70,7 @@
File webAppResource = new File( getTestDirectory(), testId + "-resources" );
File webAppDirectory = new File( getTestDirectory(), testId );
File sampleResource = new File( webAppResource, "pix/panis_na.jpg" );
- ResourceStub[] resources = new ResourceStub[]{new ResourceStub()};
+ ResourceStub[] resources = new ResourceStub[] { new ResourceStub() };
createFile( sampleResource );
@@ -115,7 +115,7 @@
File webAppResource = new File( getTestDirectory(), "resources" );
File webAppDirectory = new File( getTestDirectory(), testId );
File sampleResource = new File( webAppResource, "pix/panis_na.jpg" );
- ResourceStub[] resources = new ResourceStub[]{new ResourceStub()};
+ ResourceStub[] resources = new ResourceStub[] { new ResourceStub() };
createFile( sampleResource );
@@ -156,7 +156,7 @@
MavenProjectBasicStub project = new MavenProjectBasicStub();
File webAppSource = createWebAppSource( testId );
File classesDir = createClassesDir( testId, true );
- File xmlSource = createXMLConfigDir( testId, new String[]{"web.xml"} );
+ File xmlSource = createXMLConfigDir( testId, new String[] { "web.xml" } );
File webAppDirectory = new File( getTestDirectory(), testId );
// configure mojo
@@ -194,7 +194,7 @@
MavenProjectBasicStub project = new MavenProjectBasicStub();
File classesDir = createClassesDir( testId, true );
File webAppSource = createWebAppSource( testId );
- File xmlSource = createXMLConfigDir( testId, new String[]{"config.xml"} );
+ File xmlSource = createXMLConfigDir( testId, new String[] { "config.xml" } );
File webAppDirectory = new File( getTestDirectory(), testId );
// configure mojo
@@ -317,60 +317,60 @@
expectedFile.delete();
}
-// The last modified thingy behavior is not applicable anymore. This is the only test that
-// has been removed.
-// /**
-// * Merge a dependent WAR that gets updated since the last run.
-// */
-// public void testExplodedWarMergeWarUpdated()
-// throws Exception
-// {
-// // setup test data
-// MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
-// WarArtifactStub warArtifact = new WarArtifactStub( getBasedir() );
-//
-// String testId = "testExplodedWarMergeWarUpdated";
-// File webAppDirectory = new File( getTestDirectory(), testId );
-// FileUtils.deleteDirectory( webAppDirectory );
-//
-// File webAppSource = getWebAppSource( testId );
-//
-// File workDirectory = new File( getTestDirectory(), "/war/work-" + testId );
-// createDir( workDirectory );
-//
-// File classesDir = createClassesDir( testId, true );
-//
-// // configure mojo
-// project.addArtifact( warArtifact );
-// this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
-// setVariableValueToObject( mojo, "workDirectory", workDirectory );
-// mojo.execute();
-//
-// // validate operation
-// File expectedFile = new File( webAppDirectory, "/org/sample/company/test.jsp" );
-//
-// assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
-// assertEquals( "file incorrect", "", FileUtils.fileRead( expectedFile ) );
-//
-// // update file, so the local one is older
-// warArtifact.setFile( new File( warArtifact.getFile().getParentFile(), "simple-updated.war" ) );
-//
-// mojo.execute();
-//
-// assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
-// assertEquals( "file incorrect", "updated\n", FileUtils.fileRead( expectedFile ) );
-//
-// // update file, so the local one is newer
-// warArtifact.setFile( new File( warArtifact.getFile().getParentFile(), "simple.war" ) );
-//
-// mojo.execute();
-//
-// assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
-// assertEquals( "file incorrect", "updated\n", FileUtils.fileRead( expectedFile ) );
-//
-// // house keeping
-// expectedFile.delete();
-// }
+ // The last modified thingy behavior is not applicable anymore. This is the only test that
+ // has been removed.
+ // /**
+ // * Merge a dependent WAR that gets updated since the last run.
+ // */
+ // public void testExplodedWarMergeWarUpdated()
+ // throws Exception
+ // {
+ // // setup test data
+ // MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
+ // WarArtifactStub warArtifact = new WarArtifactStub( getBasedir() );
+ //
+ // String testId = "testExplodedWarMergeWarUpdated";
+ // File webAppDirectory = new File( getTestDirectory(), testId );
+ // FileUtils.deleteDirectory( webAppDirectory );
+ //
+ // File webAppSource = getWebAppSource( testId );
+ //
+ // File workDirectory = new File( getTestDirectory(), "/war/work-" + testId );
+ // createDir( workDirectory );
+ //
+ // File classesDir = createClassesDir( testId, true );
+ //
+ // // configure mojo
+ // project.addArtifact( warArtifact );
+ // this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
+ // setVariableValueToObject( mojo, "workDirectory", workDirectory );
+ // mojo.execute();
+ //
+ // // validate operation
+ // File expectedFile = new File( webAppDirectory, "/org/sample/company/test.jsp" );
+ //
+ // assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
+ // assertEquals( "file incorrect", "", FileUtils.fileRead( expectedFile ) );
+ //
+ // // update file, so the local one is older
+ // warArtifact.setFile( new File( warArtifact.getFile().getParentFile(), "simple-updated.war" ) );
+ //
+ // mojo.execute();
+ //
+ // assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
+ // assertEquals( "file incorrect", "updated\n", FileUtils.fileRead( expectedFile ) );
+ //
+ // // update file, so the local one is newer
+ // warArtifact.setFile( new File( warArtifact.getFile().getParentFile(), "simple.war" ) );
+ //
+ // mojo.execute();
+ //
+ // assertTrue( "file not found: " + expectedFile.toString(), expectedFile.exists() );
+ // assertEquals( "file incorrect", "updated\n", FileUtils.fileRead( expectedFile ) );
+ //
+ // // house keeping
+ // expectedFile.delete();
+ // }
/**
* @throws Exception
@@ -709,8 +709,7 @@
assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() );
- assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact.toString(),
- expectedEJBDupArtifact.exists() );
+ assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact.toString(), expectedEJBDupArtifact.exists() );
// house keeping
expectedWebSourceFile.delete();
@@ -762,8 +761,7 @@
assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() );
- assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact.toString(),
- expectedEJBDupArtifact.exists() );
+ assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact.toString(), expectedEJBDupArtifact.exists() );
// house keeping
expectedWebSourceFile.delete();
@@ -1017,8 +1015,7 @@
assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() );
- assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact.toString(),
- expectedEJBDupArtifact.exists() );
+ assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact.toString(), expectedEJBDupArtifact.exists() );
// house keeping
expectedWebSourceFile.delete();
@@ -1031,5 +1028,4 @@
/*---------------------------*/
-
}
diff --git a/src/test/java/org/apache/maven/plugin/war/WarInPlaceMojoTest.java b/src/test/java/org/apache/maven/plugin/war/WarInPlaceMojoTest.java
index 7be7107..b9eb7bb 100644
--- a/src/test/java/org/apache/maven/plugin/war/WarInPlaceMojoTest.java
+++ b/src/test/java/org/apache/maven/plugin/war/WarInPlaceMojoTest.java
@@ -28,8 +28,8 @@
public class WarInPlaceMojoTest
extends AbstractWarMojoTest
{
- protected static final String pomFilePath =
- getBasedir() + "/target/test-classes/unit/warexplodedinplacemojo/plugin-config.xml";
+ protected static final String pomFilePath = getBasedir()
+ + "/target/test-classes/unit/warexplodedinplacemojo/plugin-config.xml";
protected File getTestDirectory()
throws Exception
@@ -67,7 +67,7 @@
File classesDir = createClassesDir( testId, true );
File webAppResource = new File( getTestDirectory(), "resources" );
File sampleResource = new File( webAppResource, "pix/panis_na.jpg" );
- ResourceStub[] resources = new ResourceStub[]{new ResourceStub()};
+ ResourceStub[] resources = new ResourceStub[] { new ResourceStub() };
createFile( sampleResource );
diff --git a/src/test/java/org/apache/maven/plugin/war/WarManifestMojoTest.java b/src/test/java/org/apache/maven/plugin/war/WarManifestMojoTest.java
index 6d412d7..20a206a 100644
--- a/src/test/java/org/apache/maven/plugin/war/WarManifestMojoTest.java
+++ b/src/test/java/org/apache/maven/plugin/war/WarManifestMojoTest.java
@@ -140,11 +140,11 @@
idx = content.indexOf( "Implementation-Vendor" );
- assertTrue( idx >= 0 );
+ assertTrue( idx >= 0 );
}
public void testManifestWithCustomAttributes()
- throws Exception
+ throws Exception
{
loadMojo( "target/test-classes/unit/manifest/manifest-with-custom-attrs/plugin-config.xml" );
@@ -167,11 +167,10 @@
int idx = content.indexOf( "Specification-Title" );
assertTrue( idx >= 0 );
-
+
idx = content.indexOf( "Custom-Version" );
- assertTrue( idx >= 0);
-
+ assertTrue( idx >= 0 );
}
diff --git a/src/test/java/org/apache/maven/plugin/war/WarMojoTest.java b/src/test/java/org/apache/maven/plugin/war/WarMojoTest.java
index 0ba2705..e20221d 100644
--- a/src/test/java/org/apache/maven/plugin/war/WarMojoTest.java
+++ b/src/test/java/org/apache/maven/plugin/war/WarMojoTest.java
@@ -43,8 +43,8 @@
{
WarMojo mojo;
- private static File pomFile =
- new File( getBasedir(), "target/test-classes/unit/warmojotest/plugin-config-primary-artifact.xml" );
+ private static File pomFile = new File( getBasedir(),
+ "target/test-classes/unit/warmojotest/plugin-config-primary-artifact.xml" );
protected File getTestDirectory()
{
@@ -75,7 +75,7 @@
String warName = "simple";
File webAppSource = createWebAppSource( testId );
File classesDir = createClassesDir( testId, true );
- File xmlSource = createXMLConfigDir( testId, new String[]{"web.xml"} );
+ File xmlSource = createXMLConfigDir( testId, new String[] { "web.xml" } );
project.setArtifact( warArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
@@ -85,12 +85,12 @@
mojo.execute();
- //validate jar file
+ // validate jar file
File expectedJarFile = new File( outputDir, "simple.war" );
- assertJarContent( expectedJarFile, new String[]{"META-INF/MANIFEST.MF", "WEB-INF/web.xml", "pansit.jsp",
+ assertJarContent( expectedJarFile, new String[] { "META-INF/MANIFEST.MF", "WEB-INF/web.xml", "pansit.jsp",
"org/web/app/last-exile.jsp", "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
- "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties"},
- new String[]{null, mojo.getWebXml().toString(), null, null, null, null} );
+ "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties" }, new String[] { null,
+ mojo.getWebXml().toString(), null, null, null, null } );
}
public void testSimpleWarPackagingExcludeWithIncludesRegEx()
@@ -104,25 +104,23 @@
String warName = "simple";
File webAppSource = createWebAppSource( testId );
File classesDir = createClassesDir( testId, true );
- File xmlSource = createXMLConfigDir( testId, new String[]{"web.xml"} );
+ File xmlSource = createXMLConfigDir( testId, new String[] { "web.xml" } );
project.setArtifact( warArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
setVariableValueToObject( mojo, "outputDirectory", outputDir );
setVariableValueToObject( mojo, "warName", warName );
mojo.setWebXml( new File( xmlSource, "web.xml" ) );
- setVariableValueToObject( mojo,"packagingIncludes","%regex[(.(?!exile))+]" );
-
-
+ setVariableValueToObject( mojo, "packagingIncludes", "%regex[(.(?!exile))+]" );
+
mojo.execute();
- //validate jar file
+ // validate jar file
File expectedJarFile = new File( outputDir, "simple.war" );
- assertJarContent( expectedJarFile, new String[]{"META-INF/MANIFEST.MF", "WEB-INF/web.xml", "pansit.jsp",
+ assertJarContent( expectedJarFile, new String[] { "META-INF/MANIFEST.MF", "WEB-INF/web.xml", "pansit.jsp",
"META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
- "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties"},
- new String[]{null, mojo.getWebXml().toString(), null, null, null, },
- new String[]{"org/web/app/last-exile.jsp"} );
+ "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties" }, new String[] { null,
+ mojo.getWebXml().toString(), null, null, null, }, new String[] { "org/web/app/last-exile.jsp" } );
}
public void testClassifier()
@@ -137,7 +135,7 @@
String warName = "simple";
File webAppSource = createWebAppSource( testId );
File classesDir = createClassesDir( testId, true );
- File xmlSource = createXMLConfigDir( testId, new String[]{"web.xml"} );
+ File xmlSource = createXMLConfigDir( testId, new String[] { "web.xml" } );
project.setArtifact( warArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
@@ -149,12 +147,12 @@
mojo.execute();
- //validate jar file
+ // validate jar file
File expectedJarFile = new File( outputDir, "simple-test-classifier.war" );
- assertJarContent( expectedJarFile, new String[]{"META-INF/MANIFEST.MF", "WEB-INF/web.xml", "pansit.jsp",
+ assertJarContent( expectedJarFile, new String[] { "META-INF/MANIFEST.MF", "WEB-INF/web.xml", "pansit.jsp",
"org/web/app/last-exile.jsp", "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
- "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties"},
- new String[]{null, mojo.getWebXml().toString(), null, null, null, null} );
+ "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties" }, new String[] { null,
+ mojo.getWebXml().toString(), null, null, null, null } );
}
public void testPrimaryArtifact()
@@ -169,7 +167,7 @@
String warName = "simple";
File webAppSource = createWebAppSource( testId );
File classesDir = createClassesDir( testId, true );
- File xmlSource = createXMLConfigDir( testId, new String[]{"web.xml"} );
+ File xmlSource = createXMLConfigDir( testId, new String[] { "web.xml" } );
warArtifact.setFile( new File( "error.war" ) );
project.setArtifact( warArtifact );
@@ -181,12 +179,12 @@
mojo.execute();
- //validate jar file
+ // validate jar file
File expectedJarFile = new File( outputDir, "simple.war" );
- assertJarContent( expectedJarFile, new String[]{"META-INF/MANIFEST.MF", "WEB-INF/web.xml", "pansit.jsp",
+ assertJarContent( expectedJarFile, new String[] { "META-INF/MANIFEST.MF", "WEB-INF/web.xml", "pansit.jsp",
"org/web/app/last-exile.jsp", "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
- "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties"},
- new String[]{null, mojo.getWebXml().toString(), null, null, null, null} );
+ "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties" }, new String[] { null,
+ mojo.getWebXml().toString(), null, null, null, null } );
}
public void testNotPrimaryArtifact()
@@ -205,7 +203,7 @@
String warName = "simple";
File webAppSource = createWebAppSource( testId );
File classesDir = createClassesDir( testId, true );
- File xmlSource = createXMLConfigDir( testId, new String[]{"web.xml"} );
+ File xmlSource = createXMLConfigDir( testId, new String[] { "web.xml" } );
warArtifact.setFile( new File( "error.war" ) );
project.setArtifact( warArtifact );
@@ -217,12 +215,12 @@
mojo.execute();
- //validate jar file
+ // validate jar file
File expectedJarFile = new File( outputDir, "simple.war" );
- assertJarContent( expectedJarFile, new String[]{"META-INF/MANIFEST.MF", "WEB-INF/web.xml", "pansit.jsp",
+ assertJarContent( expectedJarFile, new String[] { "META-INF/MANIFEST.MF", "WEB-INF/web.xml", "pansit.jsp",
"org/web/app/last-exile.jsp", "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
- "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties"},
- new String[]{null, mojo.getWebXml().toString(), null, null, null, null} );
+ "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties" }, new String[] { null,
+ mojo.getWebXml().toString(), null, null, null, null } );
}
public void testMetaInfContent()
@@ -236,7 +234,7 @@
String warName = "simple";
File webAppSource = createWebAppSource( testId );
File classesDir = createClassesDir( testId, true );
- File xmlSource = createXMLConfigDir( testId, new String[]{"web.xml"} );
+ File xmlSource = createXMLConfigDir( testId, new String[] { "web.xml" } );
// Create the sample config.xml
final File configFile = new File( webAppSource, "META-INF/config.xml" );
@@ -250,13 +248,13 @@
mojo.execute();
- //validate jar file
+ // validate jar file
File expectedJarFile = new File( outputDir, "simple.war" );
- assertJarContent( expectedJarFile, new String[]{"META-INF/MANIFEST.MF", "META-INF/config.xml",
+ assertJarContent( expectedJarFile, new String[] { "META-INF/MANIFEST.MF", "META-INF/config.xml",
"WEB-INF/web.xml", "pansit.jsp", "org/web/app/last-exile.jsp",
"META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
- "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties"}, new String[]{null, null,
- mojo.getWebXml().toString(), null, null, null, null} );
+ "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties" }, new String[] { null, null,
+ mojo.getWebXml().toString(), null, null, null, null } );
}
public void testMetaInfContentWithContainerConfig()
@@ -270,7 +268,7 @@
String warName = "simple";
File webAppSource = createWebAppSource( testId );
File classesDir = createClassesDir( testId, true );
- File xmlSource = createXMLConfigDir( testId, new String[]{"web.xml"} );
+ File xmlSource = createXMLConfigDir( testId, new String[] { "web.xml" } );
// Create the sample config.xml
final File configFile = new File( webAppSource, "META-INF/config.xml" );
@@ -285,16 +283,15 @@
mojo.execute();
- //validate jar file
+ // validate jar file
File expectedJarFile = new File( outputDir, "simple.war" );
- assertJarContent( expectedJarFile, new String[]{"META-INF/MANIFEST.MF", "META-INF/config.xml",
+ assertJarContent( expectedJarFile, new String[] { "META-INF/MANIFEST.MF", "META-INF/config.xml",
"WEB-INF/web.xml", "pansit.jsp", "org/web/app/last-exile.jsp",
"META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
- "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties"}, new String[]{null, null,
- mojo.getWebXml().toString(), null, null, null, null} );
+ "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties" }, new String[] { null, null,
+ mojo.getWebXml().toString(), null, null, null, null } );
}
-
public void testFailOnMissingWebXmlFalse()
throws Exception
{
@@ -315,12 +312,13 @@
mojo.setFailOnMissingWebXml( false );
mojo.execute();
- //validate jar file
+ // validate jar file
File expectedJarFile = new File( outputDir, "simple.war" );
- final Map<String, JarEntry> jarContent = assertJarContent( expectedJarFile, new String[]{"META-INF/MANIFEST.MF", "pansit.jsp",
- "org/web/app/last-exile.jsp", "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
- "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties"},
- new String[]{null, null, null, null, null} );
+ final Map<String, JarEntry> jarContent =
+ assertJarContent( expectedJarFile, new String[] { "META-INF/MANIFEST.MF", "pansit.jsp",
+ "org/web/app/last-exile.jsp", "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.xml",
+ "META-INF/maven/org.apache.maven.test/maven-test-plugin/pom.properties" }, new String[] { null, null,
+ null, null, null } );
assertFalse( "web.xml should be missing", jarContent.containsKey( "WEB-INF/web.xml" ) );
}
@@ -351,7 +349,7 @@
}
catch ( MojoExecutionException e )
{
- //expected behaviour
+ // expected behaviour
}
}
@@ -366,7 +364,7 @@
String warName = "simple";
File webAppSource = createWebAppSource( testId );
File classesDir = createClassesDir( testId, false );
- File xmlSource = createXMLConfigDir( testId, new String[]{"web.xml"} );
+ File xmlSource = createXMLConfigDir( testId, new String[] { "web.xml" } );
project.setArtifact( warArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
@@ -377,10 +375,10 @@
mojo.execute();
- //validate jar file
+ // validate jar file
File expectedJarFile = new File( outputDir, "simple-classes.jar" );
- assertJarContent( expectedJarFile, new String[]{"META-INF/MANIFEST.MF", "sample-servlet.class"},
- new String[]{null, null} );
+ assertJarContent( expectedJarFile, new String[] { "META-INF/MANIFEST.MF", "sample-servlet.class" },
+ new String[] { null, null } );
}
public void testAttachClassesWithCustomClassifier()
@@ -394,7 +392,7 @@
String warName = "simple";
File webAppSource = createWebAppSource( testId );
File classesDir = createClassesDir( testId, false );
- File xmlSource = createXMLConfigDir( testId, new String[]{"web.xml"} );
+ File xmlSource = createXMLConfigDir( testId, new String[] { "web.xml" } );
project.setArtifact( warArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
@@ -406,25 +404,25 @@
mojo.execute();
- //validate jar file
+ // validate jar file
File expectedJarFile = new File( outputDir, "simple-mystuff.jar" );
- assertJarContent( expectedJarFile, new String[]{"META-INF/MANIFEST.MF", "sample-servlet.class"},
- new String[]{null, null} );
+ assertJarContent( expectedJarFile, new String[] { "META-INF/MANIFEST.MF", "sample-servlet.class" },
+ new String[] { null, null } );
}
-
- protected Map<String, JarEntry> assertJarContent( final File expectedJarFile, final String[] files, final String[] filesContent )
+ protected Map<String, JarEntry> assertJarContent( final File expectedJarFile, final String[] files,
+ final String[] filesContent )
throws IOException
{
return assertJarContent( expectedJarFile, files, filesContent, null );
}
- protected Map<String, JarEntry> assertJarContent( final File expectedJarFile, final String[] files, final String[] filesContent, final String[] mustNotBeInJar )
+ protected Map<String, JarEntry> assertJarContent( final File expectedJarFile, final String[] files,
+ final String[] filesContent, final String[] mustNotBeInJar )
throws IOException
{
// Sanity check
- assertEquals( "Could not test, files and filesContent lenght does not match", files.length,
- filesContent.length );
+ assertEquals( "Could not test, files and filesContent lenght does not match", files.length, filesContent.length );
assertTrue( "war file not created: " + expectedJarFile.toString(), expectedJarFile.exists() );
final Map<String, JarEntry> jarContent = new HashMap<String, JarEntry>();
@@ -450,10 +448,11 @@
IOUtil.toString( jarFile.getInputStream( (ZipEntry) jarContent.get( file ) ) ) );
}
}
- if( mustNotBeInJar!=null )
+ if ( mustNotBeInJar != null )
{
- for (String file : mustNotBeInJar) {
- assertFalse("File[" + file + "] found in archive", jarContent.containsKey(file));
+ for ( String file : mustNotBeInJar )
+ {
+ assertFalse( "File[" + file + "] found in archive", jarContent.containsKey( file ) );
}
}
@@ -461,4 +460,3 @@
}
}
-
diff --git a/src/test/java/org/apache/maven/plugin/war/WarOverlaysTest.java b/src/test/java/org/apache/maven/plugin/war/WarOverlaysTest.java
index b16b634..8a2e8ac 100644
--- a/src/test/java/org/apache/maven/plugin/war/WarOverlaysTest.java
+++ b/src/test/java/org/apache/maven/plugin/war/WarOverlaysTest.java
@@ -39,7 +39,6 @@
private static File pomFile = new File( getBasedir(), "target/test-classes/unit/waroverlays/default.xml" );
-
public void setUp()
throws Exception
{
@@ -70,7 +69,7 @@
{
// setup test data
final String testId = "no-overlay";
- final File xmlSource = createXMLConfigDir( testId, new String[]{"web.xml"} );
+ final File xmlSource = createXMLConfigDir( testId, new String[] { "web.xml" } );
final File webAppDirectory = setUpMojo( testId, null );
try
@@ -97,14 +96,14 @@
// Add an overlay
final ArtifactStub overlay = buildWarOverlayStub( "overlay-one" );
- final File webAppDirectory = setUpMojo( testId, new ArtifactStub[]{overlay} );
+ final File webAppDirectory = setUpMojo( testId, new ArtifactStub[] { overlay } );
final List<File> assertedFiles = new ArrayList<File>();
try
{
mojo.execute();
assertedFiles.addAll( assertDefaultContent( webAppDirectory ) );
assertedFiles.addAll( assertWebXml( webAppDirectory ) );
- assertedFiles.addAll( assertCustomContent( webAppDirectory, new String[]{"index.jsp", "login.jsp"},
+ assertedFiles.addAll( assertCustomContent( webAppDirectory, new String[] { "index.jsp", "login.jsp" },
"overlay file not found" ) );
// index and login come from overlay1
@@ -112,7 +111,7 @@
assertOverlayedFile( webAppDirectory, "overlay-one", "login.jsp" );
// Ok now check that there is no more files/directories
- final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[]{MANIFEST_PATH} );
+ final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] { MANIFEST_PATH } );
assertWebAppContent( webAppDirectory, assertedFiles, filter );
}
finally
@@ -131,27 +130,26 @@
final ArtifactStub overlay = buildWarOverlayStub( "overlay-one" );
final ArtifactStub overlay2 = buildWarOverlayStub( "overlay-two" );
- final File webAppDirectory = setUpMojo( testId, new ArtifactStub[]{overlay, overlay2} );
+ final File webAppDirectory = setUpMojo( testId, new ArtifactStub[] { overlay, overlay2 } );
final List<File> assertedFiles = new ArrayList<File>();
try
{
mojo.execute();
assertedFiles.addAll( assertDefaultContent( webAppDirectory ) );
assertedFiles.addAll( assertWebXml( webAppDirectory ) );
- assertedFiles.addAll( assertCustomContent( webAppDirectory,
- new String[]{"index.jsp", "login.jsp", "admin.jsp"},
- "overlay file not found" ) );
+ assertedFiles.addAll( assertCustomContent( webAppDirectory, new String[] { "index.jsp", "login.jsp",
+ "admin.jsp" }, "overlay file not found" ) );
// index and login come from overlay1
assertOverlayedFile( webAppDirectory, "overlay-one", "index.jsp" );
assertOverlayedFile( webAppDirectory, "overlay-one", "login.jsp" );
- //admin comes from overlay2
+ // admin comes from overlay2
// index and login comes from overlay1
assertOverlayedFile( webAppDirectory, "overlay-two", "admin.jsp" );
// Ok now check that there is no more files/directories
- final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[]{MANIFEST_PATH} );
+ final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] { MANIFEST_PATH } );
assertWebAppContent( webAppDirectory, assertedFiles, filter );
}
finally
@@ -160,13 +158,10 @@
}
}
-
/**
- * Merge a dependent WAR when a file in the war source directory
- * overrides one found in the WAR.
+ * Merge a dependent WAR when a file in the war source directory overrides one found in the WAR.
* <p/>
- * It also tests completeness of the resulting war as well as the proper
- * order of dependencies.
+ * It also tests completeness of the resulting war as well as the proper order of dependencies.
*
* @throws Exception if any error occurs
*/
@@ -181,19 +176,17 @@
final ArtifactStub overlay2 = buildWarOverlayStub( "overlay-full-2" );
final ArtifactStub overlay3 = buildWarOverlayStub( "overlay-full-3" );
- final File webAppDirectory = setUpMojo( testId, new ArtifactStub[]{overlay1, overlay2, overlay3},
- new String[]{"org/sample/company/test.jsp", "jsp/b.jsp"} );
+ final File webAppDirectory =
+ setUpMojo( testId, new ArtifactStub[] { overlay1, overlay2, overlay3 }, new String[] {
+ "org/sample/company/test.jsp", "jsp/b.jsp" } );
assertScenariOne( testId, webAppDirectory );
}
-
/**
- * Tests that specifying the overlay explicitely has the same behavior as
- * the default (i.e. order, etc).
+ * Tests that specifying the overlay explicitely has the same behavior as the default (i.e. order, etc).
* <p/>
- * The default project is not specified in this case so it is processed
- * first by default
+ * The default project is not specified in this case so it is processed first by default
*
* @throws Exception if an error occurs
*/
@@ -208,8 +201,9 @@
final ArtifactStub overlay2 = buildWarOverlayStub( "overlay-full-2" );
final ArtifactStub overlay3 = buildWarOverlayStub( "overlay-full-3" );
- final File webAppDirectory = setUpMojo( testId, new ArtifactStub[]{overlay1, overlay2, overlay3},
- new String[]{"org/sample/company/test.jsp", "jsp/b.jsp"} );
+ final File webAppDirectory =
+ setUpMojo( testId, new ArtifactStub[] { overlay1, overlay2, overlay3 }, new String[] {
+ "org/sample/company/test.jsp", "jsp/b.jsp" } );
// Add the tags
final List<Overlay> overlays = new ArrayList<Overlay>();
@@ -223,11 +217,9 @@
}
/**
- * Tests that specifying the overlay explicitely has the same behavior as
- * the default (i.e. order, etc).
+ * Tests that specifying the overlay explicitely has the same behavior as the default (i.e. order, etc).
* <p/>
- * The default project is explicitely specified so this should match the
- * default.
+ * The default project is explicitely specified so this should match the default.
*
* @throws Exception if an error occurs
*/
@@ -242,8 +234,9 @@
final ArtifactStub overlay2 = buildWarOverlayStub( "overlay-full-2" );
final ArtifactStub overlay3 = buildWarOverlayStub( "overlay-full-3" );
- final File webAppDirectory = setUpMojo( testId, new ArtifactStub[]{overlay1, overlay2, overlay3},
- new String[]{"org/sample/company/test.jsp", "jsp/b.jsp"} );
+ final File webAppDirectory =
+ setUpMojo( testId, new ArtifactStub[] { overlay1, overlay2, overlay3 }, new String[] {
+ "org/sample/company/test.jsp", "jsp/b.jsp" } );
// Add the tags
final List<Overlay> overlays = new ArrayList<Overlay>();
@@ -261,12 +254,10 @@
assertScenariOne( testId, webAppDirectory );
}
-
/**
- * Runs the mojo and asserts a scenerio with 3 overlays and no
- * includes/excludes settings.
+ * Runs the mojo and asserts a scenerio with 3 overlays and no includes/excludes settings.
*
- * @param testId thie id of the test
+ * @param testId thie id of the test
* @param webAppDirectory the webapp directory
* @throws Exception if an exception occurs
*/
@@ -278,10 +269,10 @@
{
mojo.execute();
assertedFiles.addAll( assertWebXml( webAppDirectory ) );
- assertedFiles.addAll( assertCustomContent( webAppDirectory, new String[]{"jsp/a.jsp", "jsp/b.jsp",
+ assertedFiles.addAll( assertCustomContent( webAppDirectory, new String[] { "jsp/a.jsp", "jsp/b.jsp",
"jsp/c.jsp", "jsp/d/a.jsp", "jsp/d/b.jsp", "jsp/d/c.jsp", "org/sample/company/test.jsp",
"WEB-INF/classes/a.class", "WEB-INF/classes/b.class", "WEB-INF/classes/c.class", "WEB-INF/lib/a.jar",
- "WEB-INF/lib/b.jar", "WEB-INF/lib/c.jar"}, "overlay file not found" ) );
+ "WEB-INF/lib/b.jar", "WEB-INF/lib/c.jar" }, "overlay file not found" ) );
// Those files should come from the source webapp without any config
assertDefaultFileContent( testId, webAppDirectory, "jsp/b.jsp" );
@@ -302,7 +293,7 @@
assertOverlayedFile( webAppDirectory, "overlay-full-1", "WEB-INF/lib/c.jar" );
// Ok now check that there is no more files/directories
- final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[]{MANIFEST_PATH} );
+ final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] { MANIFEST_PATH } );
assertWebAppContent( webAppDirectory, assertedFiles, filter );
}
finally
@@ -322,8 +313,9 @@
final ArtifactStub overlay2 = buildWarOverlayStub( "overlay-full-2" );
final ArtifactStub overlay3 = buildWarOverlayStub( "overlay-full-3" );
- final File webAppDirectory = setUpMojo( testId, new ArtifactStub[]{overlay1, overlay2, overlay3},
- new String[]{"org/sample/company/test.jsp", "jsp/b.jsp"} );
+ final File webAppDirectory =
+ setUpMojo( testId, new ArtifactStub[] { overlay1, overlay2, overlay3 }, new String[] {
+ "org/sample/company/test.jsp", "jsp/b.jsp" } );
Overlay over1 = new DefaultOverlay( overlay3 );
over1.setExcludes( "**/a.*,**/c.*,**/*.xml" );
@@ -341,7 +333,7 @@
mojo.addOverlay( over1 );
mojo.addOverlay( over2 );
mojo.addOverlay( over3 );
- mojo.addOverlay( mojo.getCurrentProjectOverlay());
+ mojo.addOverlay( mojo.getCurrentProjectOverlay() );
mojo.addOverlay( over4 );
final List<File> assertedFiles = new ArrayList<File>();
@@ -349,10 +341,10 @@
{
mojo.execute();
assertedFiles.addAll( assertWebXml( webAppDirectory ) );
- assertedFiles.addAll( assertCustomContent( webAppDirectory, new String[]{"jsp/a.jsp", "jsp/b.jsp",
+ assertedFiles.addAll( assertCustomContent( webAppDirectory, new String[] { "jsp/a.jsp", "jsp/b.jsp",
"jsp/c.jsp", "jsp/d/a.jsp", "jsp/d/b.jsp", "jsp/d/c.jsp", "org/sample/company/test.jsp",
"WEB-INF/classes/a.class", "WEB-INF/classes/b.class", "WEB-INF/classes/c.class", "WEB-INF/lib/a.jar",
- "WEB-INF/lib/b.jar", "WEB-INF/lib/c.jar"}, "overlay file not found" ) );
+ "WEB-INF/lib/b.jar", "WEB-INF/lib/c.jar" }, "overlay file not found" ) );
assertOverlayedFile( webAppDirectory, "overlay-full-3", "jsp/a.jsp" );
assertOverlayedFile( webAppDirectory, "overlay-full-3", "jsp/b.jsp" );
@@ -370,7 +362,7 @@
assertOverlayedFile( webAppDirectory, "overlay-full-2", "WEB-INF/lib/c.jar" );
// Ok now check that there is no more files/directories
- final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[]{MANIFEST_PATH} );
+ final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] { MANIFEST_PATH } );
assertWebAppContent( webAppDirectory, assertedFiles, filter );
}
finally
@@ -379,7 +371,6 @@
}
}
-
public void testOverlaysIncludesExcludesWithMultipleDefinitions2()
throws Exception
{
@@ -391,8 +382,9 @@
final ArtifactStub overlay2 = buildWarOverlayStub( "overlay-full-2" );
final ArtifactStub overlay3 = buildWarOverlayStub( "overlay-full-3" );
- final File webAppDirectory = setUpMojo( testId, new ArtifactStub[]{overlay1, overlay2, overlay3},
- new String[]{"org/sample/company/test.jsp", "jsp/b.jsp"} );
+ final File webAppDirectory =
+ setUpMojo( testId, new ArtifactStub[] { overlay1, overlay2, overlay3 }, new String[] {
+ "org/sample/company/test.jsp", "jsp/b.jsp" } );
Overlay over1 = new DefaultOverlay( overlay3 );
over1.setExcludes( "**/a.*,**/c.*,**/*.xml,jsp/b.jsp" );
@@ -419,10 +411,10 @@
{
mojo.execute();
assertedFiles.addAll( assertWebXml( webAppDirectory ) );
- assertedFiles.addAll( assertCustomContent( webAppDirectory, new String[]{"jsp/a.jsp", "jsp/b.jsp",
+ assertedFiles.addAll( assertCustomContent( webAppDirectory, new String[] { "jsp/a.jsp", "jsp/b.jsp",
"jsp/c.jsp", "jsp/d/a.jsp", "jsp/d/b.jsp", "jsp/d/c.jsp", "org/sample/company/test.jsp",
"WEB-INF/classes/a.class", "WEB-INF/classes/b.class", "WEB-INF/classes/c.class", "WEB-INF/lib/a.jar",
- "WEB-INF/lib/b.jar", "WEB-INF/lib/c.jar"}, "overlay file not found" ) );
+ "WEB-INF/lib/b.jar", "WEB-INF/lib/c.jar" }, "overlay file not found" ) );
assertOverlayedFile( webAppDirectory, "overlay-full-3", "jsp/a.jsp" );
assertDefaultFileContent( testId, webAppDirectory, "jsp/b.jsp" );
@@ -440,7 +432,7 @@
assertOverlayedFile( webAppDirectory, "overlay-full-2", "WEB-INF/lib/c.jar" );
// Ok now check that there is no more files/directories
- final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[]{MANIFEST_PATH} );
+ final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] { MANIFEST_PATH } );
assertWebAppContent( webAppDirectory, assertedFiles, filter );
}
finally
@@ -460,7 +452,7 @@
final ArtifactStub overlay = buildWarOverlayStub( "overlay-one" );
final ArtifactStub overlay2 = buildWarOverlayStub( "overlay-two" );
- final File webAppDirectory = setUpMojo( testId, new ArtifactStub[]{overlay, overlay2} );
+ final File webAppDirectory = setUpMojo( testId, new ArtifactStub[] { overlay, overlay2 } );
final List<File> assertedFiles = new ArrayList<File>();
try
{
@@ -485,9 +477,8 @@
assertedFiles.addAll( assertDefaultContent( webAppDirectory ) );
assertedFiles.addAll( assertWebXml( webAppDirectory ) );
- assertedFiles.addAll( assertCustomContent( webAppDirectory,
- new String[]{"index.jsp", "login.jsp", "admin.jsp"},
- "overlay file not found" ) );
+ assertedFiles.addAll( assertCustomContent( webAppDirectory, new String[] { "index.jsp", "login.jsp",
+ "admin.jsp" }, "overlay file not found" ) );
// index and login come from overlay2 now
assertOverlayedFile( webAppDirectory, "overlay-two", "index.jsp" );
@@ -495,7 +486,7 @@
assertOverlayedFile( webAppDirectory, "overlay-two", "admin.jsp" );
// Ok now check that there is no more files/directories
- final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[]{MANIFEST_PATH} );
+ final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] { MANIFEST_PATH } );
assertWebAppContent( webAppDirectory, assertedFiles, filter );
}
finally
@@ -514,7 +505,7 @@
final ArtifactStub overlay = buildWarOverlayStub( "overlay-one" );
final ArtifactStub overlay2 = buildWarOverlayStub( "overlay-two" );
- final File webAppDirectory = setUpMojo( testId, new ArtifactStub[]{overlay, overlay2} );
+ final File webAppDirectory = setUpMojo( testId, new ArtifactStub[] { overlay, overlay2 } );
final List<File> assertedFiles = new ArrayList<File>();
try
{
@@ -541,9 +532,8 @@
assertedFiles.addAll( assertDefaultContent( webAppDirectory ) );
assertedFiles.addAll( assertWebXml( webAppDirectory ) );
- assertedFiles.addAll( assertCustomContent( webAppDirectory,
- new String[]{"index.jsp", "login.jsp", "admin.jsp"},
- "overlay file not found" ) );
+ assertedFiles.addAll( assertCustomContent( webAppDirectory, new String[] { "index.jsp", "login.jsp",
+ "admin.jsp" }, "overlay file not found" ) );
// index and login come from overlay2 now
assertOverlayedFile( webAppDirectory, "overlay-two", "index.jsp" );
@@ -551,7 +541,7 @@
assertOverlayedFile( webAppDirectory, "overlay-two", "admin.jsp" );
// Ok now check that there is no more files/directories
- final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[]{MANIFEST_PATH} );
+ final FileFilter filter = new FileFilterImpl( webAppDirectory, new String[] { MANIFEST_PATH } );
assertWebAppContent( webAppDirectory, assertedFiles, filter );
}
finally
@@ -562,16 +552,15 @@
// Helpers
-
/**
* Asserts that the content of an overlayed file is correct.
* <p/>
- * Note that the <tt>filePath</tt> is relative to both the webapp
- * directory and the overlayed directory, defined by the <tt>overlayId</tt>.
+ * Note that the <tt>filePath</tt> is relative to both the webapp directory and the overlayed directory, defined by
+ * the <tt>overlayId</tt>.
*
* @param webAppDirectory the webapp directory
- * @param overlayId the id of the overlay
- * @param filePath the relative path
+ * @param overlayId the id of the overlay
+ * @param filePath the relative path
* @throws IOException if an error occurred while reading the files
*/
protected void assertOverlayedFile( File webAppDirectory, String overlayId, String filePath )
@@ -584,16 +573,15 @@
}
-
/**
* Asserts that the content of an overlayed file is correct.
* <p/>
- * Note that the <tt>filePath</tt> is relative to both the webapp
- * directory and the overlayed directory, defined by the <tt>overlayId</tt>.
+ * Note that the <tt>filePath</tt> is relative to both the webapp directory and the overlayed directory, defined by
+ * the <tt>overlayId</tt>.
*
- * @param testId te id of the test
+ * @param testId te id of the test
* @param webAppDirectory the webapp directory
- * @param filePath the relative path
+ * @param filePath the relative path
* @throws IOException if an error occurred while reading the files
*/
protected void assertDefaultFileContent( String testId, File webAppDirectory, String filePath )
diff --git a/src/test/java/org/apache/maven/plugin/war/WarZipTest.java b/src/test/java/org/apache/maven/plugin/war/WarZipTest.java
index 1cdc204..4407635 100644
--- a/src/test/java/org/apache/maven/plugin/war/WarZipTest.java
+++ b/src/test/java/org/apache/maven/plugin/war/WarZipTest.java
@@ -42,7 +42,6 @@
private static File pomFile = new File( getBasedir(), "src/test/resources/unit/warziptest/war-with-zip.xml" );
-
protected File getTestDirectory()
{
return new File( getBasedir(), "target/test-classes/unit/warziptest" );
@@ -79,7 +78,7 @@
String warName = "simple";
File webAppSource = createWebAppSource( testId );
File classesDir = createClassesDir( testId, true );
- File xmlSource = createXMLConfigDir( testId, new String[]{"web.xml"} );
+ File xmlSource = createXMLConfigDir( testId, new String[] { "web.xml" } );
project.setArtifact( warArtifact );
this.configureMojo( mojo, new LinkedList<String>(), classesDir, webAppSource, webAppDirectory, project );
@@ -99,7 +98,7 @@
File webAppDirectory = configureMojo( "one-zip" );
Overlay overlay = new DefaultOverlay( buildZipArtifact() );
- //overlay.setSkip( false );
+ // overlay.setSkip( false );
overlay.setType( "zip" );
mojo.addOverlay( overlay );
mojo.execute();