[MWAR-375] Remove the useCache with it's implementation
diff --git a/pom.xml b/pom.xml
index fe62503..38372ef 100644
--- a/pom.xml
+++ b/pom.xml
@@ -121,12 +121,6 @@
</dependency>
<dependency>
- <groupId>com.thoughtworks.xstream</groupId>
- <artifactId>xstream</artifactId>
- <version>1.4.10</version>
- </dependency>
-
- <dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.2.0</version>
@@ -187,17 +181,6 @@
<rules>
<enforceBytecodeVersion combine.children="append">
<maxJdkVersion>${maven.compiler.target}</maxJdkVersion>
- <ignoreClasses>
- <!--
- ! MWAR-369:
- ! Added the following two ignores cause those classes
- ! are JDK 8 classes.
- -->
- <ignoreClass>com.thoughtworks.xstream.converters.reflection.LambdaConverter</ignoreClass>
- <ignoreClass>com.thoughtworks.xstream.mapper.LambdaMapper</ignoreClass>
- <ignoreClass>com.thoughtworks.xstream.converters.time.*</ignoreClass>
- <ignoreClass>com.thoughtworks.xstream.core.util.ISO8601JavaTimeConverter</ignoreClass>
- </ignoreClasses>
</enforceBytecodeVersion>
</rules>
<fail>true</fail>
diff --git a/src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java b/src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java
index 10f3724..4721d6b 100644
--- a/src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/war/AbstractWarMojo.java
@@ -45,15 +45,11 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.war.overlay.OverlayManager;
import org.apache.maven.plugins.war.packaging.CopyUserManifestTask;
-import org.apache.maven.plugins.war.packaging.DependenciesAnalysisPackagingTask;
import org.apache.maven.plugins.war.packaging.OverlayPackagingTask;
-import org.apache.maven.plugins.war.packaging.SaveWebappStructurePostPackagingTask;
import org.apache.maven.plugins.war.packaging.WarPackagingContext;
import org.apache.maven.plugins.war.packaging.WarPackagingTask;
-import org.apache.maven.plugins.war.packaging.WarPostPackagingTask;
import org.apache.maven.plugins.war.packaging.WarProjectPackagingTask;
import org.apache.maven.plugins.war.util.WebappStructure;
-import org.apache.maven.plugins.war.util.WebappStructureSerializer;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.filtering.MavenFileFilter;
import org.apache.maven.shared.filtering.MavenFilteringException;
@@ -197,23 +193,6 @@
private String outputFileNameMapping;
/**
- * The file containing the webapp structure cache.
- *
- * @since 2.1-alpha-1
- */
- @Parameter( defaultValue = "${project.build.directory}/war/work/webapp-cache.xml", required = true )
- 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.
- *
- * @since 2.1-alpha-1
- */
- @Parameter( defaultValue = "false" )
- private boolean useCache;
-
- /**
*/
@Component( role = ArtifactFactory.class )
private ArtifactFactory artifactFactory;
@@ -361,8 +340,6 @@
@Parameter
private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
- private final WebappStructureSerializer webappStructureSerialier = new WebappStructureSerializer();
-
private final Overlay currentProjectOverlay = Overlay.createInstance();
/**
@@ -465,17 +442,7 @@
throws MojoExecutionException, MojoFailureException, IOException
{
- WebappStructure cache;
- if ( useCache && cacheFile.exists() )
- {
- // CHECKSTYLE_OFF: LineLength
- cache = new WebappStructure( mavenProject.getDependencies(), webappStructureSerialier.fromXml( cacheFile ) );
- // CHECKSTYLE_ON: LineLength
- }
- else
- {
- cache = new WebappStructure( mavenProject.getDependencies(), null );
- }
+ WebappStructure structure = new WebappStructure( mavenProject.getDependencies() );
// CHECKSTYLE_OFF: LineLength
final long startTime = System.currentTimeMillis();
@@ -521,7 +488,7 @@
}
final WarPackagingContext context =
- new DefaultWarPackagingContext( webapplicationDirectory, cache, overlayManager, defaultFilterWrappers,
+ new DefaultWarPackagingContext( webapplicationDirectory, structure, overlayManager, defaultFilterWrappers,
getNonFilteredFileExtensions(), filteringDeploymentDescriptors,
this.artifactFactory, resourceEncoding, useJvmChmod );
@@ -532,13 +499,7 @@
warPackagingTask.performPackaging( context );
}
- // Post packaging
- final List<WarPostPackagingTask> postPackagingTasks = getPostPackagingTasks();
- for ( WarPostPackagingTask task : postPackagingTasks )
- {
- task.performPostPackaging( context );
- }
- getLog().info( "Webapp assembled in [" + ( System.currentTimeMillis() - startTime ) + " msecs]" );
+ getLog().debug( "Webapp assembled in [" + ( System.currentTimeMillis() - startTime ) + " msecs]" );
}
@@ -557,12 +518,6 @@
packagingTasks.add( new CopyUserManifestTask() );
- if ( useCache )
- {
- packagingTasks.add( new DependenciesAnalysisPackagingTask() );
-
- }
-
final List<Overlay> resolvedOverlays = overlayManager.getOverlays();
for ( Overlay overlay : resolvedOverlays )
{
@@ -580,23 +535,6 @@
}
/**
- * Returns a <tt>List</tt> of the {@link org.apache.maven.plugins.war.packaging.WarPostPackagingTask} instances to
- * invoke to perform the post-packaging.
- *
- * @return the list of post packaging tasks
- */
- private List<WarPostPackagingTask> getPostPackagingTasks()
- {
- final List<WarPostPackagingTask> postPackagingTasks = new ArrayList<>();
- if ( useCache )
- {
- postPackagingTasks.add( new SaveWebappStructurePostPackagingTask( cacheFile ) );
- }
- // TODO add lib scanning to detect duplicates
- return postPackagingTasks;
- }
-
- /**
* WarPackagingContext default implementation
*/
private class DefaultWarPackagingContext
@@ -1063,22 +1001,6 @@
}
/**
- * @return {@link #cacheFile}
- */
- public File getCacheFile()
- {
- return cacheFile;
- }
-
- /**
- * @param cacheFile {@link #cacheFile}
- */
- public void setCacheFile( File cacheFile )
- {
- this.cacheFile = cacheFile;
- }
-
- /**
* @return {@link #warSourceIncludes}
*/
public String getWarSourceIncludes()
@@ -1111,22 +1033,6 @@
}
/**
- * @return {@link #useCache}
- */
- public boolean isUseCache()
- {
- return useCache;
- }
-
- /**
- * @param useCache {@link #useCache}
- */
- public void setUseCache( boolean useCache )
- {
- this.useCache = useCache;
- }
-
- /**
* @return {@link #archive}
*/
public MavenArchiveConfiguration getArchive()
diff --git a/src/main/java/org/apache/maven/plugins/war/packaging/DependenciesAnalysisPackagingTask.java b/src/main/java/org/apache/maven/plugins/war/packaging/DependenciesAnalysisPackagingTask.java
deleted file mode 100644
index 4e53eab..0000000
--- a/src/main/java/org/apache/maven/plugins/war/packaging/DependenciesAnalysisPackagingTask.java
+++ /dev/null
@@ -1,234 +0,0 @@
-package org.apache.maven.plugins.war.packaging;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.war.util.WebappStructure;
-
-import java.io.File;
-
-/**
- * Analyzes the dependencies of the project with its previous state and update the target directory accordingly.
- *
- * @author Stephane Nicoll
- * @version $Id$
- */
-public class DependenciesAnalysisPackagingTask
- extends AbstractWarPackagingTask
-{
-
- /**
- * {@inheritDoc}
- */
- public void performPackaging( final WarPackagingContext context )
- throws MojoExecutionException, MojoFailureException
- {
-
- context.getWebappStructure().analyseDependencies( new DependenciesAnalysisCallbackImpl( context ) );
-
- }
-
- /**
- * {@inheritDoc}
- */
- protected void handleDependency( WarPackagingContext context, Dependency dependency, String notBundledMessage,
- String warOrZipMessage, String standardMessage, boolean removeFile )
- {
- if ( Artifact.SCOPE_PROVIDED.equals( dependency.getScope() )
- || Artifact.SCOPE_TEST.equals( dependency.getScope() ) || dependency.isOptional() )
- {
- context.getLog().debug( notBundledMessage );
- }
- else
- {
- handleDependencyScope( context, dependency, warOrZipMessage, standardMessage, removeFile );
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected void handleDependencyScope( WarPackagingContext context, Dependency dependency, String warOrZipMessage,
- String standardMessage, boolean removeFile )
- {
- if ( "war".equals( dependency.getType() ) || "zip".equals( dependency.getType() ) )
- {
- context.getLog().warn( warOrZipMessage );
- }
- else if ( "tld".equals( dependency.getType() ) || "aar".equals( dependency.getType() )
- || "mar".equals( dependency.getType() ) || "xar".equals( dependency.getType() )
- || "jar".equals( dependency.getType() ) || "ejb".equals( dependency.getType() )
- || "ejb-client".equals( dependency.getType() ) || "test-jar".equals( dependency.getType() )
- || "par".equals( dependency.getType() ) )
- {
- context.getLog().info( standardMessage );
- if ( removeFile )
- {
- removeDependency( context, dependency );
- }
- }
- }
-
- private void removeDependency( WarPackagingContext context, Dependency dependency )
- {
- final String targetFileName = context.getWebappStructure().getCachedTargetFileName( dependency );
- if ( targetFileName != null )
- {
- final String type = dependency.getType();
- File targetFile = null;
- if ( "tld".equals( type ) )
- {
- targetFile = new File( context.getWebappDirectory(), ArtifactsPackagingTask.TLD_PATH + targetFileName );
- }
- else if ( "aar".equals( type ) )
- {
- targetFile =
- new File( context.getWebappDirectory(), ArtifactsPackagingTask.SERVICES_PATH + targetFileName );
- }
- else if ( "mar".equals( type ) )
- {
- targetFile =
- new File( context.getWebappDirectory(), ArtifactsPackagingTask.MODULES_PATH + targetFileName );
- }
- else if ( "xar".equals( type ) )
- {
- targetFile =
- new File( context.getWebappDirectory(), ArtifactsPackagingTask.EXTENSIONS_PATH + targetFileName );
- }
- else if ( "jar".equals( type ) || "ejb".equals( type ) || "ejb-client".equals( type )
- || "test-jar".equals( type ) )
- {
- targetFile = new File( context.getWebappDirectory(), LIB_PATH + targetFileName );
- }
- else if ( "par".equals( type ) )
- {
- String targetFileName2 = targetFileName.substring( 0, targetFileName.lastIndexOf( '.' ) ) + ".jar";
- targetFile = new File( context.getWebappDirectory(), LIB_PATH + targetFileName2 );
- }
-
- // now remove
- if ( targetFile == null )
- {
- context.getLog().error( "Could not get file from dependency [" + dependency + "]" );
- }
- else if ( targetFile.exists() )
- {
- context.getLog().debug( "Removing file [" + targetFile.getAbsolutePath() + "]" );
- targetFile.delete();
- }
- else
- {
- context.getLog().warn( "File to remove [" + targetFile.getAbsolutePath() + "] has not been found" );
- }
- }
- else
- {
- context.getLog().warn( "Could not retrieve the target file name of dependency [" + dependency + "]" );
- }
- }
-
- class DependenciesAnalysisCallbackImpl
- implements WebappStructure.DependenciesAnalysisCallback
- {
- private final WarPackagingContext context;
-
- DependenciesAnalysisCallbackImpl( WarPackagingContext context )
- {
- this.context = context;
- }
-
- public void unchangedDependency( Dependency dependency )
- {
- context.getLog().debug( "Dependency [" + dependency + "] has not changed since last build." );
- }
-
- public void newDependency( Dependency dependency )
- {
- context.getLog().debug( "New dependency [" + dependency + "]." );
- }
-
- public void removedDependency( Dependency dependency )
- {
- handleDependency( context, dependency, "Dependency [" + dependency
- + "] has been removed from the project but it was not bundled anyway.", "Dependency [" + dependency
- + "] has been removed from the project. If it was included in the build as an overlay, "
- + "consider cleaning the target directory of the project (mvn clean)", "Dependency [" + dependency
- + "] has been removed from the project.", true );
- }
-
- 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 );
- }
-
- public void updatedScope( Dependency dependency, String previousScope )
- {
- // CHECKSTYLE_OFF: LineLength
- if ( Artifact.SCOPE_PROVIDED.equals( dependency.getScope() )
- || Artifact.SCOPE_TEST.equals( dependency.getScope() )
- && ( !Artifact.SCOPE_PROVIDED.equals( previousScope ) && !Artifact.SCOPE_TEST.equals( previousScope ) ) )
- // CHECKSTYLE_ON: LineLength
- {
- // It's now provided or test so it should be removed
- handleDependencyScope( context, dependency, "Scope of dependency [" + dependency + "] has changed ("
- + previousScope + " -> " + dependency.getScope()
- + "). If it was included in the build as an overlay, "
- + "consider cleaning the target directory of the project (mvn clean)", "Scope of dependency ["
- + dependency + "] has changed (" + previousScope + " -> " + dependency.getScope() + ").", true );
- }
-
- }
-
- 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 );
-
- }
- }
-
- public void updatedUnknown( Dependency dependency, Dependency previousDep )
- {
- handleDependency( context, dependency, "Dependency [" + dependency + "] has changed (was " + previousDep
- + ") but it was not bundled anyway.", "Dependency [" + dependency + "] has changed (was " + previousDep
- + "). If it was included in the build as an overlay, " + "consider "
- + "cleaning the target directory of the project (mvn clean)", "Dependency [" + dependency
- + "] has changed (was " + previousDep + ").", true );
- }
-
- }
-
-}
diff --git a/src/main/java/org/apache/maven/plugins/war/packaging/SaveWebappStructurePostPackagingTask.java b/src/main/java/org/apache/maven/plugins/war/packaging/SaveWebappStructurePostPackagingTask.java
deleted file mode 100644
index d34bda2..0000000
--- a/src/main/java/org/apache/maven/plugins/war/packaging/SaveWebappStructurePostPackagingTask.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.apache.maven.plugins.war.packaging;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.war.util.WebappStructureSerializer;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Saves the webapp structure cache.
- *
- * @author Stephane Nicoll
- * @version $Id$
- */
-public class SaveWebappStructurePostPackagingTask
- implements WarPostPackagingTask
-{
-
- private final File targetFile;
-
- private final WebappStructureSerializer serialier;
-
- /**
- * @param targetFile {@link #targetFile}
- */
- public SaveWebappStructurePostPackagingTask( File targetFile )
- {
- this.targetFile = targetFile;
- this.serialier = new WebappStructureSerializer();
- }
-
- /**
- * {@inheritDoc}
- */
- public void performPostPackaging( WarPackagingContext context )
- throws MojoExecutionException, MojoFailureException
- {
- if ( targetFile == null )
- {
- context.getLog().debug( "Cache usage is disabled, not saving webapp structure." );
- }
- else
- {
- try
- {
- serialier.toXml( context.getWebappStructure(), targetFile );
- context.getLog().debug( "Cache saved successfully." );
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( "Could not save webapp structure", e );
- }
- }
- }
-}
diff --git a/src/main/java/org/apache/maven/plugins/war/packaging/WarPackagingContext.java b/src/main/java/org/apache/maven/plugins/war/packaging/WarPackagingContext.java
index 150bf02..ee29466 100644
--- a/src/main/java/org/apache/maven/plugins/war/packaging/WarPackagingContext.java
+++ b/src/main/java/org/apache/maven/plugins/war/packaging/WarPackagingContext.java
@@ -154,9 +154,7 @@
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.
*
* @return the list of registered overlays, including the current project
*/
diff --git a/src/main/java/org/apache/maven/plugins/war/packaging/WarPostPackagingTask.java b/src/main/java/org/apache/maven/plugins/war/packaging/WarPostPackagingTask.java
deleted file mode 100644
index 8723049..0000000
--- a/src/main/java/org/apache/maven/plugins/war/packaging/WarPostPackagingTask.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.apache.maven.plugins.war.packaging;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-
-/**
- * Defines tasks that should be performed after the packaging.
- *
- * @author Stephane Nicoll
- * @version $Id$
- */
-public interface WarPostPackagingTask
-{
-
- /**
- * Executes the post packaging task.
- *
- * 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
- */
- void performPostPackaging( WarPackagingContext context )
- throws MojoExecutionException, MojoFailureException;
-
-}
diff --git a/src/main/java/org/apache/maven/plugins/war/util/WebappStructure.java b/src/main/java/org/apache/maven/plugins/war/util/WebappStructure.java
index 5d9a4f9..34ded21 100644
--- a/src/main/java/org/apache/maven/plugins/war/util/WebappStructure.java
+++ b/src/main/java/org/apache/maven/plugins/war/util/WebappStructure.java
@@ -21,13 +21,11 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Dependency;
-import org.codehaus.plexus.util.StringUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -50,8 +48,6 @@
private transient PathSet allFiles = new PathSet();
- private transient WebappStructure cache;
-
/**
* Creates a new empty instance.
*
@@ -61,27 +57,6 @@
{
this.dependenciesInfo = createDependenciesInfoList( dependencies );
this.registeredFiles = new HashMap<String, PathSet>();
- this.cache = null;
- }
-
- /**
- * Creates a new instance with the specified cache.
- *
- * @param dependencies the dependencies of the project
- * @param cache the cache
- */
- public WebappStructure( List<Dependency> dependencies, WebappStructure cache )
- {
- this.dependenciesInfo = createDependenciesInfoList( dependencies );
- this.registeredFiles = new HashMap<String, PathSet>();
- if ( cache == null )
- {
- this.cache = new WebappStructure( dependencies );
- }
- else
- {
- this.cache = cache;
- }
}
/**
@@ -197,22 +172,22 @@
{
doRegister( id, path );
// This is a new file
- if ( cache.getOwner( path ) == null )
+ if ( getOwner( path ) == null )
{
callback.registered( id, path );
} // The file already belonged to this owner
- else if ( cache.getOwner( path ).equals( id ) )
+ else if ( getOwner( path ).equals( id ) )
{
callback.alreadyRegistered( id, path );
} // The file belongs to another owner and it's known currently
- else if ( getOwners().contains( cache.getOwner( path ) ) )
+ else if ( getOwners().contains( getOwner( path ) ) )
{
- callback.superseded( id, path, cache.getOwner( path ) );
+ callback.superseded( id, path, getOwner( path ) );
} // The file belongs to another owner and it's unknown
else
{
- callback.supersededUnknownOwner( id, path, cache.getOwner( path ) );
+ callback.supersededUnknownOwner( id, path, getOwner( path ) );
}
}
}
@@ -247,12 +222,7 @@
}
/**
- * 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.
- * </p>
+ * Returns the owners.
*
* @return the list of owners
*/
@@ -288,79 +258,7 @@
return pathSet;
}
- /**
- * Analyze the dependencies of the project using the specified callback.
- *
- * @param callback the callback to use to report the result of the analysis
- */
- public void analyseDependencies( DependenciesAnalysisCallback callback )
- {
- if ( callback == null )
- {
- throw new NullPointerException( "Callback could not be null." );
- }
- if ( cache == null )
- {
- // Could not analyze dependencies without a cache
- return;
- }
-
- final List<Dependency> currentDependencies = new ArrayList<Dependency>( getDependencies() );
- final List<Dependency> previousDependencies = new ArrayList<Dependency>( cache.getDependencies() );
- final Iterator<Dependency> it = currentDependencies.listIterator();
- while ( it.hasNext() )
- {
- Dependency dependency = it.next();
- // Check if the dependency is there "as is"
-
- final Dependency matchingDependency = matchDependency( previousDependencies, dependency );
- if ( matchingDependency != null )
- {
- callback.unchangedDependency( dependency );
- // Handled so let's remove
- it.remove();
- previousDependencies.remove( matchingDependency );
- }
- else
- {
- // Try to get the dependency
- final Dependency previousDep = findDependency( dependency, previousDependencies );
- if ( previousDep == null )
- {
- callback.newDependency( dependency );
- it.remove();
- }
- else if ( !dependency.getVersion().equals( previousDep.getVersion() ) )
- {
- callback.updatedVersion( dependency, previousDep.getVersion() );
- it.remove();
- previousDependencies.remove( previousDep );
- }
- else if ( !dependency.getScope().equals( previousDep.getScope() ) )
- {
- callback.updatedScope( dependency, previousDep.getScope() );
- it.remove();
- previousDependencies.remove( previousDep );
- }
- else if ( dependency.isOptional() != previousDep.isOptional() )
- {
- callback.updatedOptionalFlag( dependency, previousDep.isOptional() );
- it.remove();
- previousDependencies.remove( previousDep );
- }
- else
- {
- callback.updatedUnknown( dependency, previousDep );
- it.remove();
- previousDependencies.remove( previousDep );
- }
- }
- }
- for ( Dependency dependency : previousDependencies )
- {
- callback.removedDependency( dependency );
- }
- }
+
/**
* Registers the target file name for the specified artifact.
@@ -382,38 +280,6 @@
}
}
- /**
- * 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.
- * </p>
- *
- * @param dependency a dependency
- * @return the target file name of the last run for this dependency
- */
- public String getCachedTargetFileName( Dependency dependency )
- {
- if ( cache == null )
- {
- return null;
- }
- for ( DependencyInfo dependencyInfo : cache.getDependenciesInfo() )
- {
- final Dependency dependency2 = dependencyInfo.getDependency();
- if ( StringUtils.equals( dependency.getGroupId(), dependency2.getGroupId() )
- && StringUtils.equals( dependency.getArtifactId(), dependency2.getArtifactId() )
- && StringUtils.equals( dependency.getType(), dependency2.getType() )
- && StringUtils.equals( dependency.getClassifier(), dependency2.getClassifier() ) )
- {
-
- return dependencyInfo.getTargetFileName();
-
- }
- }
- return null;
- }
-
// Private helpers
private void doRegister( String id, String path )
@@ -422,45 +288,6 @@
getStructure( id ).add( path );
}
- /**
- * Find a dependency that is similar from the specified dependency.
- *
- * @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
- */
- private Dependency findDependency( Dependency dependency, List<Dependency> dependencies )
- {
- // CHECKSTYLE_OFF: LineLength
- for ( Dependency dep : dependencies )
- {
- 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() ) ) ) )
- {
- return dep;
- }
- }
- return null;
- // CHECKSTYLE_ON: LineLength
- }
-
- private Dependency matchDependency( List<Dependency> dependencies, Dependency dependency )
- {
- for ( Dependency dep : dependencies )
- {
- if ( WarUtils.dependencyEquals( dep, dependency ) )
- {
- return dep;
- }
-
- }
- return null;
- }
-
private List<DependencyInfo> createDependenciesInfoList( List<Dependency> dependencies )
{
if ( dependencies == null )
@@ -562,64 +389,4 @@
throws IOException;
}
- /**
- * Callback interface to handle events related to dependencies analysis.
- */
- public interface DependenciesAnalysisCallback
- {
-
- /**
- * Called if the dependency has not changed since the last build.
- *
- * @param dependency the dependency that hasn't changed
- */
- void unchangedDependency( Dependency dependency );
-
- /**
- * Called if a new dependency has been added since the last build.
- *
- * @param dependency the new dependency
- */
- void newDependency( Dependency dependency );
-
- /**
- * Called if the dependency has been removed since the last build.
- *
- * @param dependency the dependency that has been removed
- */
- void removedDependency( Dependency dependency );
-
- /**
- * Called if the version of the dependency has changed since the last build.
- *
- * @param dependency the dependency
- * @param previousVersion the previous version of the dependency
- */
- void updatedVersion( Dependency dependency, String previousVersion );
-
- /**
- * Called if the scope of the dependency has changed since the last build.
- *
- * @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.
- *
- * @param dependency the dependency
- * @param previousOptional the previous optional flag
- */
- void updatedOptionalFlag( Dependency dependency, boolean previousOptional );
-
- /**
- * Called if the dependency has been updated for unknown reason.
- *
- * @param dependency the dependency
- * @param previousDep the previous dependency
- */
- void updatedUnknown( Dependency dependency, Dependency previousDep );
-
- }
}
diff --git a/src/main/java/org/apache/maven/plugins/war/util/WebappStructureSerializer.java b/src/main/java/org/apache/maven/plugins/war/util/WebappStructureSerializer.java
deleted file mode 100644
index 28969a0..0000000
--- a/src/main/java/org/apache/maven/plugins/war/util/WebappStructureSerializer.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package org.apache.maven.plugins.war.util;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.thoughtworks.xstream.XStream;
-import static com.thoughtworks.xstream.XStream.PRIORITY_NORMAL;
-import static com.thoughtworks.xstream.XStream.PRIORITY_VERY_LOW;
-import com.thoughtworks.xstream.converters.basic.IntConverter;
-import com.thoughtworks.xstream.converters.basic.StringConverter;
-import com.thoughtworks.xstream.converters.collections.CollectionConverter;
-import com.thoughtworks.xstream.converters.collections.MapConverter;
-import com.thoughtworks.xstream.converters.reflection.ReflectionConverter;
-import com.thoughtworks.xstream.converters.reflection.ReflectionProvider;
-import com.thoughtworks.xstream.io.xml.DomDriver;
-import com.thoughtworks.xstream.mapper.Mapper;
-import org.apache.maven.model.Dependency;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.ReaderFactory;
-import org.codehaus.plexus.util.WriterFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
-
-/**
- * Serializes {@link WebappStructure} back and forth.
- *
- * @author Stephane Nicoll
- * @version $Id$
- */
-public class WebappStructureSerializer
-{
-
- private static final XStream XSTREAM;
-
- static
- {
- XSTREAM = new XStream( new DomDriver() )
- {
- @Override
- protected void setupConverters()
- {
- Mapper mapper = getMapper();
- ReflectionProvider reflectionProvider = getReflectionProvider();
- registerConverter(
- new ReflectionConverter( mapper, reflectionProvider ), PRIORITY_VERY_LOW );
- registerConverter( new StringConverter(), PRIORITY_NORMAL );
- registerConverter( new IntConverter(), PRIORITY_NORMAL );
- registerConverter( new CollectionConverter( mapper ), PRIORITY_NORMAL );
- registerConverter( new MapConverter( mapper ), PRIORITY_NORMAL );
- }
- };
- // Register aliases
- XSTREAM.alias( "webapp-structure", WebappStructure.class );
- XSTREAM.alias( "path-set", PathSet.class );
- XSTREAM.alias( "dependency", Dependency.class );
-
- }
-
- /**
- * Creates a new instance of the serializer.
- */
- public WebappStructureSerializer()
- {
- }
-
- /**
- * Reads the {@link WebappStructure} from the specified file.
- *
- * @param file the file containing the webapp structure
- * @return the webapp structure
- * @throws IOException if an error occurred while reading the structure
- */
- public WebappStructure fromXml( File file )
- throws IOException
- {
- Reader reader = null;
-
- try
- {
- reader = ReaderFactory.newXmlReader( file );
- final WebappStructure webappStructure = (WebappStructure) XSTREAM.fromXML( reader );
- reader.close();
- reader = null;
- return webappStructure;
- }
- finally
- {
- IOUtil.close( reader );
- }
- }
-
- /**
- * Saves the {@link WebappStructure} to the specified file.
- *
- * @param webappStructure the structure to save
- * @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 )
- throws IOException
- {
- // CHECKSTYLE_OFF: LineLength
- Writer writer = null;
- try
- {
- if ( !targetFile.getParentFile().exists() && !targetFile.getParentFile().mkdirs() )
- {
- throw new IOException( "Could not create parent [" + targetFile.getParentFile().getAbsolutePath() + "]" );
- }
-
- if ( !targetFile.exists() && !targetFile.createNewFile() )
- {
- throw new IOException( "Could not create file [" + targetFile.getAbsolutePath() + "]" );
- }
- writer = WriterFactory.newXmlWriter( targetFile );
- XSTREAM.toXML( webappStructure, writer );
- writer.close();
- writer = null;
- }
- finally
- {
- IOUtil.close( writer );
- }
- // CHECKSTYLE_ON: LineLength
- }
-}
diff --git a/src/site/apt/overlays.apt.vm b/src/site/apt/overlays.apt.vm
index 3b4c367..894c9de 100644
--- a/src/site/apt/overlays.apt.vm
+++ b/src/site/apt/overlays.apt.vm
@@ -347,24 +347,6 @@
</plugin>
</plugins>
...
-+-----------------+
-
- * <<useCache>> - set to <<<true>>> to enable the webapp structure cache. Default value is: <<<false>>>.
-
-+-----------------+
- ...
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <version>${project.version}</version>
- <configuration>
- <useCache>true</useCache>
- </configuration>
- </plugin>
- </plugins>
- ...
-+-----------------+
* Zip dependencies with overlays
diff --git a/src/test/java/org/apache/maven/plugins/war/AbstractWarMojoTest.java b/src/test/java/org/apache/maven/plugins/war/AbstractWarMojoTest.java
index 2afe122..3111696 100644
--- a/src/test/java/org/apache/maven/plugins/war/AbstractWarMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/war/AbstractWarMojoTest.java
@@ -68,7 +68,6 @@
throws Exception
{
setVariableValueToObject( mojo, "filters", filters );
- setVariableValueToObject( mojo, "useCache", Boolean.FALSE );
setVariableValueToObject( mojo, "mavenFileFilter", lookup( MavenFileFilter.class.getName() ) );
setVariableValueToObject( mojo, "useJvmChmod", Boolean.TRUE );
diff --git a/src/test/java/org/apache/maven/plugins/war/WarDependenciesAnalysisTest.java b/src/test/java/org/apache/maven/plugins/war/WarDependenciesAnalysisTest.java
deleted file mode 100644
index dc103bf..0000000
--- a/src/test/java/org/apache/maven/plugins/war/WarDependenciesAnalysisTest.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package org.apache.maven.plugins.war;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.handler.ArtifactHandler;
-import org.apache.maven.plugin.testing.stubs.ArtifactStub;
-import org.apache.maven.plugins.war.stub.JarArtifactStub;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Stephane Nicoll
- */
-public class WarDependenciesAnalysisTest
- extends AbstractWarExplodedMojoTest
-{
- protected File getPomFile()
- {
- return new File( getBasedir(), "/target/test-classes/unit/dependencies/default.xml" );
- }
-
- protected File getTestDirectory()
- {
- return new File( getBasedir(), "target/test-classes/unit/dependenciesanalysis/test-dir" );
- }
-
- public void testNoChange()
- throws Exception
- {
- // setup test data
- final String testId = "no-change";
- final ArtifactHandler artifactHandler = (ArtifactHandler) lookup( ArtifactHandler.ROLE, "jar" );
- ArtifactStub jarArtifact = new JarArtifactStub( getBasedir(), artifactHandler );
- 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" } );
-
- }
-
- public void testRemovedDependency()
- throws Exception
- {
- // setup test data
- final String testId = "remove-dependency";
- final ArtifactHandler artifactHandler = (ArtifactHandler) lookup( ArtifactHandler.ROLE, "jar" );
- ArtifactStub jarArtifact = new JarArtifactStub( getBasedir(), artifactHandler );
- 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 );
-
- }
-
- public void testDependencyWithUpdatedVersion()
- throws Exception
- {
- // setup test data
- final String testId = "dependency-update-version";
- final ArtifactHandler artifactHandler = (ArtifactHandler) lookup( ArtifactHandler.ROLE, "jar" );
- ArtifactStub jarArtifact = new JarArtifactStub( getBasedir(), artifactHandler );
- jarArtifact.setArtifactId( "lib-test" );
- jarArtifact.setVersion( "1.0" );
-
- ArtifactStub jarArtifact2 = new JarArtifactStub( getBasedir(), artifactHandler );
- 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" } );
-
- }
-
- public void testDependencyNowProvided()
- throws Exception
- {
- // setup test data
- final String testId = "dependency-now-provided";
- final ArtifactHandler artifactHandler = (ArtifactHandler) lookup( ArtifactHandler.ROLE, "jar" );
- ArtifactStub jarArtifact = new JarArtifactStub( getBasedir(), artifactHandler );
- jarArtifact.setArtifactId( "lib-test" );
- jarArtifact.setVersion( "1.0" );
-
- ArtifactStub jarArtifact2 = new JarArtifactStub( getBasedir(), artifactHandler );
- jarArtifact2.setArtifactId( "lib-test" );
- 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 );
-
- }
-
- protected void doTestTwiceWithUpdatedDependency( String testId, ArtifactStub[] firstStubs,
- ArtifactStub[] secondStubs, String[] firstCustomContent,
- String[] secondCustomContent )
- throws Exception
- {
- // setup test data
- final File xmlSource = createXMLConfigDir( testId, new String[] { "web.xml" } );
- final File webAppDirectory = setUpMojoWithCache( testId, firstStubs );
- try
- {
- mojo.setWebXml( new File( xmlSource, "web.xml" ) );
- mojo.execute();
-
- final List<File> assertedFiles = new ArrayList<File>();
- assertedFiles.addAll( assertDefaultContent( webAppDirectory ) );
- assertedFiles.addAll( assertWebXml( webAppDirectory ) );
- 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 } );
- assertWebAppContent( webAppDirectory, assertedFiles, filter );
-
- // Run the thing again and check it's ok
- setUpMojoWithCache( testId, secondStubs );
-
- mojo.execute();
-
- final List<File> assertedFiles2 = new ArrayList<File>();
- assertedFiles2.addAll( assertDefaultContent( webAppDirectory ) );
- assertedFiles2.addAll( assertWebXml( webAppDirectory ) );
- if ( secondCustomContent != null )
- {
- assertedFiles2.addAll( assertCustomContent( webAppDirectory, secondCustomContent, "library not found" ) );
-
- }
- assertWebAppContent( webAppDirectory, assertedFiles2, filter );
-
- }
- finally
- {
- cleanDirectory( webAppDirectory );
- cleanDirectory( mojo.getWorkDirectory() );
-
- }
- }
-
- /**
- * Configures the exploded mojo for the specified 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
- */
- protected File setUpMojoWithCache( final String testId, ArtifactStub[] artifactStubs )
- throws Exception
- {
- final File webappDir = setUpMojo( testId, artifactStubs, null );
- setVariableValueToObject( mojo, "useCache", Boolean.TRUE );
- final File cacheFile = new File( mojo.getWorkDirectory(), "webapp-cache.xml" );
- setVariableValueToObject( mojo, "cacheFile", cacheFile );
-
- return webappDir;
- }
-
-}
diff --git a/src/test/java/org/apache/maven/plugins/war/WarOverlaysTest.java b/src/test/java/org/apache/maven/plugins/war/WarOverlaysTest.java
index 295c6be..791c3aa 100644
--- a/src/test/java/org/apache/maven/plugins/war/WarOverlaysTest.java
+++ b/src/test/java/org/apache/maven/plugins/war/WarOverlaysTest.java
@@ -443,116 +443,6 @@
}
- public void testCacheWithUpdatedOverlay()
- throws Exception
- {
- // setup test data
- final String testId = "cache-updated-overlay";
-
- // Add an overlay
- final ArtifactStub overlay = buildWarOverlayStub( "overlay-one" );
- final ArtifactStub overlay2 = buildWarOverlayStub( "overlay-two" );
-
- final File webAppDirectory = setUpMojo( testId, new ArtifactStub[] { overlay, overlay2 } );
- final List<File> assertedFiles = new ArrayList<File>();
- try
- {
- // Use the cache
- setVariableValueToObject( mojo, "useCache", Boolean.TRUE );
- setVariableValueToObject( mojo, "cacheFile", new File( mojo.getWorkDirectory(), "cache.xml" ) );
-
- final LinkedList<Overlay> overlays = new LinkedList<Overlay>();
- overlays.add( new DefaultOverlay( overlay ) );
- overlays.add( new DefaultOverlay( overlay2 ) );
- mojo.setOverlays( overlays );
-
- mojo.execute();
-
- // Now change the overlay order and make sure the right file is overwritten
- final LinkedList<Overlay> updatedOverlays = new LinkedList<Overlay>();
- updatedOverlays.add( new DefaultOverlay( overlay2 ) );
- updatedOverlays.add( new DefaultOverlay( overlay ) );
- mojo.setOverlays( updatedOverlays );
-
- 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" ) );
-
- // index and login come from overlay2 now
- assertOverlayedFile( webAppDirectory, "overlay-two", "index.jsp" );
- assertOverlayedFile( webAppDirectory, "overlay-one", "login.jsp" );
- 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 } );
- assertWebAppContent( webAppDirectory, assertedFiles, filter );
- }
- finally
- {
- cleanDirectory( webAppDirectory );
- }
- }
-
- public void testCacheWithRemovedOverlay()
- throws Exception
- {
- // setup test data
- final String testId = "cache-removed-overlay";
-
- // Add an overlay
- final ArtifactStub overlay = buildWarOverlayStub( "overlay-one" );
- final ArtifactStub overlay2 = buildWarOverlayStub( "overlay-two" );
-
- final File webAppDirectory = setUpMojo( testId, new ArtifactStub[] { overlay, overlay2 } );
- final List<File> assertedFiles = new ArrayList<>();
- try
- {
- // Use the cache
- setVariableValueToObject( mojo, "useCache", Boolean.TRUE );
- setVariableValueToObject( mojo, "cacheFile", new File( mojo.getWorkDirectory(), "cache.xml" ) );
-
- final LinkedList<Overlay> overlays = new LinkedList<>();
- overlays.add( new DefaultOverlay( overlay ) );
- overlays.add( new DefaultOverlay( overlay2 ) );
- mojo.setOverlays( overlays );
-
- mojo.execute();
-
- // Now remove overlay one the right file is overwritten
- final LinkedList<Overlay> updatedOverlays = new LinkedList<>();
- updatedOverlays.add( new DefaultOverlay( overlay2 ) );
- mojo.setOverlays( updatedOverlays );
-
- // Remove overlay one as a dep
- mojo.getProject().getArtifacts().remove( overlay );
-
- mojo.execute();
-
- assertedFiles.addAll( assertDefaultContent( webAppDirectory ) );
- assertedFiles.addAll( assertWebXml( webAppDirectory ) );
-
- // MWAR-427: looks like cache has unwanted side effects
- 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" );
-// assertOverlayedFile( webAppDirectory, "overlay-one", "login.jsp" );
- 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 } );
- assertWebAppContent( webAppDirectory, assertedFiles, filter );
- }
- finally
- {
- cleanDirectory( webAppDirectory );
- }
- }
-
// Helpers
/**
diff --git a/src/test/java/org/apache/maven/plugins/war/util/WebappStructureTest.java b/src/test/java/org/apache/maven/plugins/war/util/WebappStructureTest.java
index b4cd051..0e135de 100644
--- a/src/test/java/org/apache/maven/plugins/war/util/WebappStructureTest.java
+++ b/src/test/java/org/apache/maven/plugins/war/util/WebappStructureTest.java
@@ -25,7 +25,6 @@
import org.apache.maven.plugins.war.util.WebappStructure;
import java.util.ArrayList;
-import java.util.List;
/**
* @author Stephane Nicoll
@@ -33,196 +32,6 @@
public class WebappStructureTest
extends TestCase
{
-
-
- public void testDependencyAnalysisNoChange()
- {
- final List<Dependency> dependencies = new ArrayList<Dependency>();
- dependencies.add( createDependency( "groupTest", "artifactTest", "1.0" ) );
- final WebappStructure cache = new WebappStructure( dependencies );
-
- final WebappStructure webappStructure = new WebappStructure( dependencies, cache );
-
- webappStructure.analyseDependencies( new WebappStructure.DependenciesAnalysisCallback()
- {
-
- int count = 0;
-
- public void unchangedDependency( Dependency dependency )
- {
- if ( count == 0 )
- {
- count++;
- }
- else
- {
- fail( "Should have called unchanged dependency only once" );
- }
- }
-
- public void newDependency( Dependency dependency )
- {
- fail( "Should have failed to trigger this callback" );
- }
-
- public void removedDependency( Dependency dependency )
- {
- fail( "Should have failed to trigger this callback" );
- }
-
- public void updatedVersion( Dependency dependency, String previousVersion )
- {
- fail( "Should have failed to trigger this callback" );
- }
-
- public void updatedScope( Dependency dependency, String previousScope )
- {
- fail( "Should have failed to trigger this callback" );
- }
-
- public void updatedOptionalFlag( Dependency dependency, boolean previousOptional )
- {
- fail( "Should have failed to trigger this callback" );
- }
-
- public void updatedUnknown( Dependency dependency, Dependency previousDep )
- {
- fail( "Should have failed to trigger this callback" );
- }
- } );
-
- }
-
-
- public void testDependencyAnalysisWithNewDependency()
- {
- final List<Dependency> dependencies = new ArrayList<Dependency>();
- dependencies.add( createDependency( "groupTest", "artifactTest", "1.0" ) );
- final WebappStructure cache = new WebappStructure( dependencies );
- final List<Dependency> newDependencies = new ArrayList<Dependency>( dependencies );
- final Dependency newDependency = createDependency( "groupTest", "nexArtifact", "2.0" );
- newDependencies.add( newDependency );
-
- final WebappStructure webappStructure = new WebappStructure( newDependencies, cache );
-
- webappStructure.analyseDependencies( new WebappStructure.DependenciesAnalysisCallback()
- {
-
- int count = 0;
-
- public void unchangedDependency( Dependency dependency )
- {
- if ( count == 0 )
- {
- count++;
- }
- else
- {
- fail( "Should have called unchanged dependency only once" );
- }
- }
-
- public void newDependency( Dependency dependency )
- {
- if ( !newDependency.equals( dependency ) )
- {
- fail( "Called new dependency with an unexpected dependency " + dependency );
- }
- }
-
- public void removedDependency( Dependency dependency )
- {
- fail( "Should have failed to trigger this callback" );
- }
-
- public void updatedVersion( Dependency dependency, String previousVersion )
- {
- fail( "Should have failed to trigger this callback" );
- }
-
- public void updatedScope( Dependency dependency, String previousScope )
- {
- fail( "Should have failed to trigger this callback" );
- }
-
- public void updatedOptionalFlag( Dependency dependency, boolean previousOptional )
- {
- fail( "Should have failed to trigger this callback" );
- }
-
- public void updatedUnknown( Dependency dependency, Dependency previousDep )
- {
- fail( "Should have failed to trigger this callback" );
- }
- } );
-
- }
-
- public void testDependencyAnalysisWithRemovedDependency()
- {
- final List<Dependency> dependencies = new ArrayList<Dependency>();
- dependencies.add( createDependency( "groupTest", "artifactTest", "1.0" ) );
- final Dependency removedDependency = createDependency( "groupTest", "removedDep", "5.2" );
- dependencies.add( removedDependency );
- final WebappStructure cache = new WebappStructure( dependencies );
-
- final List<Dependency> newDependencies = new ArrayList<Dependency>( dependencies );
- newDependencies.remove( removedDependency );
- final WebappStructure webappStructure = new WebappStructure( newDependencies, cache );
-
- webappStructure.analyseDependencies( new WebappStructure.DependenciesAnalysisCallback()
- {
-
- int count = 0;
-
- public void unchangedDependency( Dependency dependency )
- {
- if ( count == 0 )
- {
- count++;
- }
- else
- {
- fail( "Should have called unchanged dependency only once" );
- }
- }
-
- public void newDependency( Dependency dependency )
- {
- fail( "Should have failed to trigger this callback" );
- }
-
- public void removedDependency( Dependency dependency )
- {
- if ( !removedDependency.equals( dependency ) )
- {
- fail( "Called removed dependency with an unexpected dependency " + dependency );
- }
- }
-
- public void updatedVersion( Dependency dependency, String previousVersion )
- {
- fail( "Should have failed to trigger this callback" );
- }
-
- public void updatedScope( Dependency dependency, String previousScope )
- {
- fail( "Should have failed to trigger this callback" );
- }
-
- public void updatedOptionalFlag( Dependency dependency, boolean previousOptional )
- {
- fail( "Should have failed to trigger this callback" );
- }
-
- public void updatedUnknown( Dependency dependency, Dependency previousDep )
- {
- fail( "Should have failed to trigger this callback" );
- }
- } );
-
- }
-
public void testUnknownFileNotAvailable()
{
final WebappStructure structure = new WebappStructure( new ArrayList<Dependency>() );
@@ -234,7 +43,6 @@
final WebappStructure structure = new WebappStructure( new ArrayList<Dependency>() );
structure.registerFile( "overlay1", "WEB-INF/web.xml" );
assertFalse( structure.registerFile( "currentBuild", "WEB-INF/web.xml" ) );
-
}
public void testRegisterForced()
diff --git a/src/test/resources/unit/dependencies/default.xml b/src/test/resources/unit/dependencies/default.xml
deleted file mode 100644
index 90164a8..0000000
--- a/src/test/resources/unit/dependencies/default.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project>
- <name>war-plugin-test</name>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <useCache>true</useCache>
-
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>