Author: jdcasey Date: Mon Jul 31 09:45:27 2006 New Revision: 427165 URL: http://svn.apache.org/viewvc?rev=427165&view=rev Log: Adding more tests, and tweaking artifact filtering to report on unused patterns.
Added: maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/StatisticsReportingFilter.java (with props) maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/phase/ maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/phase/DependencySetAssemblyPhaseTest.java (with props) Modified: maven/plugins/branches/MASSEMBLY-124/pom.xml maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/phase/DependencySetAssemblyPhase.java maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/phase/FileSetAssemblyPhase.java maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/phase/ModuleSetAssemblyPhase.java maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTask.java maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyExcludesArtifactFilter.java maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyIncludesArtifactFilter.java maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReader.java maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/mojos/UnpackMojo.java maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/utils/FilterUtils.java maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/utils/ProjectUtils.java maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/FilterUtilsTest.java maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/ProjectUtilsTest.java Modified: maven/plugins/branches/MASSEMBLY-124/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/pom.xml?rev=427165&r1=427164&r2=427165&view=diff ============================================================================== --- maven/plugins/branches/MASSEMBLY-124/pom.xml (original) +++ maven/plugins/branches/MASSEMBLY-124/pom.xml Mon Jul 31 09:45:27 2006 @@ -119,10 +119,15 @@ <artifactId>plexus-archiver</artifactId> <version>1.0-alpha-7-SNAPSHOT</version> </dependency> + <!-- FIXME: upgrade to p-u 1.3 when available, to fix + workaround in DefaultAssemblyReader for NPE caused + by DirectoryScanner.scandir(..) and UnixFileSystem's + implementation of File.list(). + --> <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> - <version>1.1</version> + <version>1.2</version> </dependency> <dependency> <groupId>org.apache.maven</groupId> Modified: maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/phase/DependencySetAssemblyPhase.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/phase/DependencySetAssemblyPhase.java?rev=427165&r1=427164&r2=427165&view=diff ============================================================================== --- maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/phase/DependencySetAssemblyPhase.java (original) +++ maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/phase/DependencySetAssemblyPhase.java Mon Jul 31 09:45:27 2006 @@ -14,14 +14,12 @@ import org.apache.maven.plugin.assembly.format.AssemblyFormattingException; import org.apache.maven.plugin.assembly.utils.AssemblyFormatUtils; import org.apache.maven.plugin.assembly.utils.FilterUtils; -import org.apache.maven.plugin.assembly.utils.ProjectUtils; import org.apache.maven.plugins.assembly.model.Assembly; import org.apache.maven.plugins.assembly.model.DependencySet; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.archiver.Archiver; import org.codehaus.plexus.logging.AbstractLogEnabled; - /** * @plexus.component role="org.apache.maven.plugin.assembly.archive.phase.AssemblyArchiverPhase" * role-hint="dependency-sets" @@ -35,62 +33,69 @@ throws ArchiveCreationException, AssemblyFormattingException { List dependencySets = assembly.getDependencySets(); - MavenProject project = configSource.getProject(); boolean includeBaseDirectory = assembly.isIncludeBaseDirectory(); for ( Iterator i = dependencySets.iterator(); i.hasNext(); ) { DependencySet dependencySet = (DependencySet) i.next(); - String output = dependencySet.getOutputDirectory(); - output = AssemblyFormatUtils.getOutputDirectory( output, project, configSource.getFinalName(), - includeBaseDirectory ); + + addDependencySet( dependencySet, archiver, configSource, includeBaseDirectory ); + } + } + + protected void addDependencySet( DependencySet dependencySet, Archiver archiver, + AssemblerConfigurationSource configSource, boolean includeBaseDirectory ) + throws AssemblyFormattingException, ArchiveCreationException + { + MavenProject project = configSource.getProject(); + + String destDirectory = dependencySet.getOutputDirectory(); + + destDirectory = AssemblyFormatUtils.getOutputDirectory( destDirectory, project, configSource.getFinalName(), + includeBaseDirectory ); + + getLogger().info( "Processing DependencySet" ); + + Set dependencyArtifacts = getDependencyArtifacts( project, dependencySet ); + + for ( Iterator j = dependencyArtifacts.iterator(); j.hasNext(); ) + { + Artifact artifact = (Artifact) j.next(); + + String fileNameMapping = AssemblyFormatUtils.evaluateFileNameMapping( dependencySet + .getOutputFileNameMapping(), artifact ); + + String outputLocation = destDirectory + fileNameMapping; + + AddArtifactTask task = new AddArtifactTask( artifact, outputLocation ); int dirMode = Integer.parseInt( dependencySet.getDirectoryMode(), 8 ); int fileMode = Integer.parseInt( dependencySet.getFileMode(), 8 ); - getLogger().debug( - "DependencySet[" + output + "]" + " dir perms: " - + Integer.toString( archiver.getDefaultDirectoryMode(), 8 ) + " file perms: " - + Integer.toString( archiver.getDefaultFileMode(), 8 ) ); - - Set allDependencyArtifacts = ProjectUtils.getDependencies( project ); - Set dependencyArtifacts = new HashSet( allDependencyArtifacts ); - - AssemblyScopeArtifactFilter scopeFilter = new AssemblyScopeArtifactFilter( dependencySet.getScope() ); - - FilterUtils.filterArtifacts( dependencyArtifacts, dependencySet.getIncludes(), dependencySet.getExcludes(), - true, Collections.singletonList( scopeFilter ) ); - - for ( Iterator j = dependencyArtifacts.iterator(); j.hasNext(); ) - { - Artifact artifact = (Artifact) j.next(); - - String fileNameMapping = AssemblyFormatUtils.evaluateFileNameMapping( dependencySet - .getOutputFileNameMapping(), artifact ); - - String outputLocation = output + fileNameMapping; - - AddArtifactTask task = new AddArtifactTask( artifact, outputLocation ); - - task.setDirectoryMode( dirMode ); - task.setFileMode( fileMode ); - task.setUnpack( dependencySet.isUnpack() ); - - task.execute( archiver, configSource ); - } - - allDependencyArtifacts.removeAll( dependencyArtifacts ); - - for ( Iterator it = allDependencyArtifacts.iterator(); it.hasNext(); ) - { - Artifact artifact = (Artifact) it.next(); - - // would be better to have a way to find out when a specified - // include or exclude - // is never triggered and warn() it. - getLogger().debug( "artifact: " + artifact + " not included" ); - } + task.setDirectoryMode( dirMode ); + task.setFileMode( fileMode ); + task.setUnpack( dependencySet.isUnpack() ); + + task.execute( archiver, configSource ); + } + } + + protected Set getDependencyArtifacts( MavenProject project, DependencySet dependencySet ) + { + Set dependencyArtifacts = new HashSet(); + + Set projectArtifacts = project.getArtifacts(); + if ( projectArtifacts != null ) + { + dependencyArtifacts.addAll( projectArtifacts ); } + + AssemblyScopeArtifactFilter scopeFilter = new AssemblyScopeArtifactFilter( dependencySet.getScope() ); + + FilterUtils.filterArtifacts( dependencyArtifacts, dependencySet.getIncludes(), dependencySet.getExcludes(), + true, Collections.singletonList( scopeFilter ), getLogger() ); + + return dependencyArtifacts; } } Modified: maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/phase/FileSetAssemblyPhase.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/phase/FileSetAssemblyPhase.java?rev=427165&r1=427164&r2=427165&view=diff ============================================================================== --- maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/phase/FileSetAssemblyPhase.java (original) +++ maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/phase/FileSetAssemblyPhase.java Mon Jul 31 09:45:27 2006 @@ -23,6 +23,7 @@ AddFileSetsTask task = new AddFileSetsTask( assembly.getFileSets() ); task.setLogger( getLogger() ); + task.setIncludeBaseDirectory( assembly.isIncludeBaseDirectory() ); task.execute( archiver, configSource ); } Modified: maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/phase/ModuleSetAssemblyPhase.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/phase/ModuleSetAssemblyPhase.java?rev=427165&r1=427164&r2=427165&view=diff ============================================================================== --- maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/phase/ModuleSetAssemblyPhase.java (original) +++ maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/phase/ModuleSetAssemblyPhase.java Mon Jul 31 09:45:27 2006 @@ -137,7 +137,7 @@ List excludes = binaries.getExcludes(); FilterUtils.filterArtifacts( binaryDependencies, includes, excludes, true, - Collections.EMPTY_LIST ); + Collections.EMPTY_LIST, getLogger() ); for ( Iterator binDepIterator = binaryDependencies.iterator(); binDepIterator.hasNext(); ) { @@ -164,6 +164,7 @@ AddFileSetsTask task = new AddFileSetsTask( moduleFileSets ); task.setLogger( getLogger() ); + task.setIncludeBaseDirectory( includeBaseDirectory ); task.execute( archiver, configSource ); } Modified: maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTask.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTask.java?rev=427165&r1=427164&r2=427165&view=diff ============================================================================== --- maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTask.java (original) +++ maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTask.java Mon Jul 31 09:45:27 2006 @@ -21,6 +21,8 @@ { private final List fileSets; + + private boolean includeBaseDirectory = false; private Logger logger; @@ -89,7 +91,7 @@ } destDirectory = AssemblyFormatUtils.getOutputDirectory( destDirectory, project, configSource.getFinalName(), - false ); + includeBaseDirectory ); logger.debug( "The archive base directory is '" + archiveBaseDir.getAbsolutePath() + "'" ); @@ -161,6 +163,11 @@ public void setLogger( Logger logger ) { this.logger = logger; + } + + public void setIncludeBaseDirectory( boolean includeBaseDirectory ) + { + this.includeBaseDirectory = includeBaseDirectory; } } Modified: maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyExcludesArtifactFilter.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyExcludesArtifactFilter.java?rev=427165&r1=427164&r2=427165&view=diff ============================================================================== --- maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyExcludesArtifactFilter.java (original) +++ maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyExcludesArtifactFilter.java Mon Jul 31 09:45:27 2006 @@ -42,4 +42,9 @@ { return !super.include( artifact ); } + + protected String getFilterDescription() + { + return "artifact exclusion filter"; + } } Modified: maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyIncludesArtifactFilter.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyIncludesArtifactFilter.java?rev=427165&r1=427164&r2=427165&view=diff ============================================================================== --- maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyIncludesArtifactFilter.java (original) +++ maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/AssemblyIncludesArtifactFilter.java Mon Jul 31 09:45:27 2006 @@ -19,11 +19,15 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; +import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.StringUtils; +import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; /** * TODO: include in maven-artifact in future @@ -31,10 +35,12 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a> */ public class AssemblyIncludesArtifactFilter - implements ArtifactFilter + implements ArtifactFilter, StatisticsReportingFilter { private final List patterns; private final boolean actTransitively; + + private Set patternsTriggered = new HashSet(); public AssemblyIncludesArtifactFilter( List patterns ) { @@ -67,6 +73,12 @@ { matched = true; } + + if ( matched ) + { + patternsTriggered.add( pattern ); + break; + } } if ( !matched && actTransitively ) @@ -83,6 +95,8 @@ if ( trailStr.indexOf( pattern ) > -1 ) { matched = true; + + patternsTriggered.add( pattern ); break; } } @@ -90,5 +104,40 @@ } return matched; + } + + public void reportMissedCriteria( Logger logger ) + { + // if there are no patterns, there is nothing to report. + if ( !patterns.isEmpty() ) + { + List missed = new ArrayList( patterns ); + missed.removeAll( patternsTriggered ); + + if ( !missed.isEmpty() && logger.isWarnEnabled() ) + { + StringBuffer buffer = new StringBuffer(); + + buffer.append( "The following patterns were never triggered in this " ); + buffer.append( getFilterDescription() ); + buffer.append( ':' ); + + for ( Iterator it = missed.iterator(); it.hasNext(); ) + { + String pattern = (String) it.next(); + + buffer.append( "\no \'" ).append( pattern ).append( "\'" ); + } + + buffer.append( "\n" ); + + logger.warn( buffer.toString() ); + } + } + } + + protected String getFilterDescription() + { + return "artifact inclusion filter"; } } Added: maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/StatisticsReportingFilter.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/StatisticsReportingFilter.java?rev=427165&view=auto ============================================================================== --- maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/StatisticsReportingFilter.java (added) +++ maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/StatisticsReportingFilter.java Mon Jul 31 09:45:27 2006 @@ -0,0 +1,10 @@ +package org.apache.maven.plugin.assembly.filter; + +import org.codehaus.plexus.logging.Logger; + +public interface StatisticsReportingFilter +{ + + void reportMissedCriteria( Logger logger ); + +} Propchange: maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/StatisticsReportingFilter.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/filter/StatisticsReportingFilter.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Modified: maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReader.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReader.java?rev=427165&r1=427164&r2=427165&view=diff ============================================================================== --- maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReader.java (original) +++ maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReader.java Mon Jul 31 09:45:27 2006 @@ -29,6 +29,7 @@ import java.io.InputStreamReader; import java.io.Reader; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -82,7 +83,34 @@ { try { - List descriptorList = FileUtils.getFiles( descriptorSourceDirectory, "**/*.xml", null ); + List descriptorList; + + try + { + descriptorList = FileUtils.getFiles( descriptorSourceDirectory, "**/*.xml", null ); + } + // FIXME: plexus-utils >= 1.3-SNAPSHOT should fix this. + catch ( NullPointerException e ) + { + StackTraceElement frameZero = e.getStackTrace()[0]; + + if ( "org.codehaus.plexus.util.DirectoryScanner".equals( frameZero.getClassName() ) + && "scandir".equals( frameZero.getMethodName() ) ) + { + if ( getLogger().isDebugEnabled() ) + { + getLogger().debug( + "Caught filesystem error while scanning directories..." + + "using zero-length list as the result.", e ); + } + + descriptorList = Collections.EMPTY_LIST; + } + else + { + throw e; + } + } for ( Iterator iter = descriptorList.iterator(); iter.hasNext(); ) { Modified: maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/mojos/UnpackMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/mojos/UnpackMojo.java?rev=427165&r1=427164&r2=427165&view=diff ============================================================================== --- maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/mojos/UnpackMojo.java (original) +++ maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/mojos/UnpackMojo.java Mon Jul 31 09:45:27 2006 @@ -17,7 +17,9 @@ */ import java.io.File; +import java.util.HashSet; import java.util.Iterator; +import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.AbstractMojo; @@ -25,7 +27,6 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.assembly.archive.ArchiveExpansionException; import org.apache.maven.plugin.assembly.utils.AssemblyFileUtils; -import org.apache.maven.plugin.assembly.utils.ProjectUtils; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.archiver.manager.ArchiverManager; import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; @@ -69,7 +70,20 @@ public void execute() throws MojoExecutionException, MojoFailureException { - for ( Iterator j = ProjectUtils.getDependencies( project ).iterator(); j.hasNext(); ) + Set dependencies = new HashSet(); + + if ( project.getArtifact() != null && project.getArtifact().getFile() != null ) + { + dependencies.add( project.getArtifact() ); + } + + Set projectArtifacts = project.getArtifacts(); + if ( projectArtifacts != null ) + { + dependencies.addAll( projectArtifacts ); + } + + for ( Iterator j = dependencies.iterator(); j.hasNext(); ) { Artifact artifact = (Artifact) j.next(); Modified: maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/utils/FilterUtils.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/utils/FilterUtils.java?rev=427165&r1=427164&r2=427165&view=diff ============================================================================== --- maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/utils/FilterUtils.java (original) +++ maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/utils/FilterUtils.java Mon Jul 31 09:45:27 2006 @@ -1,5 +1,6 @@ package org.apache.maven.plugin.assembly.utils; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -9,11 +10,13 @@ import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.plugin.assembly.filter.AssemblyExcludesArtifactFilter; import org.apache.maven.plugin.assembly.filter.AssemblyIncludesArtifactFilter; +import org.apache.maven.plugin.assembly.filter.StatisticsReportingFilter; import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.logging.Logger; public final class FilterUtils { - + private FilterUtils() { } @@ -30,12 +33,12 @@ { filter.add( new AssemblyExcludesArtifactFilter( excludes, actTransitively ) ); } - + for ( Iterator it = projects.iterator(); it.hasNext(); ) { MavenProject project = (MavenProject) it.next(); Artifact artifact = project.getArtifact(); - + if ( !filter.include( artifact ) ) { it.remove(); @@ -43,36 +46,67 @@ } } - public static void filterArtifacts( Set artifacts, List includes, List excludes, boolean actTransitively, List additionalFilters ) + public static void filterArtifacts( Set artifacts, List includes, List excludes, boolean actTransitively, + List additionalFilters, Logger logger ) { - AndArtifactFilter filter = new AndArtifactFilter(); + List allFilters = new ArrayList(); + AndArtifactFilter filter = new AndArtifactFilter(); + if ( additionalFilters != null && !additionalFilters.isEmpty() ) { for ( Iterator it = additionalFilters.iterator(); it.hasNext(); ) { ArtifactFilter additionalFilter = (ArtifactFilter) it.next(); - + filter.add( additionalFilter ); } } if ( !includes.isEmpty() ) { - filter.add( new AssemblyIncludesArtifactFilter( includes, actTransitively ) ); + ArtifactFilter includeFilter = new AssemblyIncludesArtifactFilter( includes, actTransitively ); + + filter.add( includeFilter ); + + allFilters.add( includeFilter ); } if ( !excludes.isEmpty() ) { - filter.add( new AssemblyExcludesArtifactFilter( excludes, actTransitively ) ); + ArtifactFilter excludeFilter = new AssemblyExcludesArtifactFilter( excludes, actTransitively ); + + filter.add( excludeFilter ); + + allFilters.add( excludeFilter ); + } + + if ( !additionalFilters.isEmpty() ) + { + allFilters.addAll( additionalFilters ); } for ( Iterator it = artifacts.iterator(); it.hasNext(); ) { Artifact artifact = (Artifact) it.next(); - + if ( !filter.include( artifact ) ) { it.remove(); + + if ( logger.isDebugEnabled() ) + { + logger.debug( artifact.getId() + " was removed by one or more filters." ); + } + } + } + + for ( Iterator it = allFilters.iterator(); it.hasNext(); ) + { + ArtifactFilter f = (ArtifactFilter) it.next(); + + if ( f instanceof StatisticsReportingFilter ) + { + ((StatisticsReportingFilter) f).reportMissedCriteria( logger ); } } } Modified: maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/utils/ProjectUtils.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/utils/ProjectUtils.java?rev=427165&r1=427164&r2=427165&view=diff ============================================================================== --- maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/utils/ProjectUtils.java (original) +++ maven/plugins/branches/MASSEMBLY-124/src/main/java/org/apache/maven/plugin/assembly/utils/ProjectUtils.java Mon Jul 31 09:45:27 2006 @@ -17,29 +17,6 @@ { } - /** - * Retrieves all artifact dependencies. - * - * @return A HashSet of artifacts - */ - public static Set getDependencies( MavenProject project ) - { - Set dependenciesSet = new HashSet(); - - if ( project.getArtifact() != null && project.getArtifact().getFile() != null ) - { - dependenciesSet.add( project.getArtifact() ); - } - - Set projectArtifacts = project.getArtifacts(); - if ( projectArtifacts != null ) - { - dependenciesSet.addAll( projectArtifacts ); - } - - return dependenciesSet; - } - public static Set getProjectModules( MavenProject project, List reactorProjects, Logger logger ) throws IOException { Added: maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/phase/DependencySetAssemblyPhaseTest.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/phase/DependencySetAssemblyPhaseTest.java?rev=427165&view=auto ============================================================================== --- maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/phase/DependencySetAssemblyPhaseTest.java (added) +++ maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/phase/DependencySetAssemblyPhaseTest.java Mon Jul 31 09:45:27 2006 @@ -0,0 +1,147 @@ +package org.apache.maven.plugin.assembly.archive.phase; + +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import junit.framework.TestCase; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.model.Model; +import org.apache.maven.plugin.assembly.testutils.MockManager; +import org.apache.maven.plugins.assembly.model.DependencySet; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.logging.Logger; +import org.codehaus.plexus.logging.console.ConsoleLogger; +import org.easymock.MockControl; + +public class DependencySetAssemblyPhaseTest + extends TestCase +{ + + private MockManager mockManager = new MockManager(); + + public void testGetDependencyArtifacts_ShouldGetOneDependencyArtifact() + { + MavenProject project = new MavenProject( new Model() ); + + ArtifactMockAndControl mac = new ArtifactMockAndControl(); + + mac.enableGetScope( Artifact.SCOPE_COMPILE ); + + project.setArtifacts( Collections.singleton( mac.artifact ) ); + + DependencySet dependencySet = new DependencySet(); + + DependencySetAssemblyPhase phase = new DependencySetAssemblyPhase(); + phase.enableLogging( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) ); + + mockManager.replayAll(); + + Set result = phase.getDependencyArtifacts( project, dependencySet ); + + assertNotNull( result ); + assertEquals( 1, result.size() ); + assertSame( mac.artifact, result.iterator().next() ); + + mockManager.verifyAll(); + } + + public void testGetDependencyArtifacts_ShouldFilterOneDependencyArtifactViaInclude() + { + MavenProject project = new MavenProject( new Model() ); + + Set artifacts = new HashSet(); + + ArtifactMockAndControl mac = new ArtifactMockAndControl(); + + mac.enableGetGroupId( "group" ); + mac.enableGetArtifactId( "artifact" ); + mac.enableGetDependencyConflictId( "group:artifact:jar" ); + mac.enableGetScope( Artifact.SCOPE_COMPILE ); + + artifacts.add( mac.artifact ); + + ArtifactMockAndControl mac2 = new ArtifactMockAndControl(); + + mac2.enableGetGroupId( "group2" ); + mac2.enableGetArtifactId( "artifact2" ); + mac2.enableGetDependencyConflictId( "group2:artifact2:jar" ); + mac2.enableGetScope( Artifact.SCOPE_COMPILE ); + mac2.enableGetDependencyTrail( Collections.EMPTY_LIST ); + mac2.enableGetId( "group2:artifact2:1.0" ); + + artifacts.add( mac2.artifact ); + + project.setArtifacts( artifacts ); + + DependencySet dependencySet = new DependencySet(); + + dependencySet.addInclude( "group:artifact" ); + + DependencySetAssemblyPhase phase = new DependencySetAssemblyPhase(); + phase.enableLogging( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) ); + + mockManager.replayAll(); + + Set result = phase.getDependencyArtifacts( project, dependencySet ); + + assertNotNull( result ); + assertEquals( 1, result.size() ); + assertSame( mac.artifact, result.iterator().next() ); + + mockManager.verifyAll(); + } + + private final class ArtifactMockAndControl + { + Artifact artifact; + MockControl control; + + public ArtifactMockAndControl() + { + control = MockControl.createControl( Artifact.class ); + mockManager.add( control ); + + artifact = (Artifact) control.getMock(); + } + + public void enableGetId( String id ) + { + artifact.getId(); + control.setReturnValue( id, MockControl.ONE_OR_MORE ); + } + + public void enableGetDependencyTrail( List dependencyTrail ) + { + artifact.getDependencyTrail(); + control.setReturnValue( dependencyTrail, MockControl.ONE_OR_MORE ); + } + + public void enableGetDependencyConflictId( String conflictId ) + { + artifact.getDependencyConflictId(); + control.setReturnValue( conflictId, MockControl.ONE_OR_MORE ); + } + + public void enableGetArtifactId( String artifactId ) + { + artifact.getArtifactId(); + control.setReturnValue( artifactId, MockControl.ONE_OR_MORE ); + } + + public void enableGetGroupId( String groupId ) + { + artifact.getGroupId(); + control.setReturnValue( groupId, MockControl.ONE_OR_MORE ); + } + + public void enableGetScope( String scope ) + { + artifact.getScope(); + control.setReturnValue( scope, MockControl.ONE_OR_MORE ); + } + } + +} Propchange: maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/phase/DependencySetAssemblyPhaseTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/archive/phase/DependencySetAssemblyPhaseTest.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Modified: maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java?rev=427165&r1=427164&r2=427165&view=diff ============================================================================== --- maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java (original) +++ maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/io/DefaultAssemblyReaderTest.java Mon Jul 31 09:45:27 2006 @@ -730,10 +730,11 @@ assembly.addFileSet( fs ); - List files = writeAssembliesToFile( Collections.singletonList( assembly ) ); + File basedir = fileManager.createTempDir(); - File assemblyFile = (File) files.get( 0 ); - File basedir = assemblyFile.getParentFile(); + List files = writeAssembliesToFile( Collections.singletonList( assembly ), basedir ); + + File assemblyFile = ( File ) files.get( 0 ); List assemblies = performReadAssemblies( basedir, assemblyFile, null, null, null, null ); @@ -773,10 +774,9 @@ assemblies.add( assembly1 ); assemblies.add( assembly2 ); - List files = writeAssembliesToFile( assemblies ); + File basedir = fileManager.createTempDir(); - File assemblyFile = (File) files.get( 0 ); - File basedir = assemblyFile.getParentFile(); + List files = writeAssembliesToFile( assemblies, basedir ); List results = performReadAssemblies( basedir, null, null, (File[]) files.toArray( new File[0] ), null, null ); @@ -823,11 +823,10 @@ List assemblies = new ArrayList(); assemblies.add( assembly1 ); assemblies.add( assembly2 ); + + File basedir = fileManager.createTempDir(); - List files = writeAssembliesToFile( assemblies ); - - File assemblyFile = (File) files.get( 0 ); - File basedir = assemblyFile.getParentFile(); + writeAssembliesToFile( assemblies, basedir ); List results = performReadAssemblies( basedir, null, null, null, null, basedir ); @@ -843,7 +842,7 @@ assertEquals( assembly2.getId(), result2.getId() ); } - private List writeAssembliesToFile( List assemblies ) + private List writeAssembliesToFile( List assemblies, File dir ) throws IOException { List files = new ArrayList(); @@ -851,8 +850,8 @@ for ( Iterator it = assemblies.iterator(); it.hasNext(); ) { Assembly assembly = (Assembly) it.next(); - - File assemblyFile = fileManager.createTempFile(); + + File assemblyFile = new File( dir, assembly.getId() + ".xml" ); FileWriter writer = null; try Modified: maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/FilterUtilsTest.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/FilterUtilsTest.java?rev=427165&r1=427164&r2=427165&view=diff ============================================================================== --- maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/FilterUtilsTest.java (original) +++ maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/FilterUtilsTest.java Mon Jul 31 09:45:27 2006 @@ -5,6 +5,7 @@ import org.apache.maven.model.Model; import org.apache.maven.plugin.assembly.testutils.MockManager; import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.logging.Logger; import org.easymock.MockControl; import java.util.Collections; @@ -20,6 +21,25 @@ private MockManager mockManager = new MockManager(); + private MockControl loggerCtl; + + private Logger logger; + + public void setUp() + { + clearAll(); + } + + private void clearAll() + { + mockManager.clear(); + + loggerCtl = MockControl.createControl( Logger.class ); + mockManager.add( loggerCtl ); + + logger = (Logger) loggerCtl.getMock(); + } + public void testFilterArtifacts_ShouldNotRemoveArtifactDirectlyIncluded() { verifyArtifactInclusion( "group", "artifact", "group:artifact", null, null, null ); @@ -33,19 +53,25 @@ public void testFilterArtifacts_ShouldRemoveArtifactTransitivelyExcluded() { + enableLoggerDebugging(); verifyArtifactExclusion( "group", "artifact", null, "group:dependentArtifact", Collections.singletonList( "group:dependentArtifact" ), null ); } public void testFilterArtifacts_ShouldRemoveArtifactDirectlyExcluded() { + enableLoggerDebugging(); verifyArtifactExclusion( "group", "artifact", null, "group:artifact", null, null ); + + clearAll(); + + enableLoggerDebugging(); verifyArtifactExclusion( "group", "artifact", null, "group:artifact:jar", null, null ); } public void testFilterArtifacts_ShouldNotRemoveArtifactNotIncludedAndNotExcluded() { - verifyArtifactInclusion( "group", "artifact", null, null, null, null, false ); - verifyArtifactInclusion( "group", "artifact", null, null, null, null, false ); + verifyArtifactInclusion( "group", "artifact", null, null, null, null ); + verifyArtifactInclusion( "group", "artifact", null, null, null, null ); } public void testFilterArtifacts_ShouldRemoveArtifactExcludedByAdditionalFilter() @@ -60,13 +86,28 @@ }; - verifyArtifactExclusion( "group", "artifact", "fail:fail", null, null, filter, false ); + enableLoggerDebugging(); + + logger.isWarnEnabled(); + loggerCtl.setReturnValue( true ); + + logger.warn( null ); + loggerCtl.setMatcher( MockControl.ALWAYS_MATCHER ); + + verifyArtifactExclusion( "group", "artifact", "fail:fail", null, null, filter ); } - - - - + private void enableLoggerDebugging() + { + logger.isDebugEnabled(); + loggerCtl.setReturnValue( true, MockControl.ONE_OR_MORE ); + + logger.debug( null ); + loggerCtl.setMatcher( MockControl.ALWAYS_MATCHER ); + loggerCtl.setVoidCallable( MockControl.ONE_OR_MORE ); + } + + public void testFilterProjects_ShouldNotRemoveProjectDirectlyIncluded() { verifyProjectInclusion( "group", "artifact", "group:artifact", null, null ); @@ -91,33 +132,23 @@ public void testFilterProjects_ShouldNotRemoveProjectNotIncludedAndNotExcluded() { - verifyProjectInclusion( "group", "artifact", null, null, null, false ); - verifyProjectInclusion( "group", "artifact", null, null, null, false ); + verifyProjectInclusion( "group", "artifact", null, null, null ); + verifyProjectInclusion( "group", "artifact", null, null, null ); } private void verifyArtifactInclusion( String groupId, String artifactId, String inclusionPattern, String exclusionPattern, List depTrail, ArtifactFilter additionalFilter ) { - verifyArtifactFiltering( groupId, artifactId, inclusionPattern, exclusionPattern, depTrail, true, true, additionalFilter ); - } - - private void verifyArtifactInclusion( String groupId, String artifactId, String inclusionPattern, String exclusionPattern, List depTrail, ArtifactFilter additionalFilter, boolean enableExpectations ) - { - verifyArtifactFiltering( groupId, artifactId, inclusionPattern, exclusionPattern, depTrail, true, enableExpectations, additionalFilter ); + verifyArtifactFiltering( groupId, artifactId, inclusionPattern, exclusionPattern, depTrail, true, additionalFilter ); } private void verifyArtifactExclusion( String groupId, String artifactId, String inclusionPattern, String exclusionPattern, List depTrail, ArtifactFilter additionalFilter ) { - verifyArtifactFiltering( groupId, artifactId, inclusionPattern, exclusionPattern, depTrail, false, true, additionalFilter ); - } - - private void verifyArtifactExclusion( String groupId, String artifactId, String inclusionPattern, String exclusionPattern, List depTrail, ArtifactFilter additionalFilter, boolean enableExpectations ) - { - verifyArtifactFiltering( groupId, artifactId, inclusionPattern, exclusionPattern, depTrail, false, enableExpectations, additionalFilter ); + verifyArtifactFiltering( groupId, artifactId, inclusionPattern, exclusionPattern, depTrail, false, additionalFilter ); } - private void verifyArtifactFiltering( String groupId, String artifactId, String inclusionPattern, String exclusionPattern, List depTrail, boolean verifyInclusion, boolean enableExpectations, ArtifactFilter additionalFilter ) + private void verifyArtifactFiltering( String groupId, String artifactId, String inclusionPattern, String exclusionPattern, List depTrail, boolean verifyInclusion, ArtifactFilter additionalFilter ) { - ArtifactMockAndControl mac = new ArtifactMockAndControl( groupId, artifactId, depTrail, enableExpectations ); + ArtifactMockAndControl mac = new ArtifactMockAndControl( groupId, artifactId, depTrail ); mockManager.replayAll(); @@ -153,8 +184,8 @@ Set artifacts = new HashSet(); artifacts.add( mac.artifact ); - - FilterUtils.filterArtifacts( artifacts, inclusions, exclusions, depTrail != null, filters ); + + FilterUtils.filterArtifacts( artifacts, inclusions, exclusions, depTrail != null, filters, logger ); if ( verifyInclusion ) { @@ -177,22 +208,17 @@ private void verifyProjectInclusion( String groupId, String artifactId, String inclusionPattern, String exclusionPattern, List depTrail ) { - verifyProjectFiltering( groupId, artifactId, inclusionPattern, exclusionPattern, depTrail, true, true ); - } - - private void verifyProjectInclusion( String groupId, String artifactId, String inclusionPattern, String exclusionPattern, List depTrail, boolean enableExpectations ) - { - verifyProjectFiltering( groupId, artifactId, inclusionPattern, exclusionPattern, depTrail, true, enableExpectations ); + verifyProjectFiltering( groupId, artifactId, inclusionPattern, exclusionPattern, depTrail, true ); } private void verifyProjectExclusion( String groupId, String artifactId, String inclusionPattern, String exclusionPattern, List depTrail ) { - verifyProjectFiltering( groupId, artifactId, inclusionPattern, exclusionPattern, depTrail, false, true ); + verifyProjectFiltering( groupId, artifactId, inclusionPattern, exclusionPattern, depTrail, false ); } - private void verifyProjectFiltering( String groupId, String artifactId, String inclusionPattern, String exclusionPattern, List depTrail, boolean verifyInclusion, boolean enableExpectations ) + private void verifyProjectFiltering( String groupId, String artifactId, String inclusionPattern, String exclusionPattern, List depTrail, boolean verifyInclusion ) { - ProjectWithArtifactMockControl pmac = new ProjectWithArtifactMockControl( groupId, artifactId, depTrail, enableExpectations ); + ProjectWithArtifactMockControl pmac = new ProjectWithArtifactMockControl( groupId, artifactId, depTrail ); mockManager.replayAll(); @@ -254,11 +280,11 @@ { ArtifactMockAndControl mac; - ProjectWithArtifactMockControl( String groupId, String artifactId, List depTrail, boolean enableExpectations ) + ProjectWithArtifactMockControl( String groupId, String artifactId, List depTrail ) { super( buildModel( groupId, artifactId ) ); - mac = new ArtifactMockAndControl( groupId, artifactId, depTrail, enableExpectations ); + mac = new ArtifactMockAndControl( groupId, artifactId, depTrail ); setArtifact( mac.artifact ); } @@ -277,7 +303,7 @@ List dependencyTrail; - ArtifactMockAndControl( String groupId, String artifactId, List dependencyTrail, boolean enableExpectations ) + ArtifactMockAndControl( String groupId, String artifactId, List dependencyTrail ) { this.groupId = groupId; this.artifactId = artifactId; @@ -290,37 +316,36 @@ // this is always enabled, for verification purposes. enableGetDependencyConflictId(); - - if ( enableExpectations ) - { - enableGetGroupIdAndArtifactId(); + enableGetGroupIdArtifactIdAndId(); - if ( dependencyTrail != null ) - { - enableGetDependencyTrail(); - } + if ( dependencyTrail != null ) + { + enableGetDependencyTrail(); } } void enableGetDependencyTrail() { artifact.getDependencyTrail(); - control.setReturnValue( dependencyTrail, MockControl.ONE_OR_MORE ); + control.setReturnValue( dependencyTrail, MockControl.ZERO_OR_MORE ); } void enableGetDependencyConflictId() { artifact.getDependencyConflictId(); - control.setReturnValue( groupId + ":" + artifactId + ":jar", MockControl.ONE_OR_MORE ); + control.setReturnValue( groupId + ":" + artifactId + ":jar", MockControl.ZERO_OR_MORE ); } - void enableGetGroupIdAndArtifactId() + void enableGetGroupIdArtifactIdAndId() { artifact.getGroupId(); - control.setReturnValue( groupId, MockControl.ONE_OR_MORE ); + control.setReturnValue( groupId, MockControl.ZERO_OR_MORE ); artifact.getArtifactId(); - control.setReturnValue( artifactId, MockControl.ONE_OR_MORE ); + control.setReturnValue( artifactId, MockControl.ZERO_OR_MORE ); + + artifact.getId(); + control.setReturnValue( groupId + ":" + artifactId + ":version:null:jar", MockControl.ZERO_OR_MORE ); } } Modified: maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/ProjectUtilsTest.java URL: http://svn.apache.org/viewvc/maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/ProjectUtilsTest.java?rev=427165&r1=427164&r2=427165&view=diff ============================================================================== --- maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/ProjectUtilsTest.java (original) +++ maven/plugins/branches/MASSEMBLY-124/src/test/java/org/apache/maven/plugin/assembly/utils/ProjectUtilsTest.java Mon Jul 31 09:45:27 2006 @@ -1,14 +1,5 @@ package org.apache.maven.plugin.assembly.utils; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.model.Build; -import org.apache.maven.model.Model; -import org.apache.maven.plugin.assembly.testutils.MockManager; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.console.ConsoleLogger; -import org.easymock.MockControl; - import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -19,37 +10,15 @@ import junit.framework.TestCase; +import org.apache.maven.model.Model; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.logging.Logger; +import org.codehaus.plexus.logging.console.ConsoleLogger; + public class ProjectUtilsTest extends TestCase { - public void testGetDependencies_ShouldIncludeProjectArtifactIfItsFileIsNonNull() - { - MavenProject project = createTestProject( "test", "testGroup", "1.0" ); - - MockManager mgr = new MockManager(); - - MockControl artifactCtl = MockControl.createControl( Artifact.class ); - mgr.add( artifactCtl ); - - Artifact artifact = (Artifact) artifactCtl.getMock(); - - artifact.getFile(); - artifactCtl.setReturnValue( new File( "." ) ); - - project.setArtifact( artifact ); - - mgr.replayAll(); - - Set dependencies = ProjectUtils.getDependencies( project ); - - assertNotNull( dependencies ); - assertEquals( 1, dependencies.size() ); - assertSame( artifact, dependencies.iterator().next() ); - - mgr.verifyAll(); - } - private MavenProject createTestProject( String artifactId, String groupId, String version ) { Model model = new Model(); @@ -60,80 +29,6 @@ MavenProject project = new MavenProject( model ); return project; - } - - public void testGetDependencies_ShouldNotIncludeProjectArtifactIfItsFileIsNull() - { - MavenProject project = createTestProject( "test", "testGroup", "1.0" ); - - MockManager mgr = new MockManager(); - - MockControl artifactCtl = MockControl.createControl( Artifact.class ); - mgr.add( artifactCtl ); - - Artifact artifact = (Artifact) artifactCtl.getMock(); - - artifact.getFile(); - artifactCtl.setReturnValue( null ); - - project.setArtifact( artifact ); - - mgr.replayAll(); - - Set dependencies = ProjectUtils.getDependencies( project ); - - assertNotNull( dependencies ); - assertTrue( dependencies.isEmpty() ); - - mgr.verifyAll(); - } - - public void testGetDependencies_ShouldIncludeProjectDependencyArtifactWhenItsFileIsNonNull() - { - MavenProject project = createTestProject( "test", "testGroup", "1.0" ); - - MockManager mgr = new MockManager(); - - MockControl artifactCtl = MockControl.createControl( Artifact.class ); - mgr.add( artifactCtl ); - - Artifact artifact = (Artifact) artifactCtl.getMock(); - - project.setArtifacts( Collections.singleton( artifact ) ); - - mgr.replayAll(); - - Set dependencies = ProjectUtils.getDependencies( project ); - - assertNotNull( dependencies ); - assertEquals( 1, dependencies.size() ); - assertSame( artifact, dependencies.iterator().next() ); - - mgr.verifyAll(); - } - - public void testGetDependencies_ShouldIncludeProjectDependencyArtifactWhenItsFileIsNull() - { - MavenProject project = createTestProject( "test", "testGroup", "1.0" ); - - MockManager mgr = new MockManager(); - - MockControl artifactCtl = MockControl.createControl( Artifact.class ); - mgr.add( artifactCtl ); - - Artifact artifact = (Artifact) artifactCtl.getMock(); - - project.setArtifacts( Collections.singleton( artifact ) ); - - mgr.replayAll(); - - Set dependencies = ProjectUtils.getDependencies( project ); - - assertNotNull( dependencies ); - assertEquals( 1, dependencies.size() ); - assertSame( artifact, dependencies.iterator().next() ); - - mgr.verifyAll(); } public void testGetProjectModules_ShouldIncludeDirectModuleOfMasterProject()