You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2006/08/03 04:46:03 UTC
svn commit: r428215 [2/2] - in /maven/plugins/trunk/maven-assembly-plugin:
./ src/functional-tests/ src/functional-tests/java/
src/functional-tests/java/org/ src/functional-tests/java/org/apache/
src/functional-tests/java/org/apache/maven/ src/function...
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/repository/DefaultRepositoryAssembler.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/repository/DefaultRepositoryAssembler.java?rev=428215&r1=428214&r2=428215&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/repository/DefaultRepositoryAssembler.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/repository/DefaultRepositoryAssembler.java Wed Aug 2 19:45:53 2006
@@ -16,23 +16,6 @@
* limitations under the License.
*/
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
-import java.lang.reflect.Field;
-import java.security.NoSuchAlgorithmException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TimeZone;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
@@ -51,6 +34,7 @@
import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.plugin.assembly.AssemblerConfigurationSource;
import org.apache.maven.plugin.assembly.filter.AssemblyExcludesArtifactFilter;
import org.apache.maven.plugin.assembly.filter.AssemblyIncludesArtifactFilter;
import org.apache.maven.plugin.assembly.utils.DigestUtils;
@@ -64,6 +48,23 @@
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.lang.reflect.Field;
+import java.security.NoSuchAlgorithmException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TimeZone;
+
/**
* @author Jason van Zyl
*/
@@ -93,10 +94,12 @@
private DigestUtils digester = new DigestUtils();
- public void assemble( File repositoryDirectory, Repository repository, MavenProject project,
- ArtifactRepository localRepository )
+ public void assemble( File repositoryDirectory, Repository repository, AssemblerConfigurationSource configSource )
throws RepositoryAssemblyException
{
+ MavenProject project = configSource.getProject();
+ ArtifactRepository localRepository = configSource.getLocalRepository();
+
createGroupVersionAlignments( repository.getGroupVersionAlignments() );
ArtifactRepository targetRepository = createLocalRepository( repositoryDirectory );
@@ -104,15 +107,16 @@
ArtifactResolutionResult result;
try
{
- // i have to get everything first as a filter or transformation here doesn't seem to work
- // to align everything. If I use a filter to change the version on the fly then I get the
- // I get JARs but no POMs, and in some directories POMs with no JARs.
-
- // I'm not getting runtime dependencies here
+ // i have to get everything first as a filter or transformation here
+ // doesn't seem to work
+ // to align everything. If I use a filter to change the version on
+ // the fly then I get the
+ // I get JARs but no POMs, and in some directories POMs with no
+ // JARs.
+ // FIXME I'm not getting runtime dependencies here
result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(), project.getArtifact(),
- project.getRemoteArtifactRepositories(), localRepository,
- metadataSource );
+ project.getRemoteArtifactRepositories(), localRepository, metadataSource );
}
catch ( ArtifactResolutionException e )
{
@@ -125,23 +129,39 @@
try
{
- // Blow the cache in the project builder so that we get POMs again on this next download
+ // Blow the cache in the project builder so that we get POMs again
+ // on this next download
invalidateProccessedProjectCache();
}
catch ( Exception e )
{
throw new RepositoryAssemblyException( "Error invalidating the processed project cache.", e );
}
+
+ ArtifactFilter filter = buildRepositoryFilter( repository, project);
+
+ assembleRepositoryArtifacts( result, filter, project, localRepository, targetRepository, repositoryDirectory );
+
+ ArtifactRepository centralRepository = findCentralRepository( project );
+
+ if ( repository.isIncludeMetadata() )
+ {
+ assembleRepositoryMetadata( result, filter, centralRepository, targetRepository );
+ }
+ }
+ private ArtifactFilter buildRepositoryFilter(Repository repository, MavenProject project)
+ {
AndArtifactFilter filter = new AndArtifactFilter();
- ArtifactFilter scopeFilter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME );
+ ArtifactFilter scopeFilter = new ScopeArtifactFilter( repository.getScope() );
filter.add( scopeFilter );
-
+
// ----------------------------------------------------------------------------
// Includes
//
- // We'll take everything if no includes are specified to try and make this
+ // We'll take everything if no includes are specified to try and make
+ // this
// process more maintainable. Don't want to have to update the assembly
// descriptor everytime the POM is updated.
// ----------------------------------------------------------------------------
@@ -149,21 +169,21 @@
if ( repository.getIncludes().isEmpty() )
{
List patterns = new ArrayList();
-
+
Set projectArtifacts = project.getDependencyArtifacts();
-
+
if ( projectArtifacts != null )
{
for ( Iterator it = projectArtifacts.iterator(); it.hasNext(); )
{
Artifact artifact = (Artifact) it.next();
-
+
patterns.add( artifact.getDependencyConflictId() );
}
}
-
+
AssemblyIncludesArtifactFilter includeFilter = new AssemblyIncludesArtifactFilter( patterns, true );
-
+
filter.add( includeFilter );
}
else
@@ -174,7 +194,8 @@
// ----------------------------------------------------------------------------
// Excludes
//
- // We still want to make it easy to exclude a few things even if we slurp
+ // We still want to make it easy to exclude a few things even if we
+ // slurp
// up everything.
// ----------------------------------------------------------------------------
@@ -183,9 +204,18 @@
filter.add( new AssemblyExcludesArtifactFilter( repository.getExcludes(), true ) );
}
+ return filter;
+ }
+
+ private void assembleRepositoryArtifacts( ArtifactResolutionResult result, ArtifactFilter filter,
+ MavenProject project, ArtifactRepository localRepository,
+ ArtifactRepository targetRepository, File repositoryDirectory )
+ throws RepositoryAssemblyException
+ {
try
{
- // Now that we have the graph, let's try to align it to versions that we want and remove
+ // Now that we have the graph, let's try to align it to versions
+ // that we want and remove
// the repository we previously populated.
FileUtils.deleteDirectory( repositoryDirectory );
@@ -199,7 +229,8 @@
{
setAlignment( a );
- // We need to flip it back to not being resolved so we can look for it again!
+ // We need to flip it back to not being resolved so we can
+ // look for it again!
a.setResolved( false );
artifactResolver.resolve( a, project.getRemoteArtifactRepositories(), localRepository );
@@ -213,19 +244,19 @@
{
a = artifactFactory.createProjectArtifact( a.getGroupId(), a.getArtifactId(), a.getVersion() );
- MavenProject p = projectBuilder.buildFromRepository( a, project.getRemoteArtifactRepositories(),
- localRepository );
+ MavenProject p = projectBuilder.buildFromRepository( a,
+ project.getRemoteArtifactRepositories(), localRepository );
do
{
- a = artifactFactory.createProjectArtifact( p.getGroupId(), p.getArtifactId(),
- p.getVersion() );
+ a = artifactFactory.createProjectArtifact( p.getGroupId(), p.getArtifactId(), p
+ .getVersion() );
setAlignment( a );
File sourceFile = new File( localRepository.getBasedir(), localRepository.pathOf( a ) );
- if( !sourceFile.exists() )
+ if ( !sourceFile.exists() )
{
break;
}
@@ -237,8 +268,7 @@
writeChecksums( targetFile );
p = p.getParent();
- }
- while ( p != null );
+ } while ( p != null );
}
}
}
@@ -259,7 +289,10 @@
{
throw new RepositoryAssemblyException( "Error reading POM.", e );
}
+ }
+ private ArtifactRepository findCentralRepository( MavenProject project )
+ {
ArtifactRepository centralRepository = null;
for ( Iterator i = project.getRemoteArtifactRepositories().iterator(); i.hasNext(); )
{
@@ -270,68 +303,69 @@
}
}
- if ( repository.isIncludeMetadata() )
+ return centralRepository;
+ }
+
+ private void assembleRepositoryMetadata( ArtifactResolutionResult result, ArtifactFilter filter,
+ ArtifactRepository centralRepository, ArtifactRepository targetRepository )
+ throws RepositoryAssemblyException
+ {
+ for ( Iterator i = result.getArtifacts().iterator(); i.hasNext(); )
{
- for ( Iterator i = result.getArtifacts().iterator(); i.hasNext(); )
- {
- Artifact a = (Artifact) i.next();
+ Artifact a = (Artifact) i.next();
- if ( filter.include( a ) )
- {
- Versioning v = new Versioning();
+ if ( filter.include( a ) )
+ {
+ Versioning v = new Versioning();
- v.setRelease( a.getVersion() );
+ v.setRelease( a.getVersion() );
- v.setLatest( a.getVersion() );
+ v.setLatest( a.getVersion() );
- v.addVersion( a.getVersion() );
+ v.addVersion( a.getVersion() );
- v.setLastUpdated( getUtcDateFormatter().format( new Date() ) );
+ v.setLastUpdated( getUtcDateFormatter().format( new Date() ) );
- ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( a, v );
- String path = targetRepository.pathOfLocalRepositoryMetadata( metadata, centralRepository );
- File metadataFile = new File( targetRepository.getBasedir(), path );
+ ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( a, v );
+ String path = targetRepository.pathOfLocalRepositoryMetadata( metadata, centralRepository );
+ File metadataFile = new File( targetRepository.getBasedir(), path );
- MetadataXpp3Writer metadataWriter = new MetadataXpp3Writer();
+ MetadataXpp3Writer metadataWriter = new MetadataXpp3Writer();
- Writer writer = null;
- try
- {
- writer = new FileWriter( metadataFile );
+ Writer writer = null;
+ try
+ {
+ writer = new FileWriter( metadataFile );
- metadataWriter.write( writer, metadata.getMetadata() );
- }
- catch ( IOException e )
- {
- throw new RepositoryAssemblyException( "Error writing artifact metdata.", e );
- }
- finally
- {
- IOUtil.close( writer );
- }
+ metadataWriter.write( writer, metadata.getMetadata() );
+ }
+ catch ( IOException e )
+ {
+ throw new RepositoryAssemblyException( "Error writing artifact metdata.", e );
+ }
+ finally
+ {
+ IOUtil.close( writer );
+ }
- try
- {
- writeChecksums( metadataFile );
+ try
+ {
+ writeChecksums( metadataFile );
- File metadataFileRemote = new File( targetRepository.getBasedir(),
- targetRepository.pathOfRemoteRepositoryMetadata(
- metadata ) );
+ File metadataFileRemote = new File( targetRepository.getBasedir(), targetRepository
+ .pathOfRemoteRepositoryMetadata( metadata ) );
- FileUtils.copyFile( metadataFile, metadataFileRemote );
+ FileUtils.copyFile( metadataFile, metadataFileRemote );
- FileUtils.copyFile( new File( metadataFile.getParentFile(), metadataFile.getName() + ".sha1" ),
- new File( metadataFileRemote.getParentFile(),
- metadataFileRemote.getName() + ".sha1" ) );
+ FileUtils.copyFile( new File( metadataFile.getParentFile(), metadataFile.getName() + ".sha1" ),
+ new File( metadataFileRemote.getParentFile(), metadataFileRemote.getName() + ".sha1" ) );
- FileUtils.copyFile( new File( metadataFile.getParentFile(), metadataFile.getName() + ".md5" ),
- new File( metadataFileRemote.getParentFile(),
- metadataFileRemote.getName() + ".md5" ) );
- }
- catch ( IOException e )
- {
- throw new RepositoryAssemblyException( "Error writing artifact metdata.", e );
- }
+ FileUtils.copyFile( new File( metadataFile.getParentFile(), metadataFile.getName() + ".md5" ),
+ new File( metadataFileRemote.getParentFile(), metadataFileRemote.getName() + ".md5" ) );
+ }
+ catch ( IOException e )
+ {
+ throw new RepositoryAssemblyException( "Error writing artifact metdata.", e );
}
}
}
@@ -345,8 +379,10 @@
String md5 = digester.createChecksum( file, "MD5" );
String sha1 = digester.createChecksum( file, "SHA-1" );
- FileUtils.fileWrite( new File( file.getParentFile(), file.getName() + ".md5" ).getAbsolutePath(), md5.toLowerCase() );
- FileUtils.fileWrite( new File( file.getParentFile(), file.getName() + ".sha1" ).getAbsolutePath(), sha1.toLowerCase() );
+ FileUtils.fileWrite( new File( file.getParentFile(), file.getName() + ".md5" ).getAbsolutePath(), md5
+ .toLowerCase() );
+ FileUtils.fileWrite( new File( file.getParentFile(), file.getName() + ".sha1" ).getAbsolutePath(), sha1
+ .toLowerCase() );
}
catch ( NoSuchAlgorithmException e )
{
@@ -383,14 +419,14 @@
}
return createRepository( "local", localRepositoryUrl, false, true,
- ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
+ ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
}
public ArtifactRepository createRepository( String repositoryId, String repositoryUrl, boolean offline,
boolean updateSnapshots, String globalChecksumPolicy )
{
- ArtifactRepository localRepository =
- new DefaultArtifactRepository( repositoryId, repositoryUrl, repositoryLayout );
+ ArtifactRepository localRepository = new DefaultArtifactRepository( repositoryId, repositoryUrl,
+ repositoryLayout );
boolean snapshotPolicySet = false;
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/repository/RepositoryAssembler.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/repository/RepositoryAssembler.java?rev=428215&r1=428214&r2=428215&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/repository/RepositoryAssembler.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/repository/RepositoryAssembler.java Wed Aug 2 19:45:53 2006
@@ -16,10 +16,8 @@
* limitations under the License.
*/
-import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.assembly.AssemblerConfigurationSource;
import org.apache.maven.plugins.assembly.model.Repository;
-import org.apache.maven.project.MavenProject;
-
import java.io.File;
/**
@@ -29,7 +27,6 @@
{
String ROLE = RepositoryAssembler.class.getName();
- public void assemble( File repositoryDirectory, Repository repository, MavenProject project,
- ArtifactRepository localRepository )
+ public void assemble( File repositoryDirectory, Repository repository, AssemblerConfigurationSource configSource )
throws RepositoryAssemblyException;
}
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/DigestUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/DigestUtils.java?rev=428215&r1=428214&r2=428215&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/DigestUtils.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/DigestUtils.java Wed Aug 2 19:45:53 2006
@@ -31,6 +31,7 @@
* Create a digest for a file. Stolen from repository-utils - once released, use that instead.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @todo [jdcasey] This needs unit tests.
*/
public class DigestUtils
{
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/FilterUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/FilterUtils.java?rev=428215&r1=428214&r2=428215&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/FilterUtils.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/FilterUtils.java Wed Aug 2 19:45:53 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,70 +10,132 @@
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()
{
}
- public static void filterProjects( Set projects, List includes, List excludes, boolean actTransitively )
+ public static void filterProjects( Set projects, List includes, List excludes, boolean actTransitively,
+ Logger logger )
{
+ List allFilters = new ArrayList();
+
AndArtifactFilter filter = new AndArtifactFilter();
if ( !includes.isEmpty() )
{
- filter.add( new AssemblyIncludesArtifactFilter( includes, actTransitively ) );
+ AssemblyIncludesArtifactFilter includeFilter =
+ new AssemblyIncludesArtifactFilter( includes, actTransitively );
+
+ filter.add( includeFilter );
+ allFilters.add( includeFilter );
}
if ( !excludes.isEmpty() )
{
- filter.add( new AssemblyExcludesArtifactFilter( excludes, actTransitively ) );
+ AssemblyExcludesArtifactFilter excludeFilter =
+ new AssemblyExcludesArtifactFilter( excludes, actTransitively );
+
+ filter.add( excludeFilter );
+ allFilters.add( excludeFilter );
}
-
+
for ( Iterator it = projects.iterator(); it.hasNext(); )
{
MavenProject project = (MavenProject) it.next();
Artifact artifact = project.getArtifact();
-
+
if ( !filter.include( artifact ) )
{
it.remove();
}
}
+
+ for ( Iterator it = allFilters.iterator(); it.hasNext(); )
+ {
+ ArtifactFilter f = (ArtifactFilter) it.next();
+
+ if ( f instanceof StatisticsReportingFilter )
+ {
+ ((StatisticsReportingFilter) f).reportMissedCriteria( logger );
+ }
+ }
}
- 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 sFilter = (StatisticsReportingFilter) f;
+
+ if( logger.isDebugEnabled() )
+ {
+ logger.debug( "Statistics for " + sFilter + "\n" );
+ }
+
+ sFilter.reportMissedCriteria( logger );
+ sFilter.reportFilteredArtifacts( logger );
}
}
}
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/ProjectUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/ProjectUtils.java?rev=428215&r1=428214&r2=428215&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/ProjectUtils.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/ProjectUtils.java Wed Aug 2 19:45:53 2006
@@ -1,42 +1,125 @@
package org.apache.maven.plugin.assembly.utils;
-import java.util.ArrayList;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.logging.Logger;
+
+import java.io.File;
+import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.project.MavenProject;
-
public final class ProjectUtils
{
-
+
private ProjectUtils()
{
}
- /**
- * Retrieves all artifact dependencies.
- *
- * @return A HashSet of artifacts
- */
- public static Set getDependencies( MavenProject project )
+ public static Set getProjectModules( MavenProject project, List reactorProjects, Logger logger )
+ throws IOException
{
- Set dependenciesSet = new HashSet();
+ Set moduleCandidates = new HashSet( reactorProjects );
- if ( project.getArtifact() != null && project.getArtifact().getFile() != null )
+ Set modules = new HashSet();
+
+ // we temporarily add the master project to the modules set, since this
+ // set is pulling double duty as a set of
+ // potential module parents in the tree rooted at the master
+ // project...this allows us to use the same looping
+ // algorithm below to discover both direct modules of the master project
+ // AND modules of those direct modules.
+ modules.add( project );
+
+ int changed = 0;
+
+ do
{
- dependenciesSet.add( project.getArtifact() );
+ changed = 0;
+
+ for ( Iterator candidateIterator = moduleCandidates.iterator(); candidateIterator.hasNext(); )
+ {
+ MavenProject moduleCandidate = (MavenProject) candidateIterator.next();
+
+ if ( moduleCandidate.getFile() == null )
+ {
+ logger.warn( "Cannot compute whether " + moduleCandidate.getId() + " is a module of: "
+ + project.getId() + "; it does not have an associated POM file on the local filesystem." );
+ continue;
+ }
+
+ for ( Iterator parentIterator = modules.iterator(); parentIterator.hasNext(); )
+ {
+ MavenProject potentialParent = (MavenProject) parentIterator.next();
+
+ if ( potentialParent.getFile() == null )
+ {
+ logger.warn( "Cannot use: " + moduleCandidate.getId()
+ + " as a potential module-parent while computing the module set for: " + project.getId()
+ + "; it does not have an associated POM file on the local filesystem." );
+ continue;
+ }
+
+ // if this parent has an entry for the module candidate in
+ // the path adjustments map, it's a direct
+ // module of that parent.
+ if ( projectContainsModule( potentialParent, moduleCandidate ) )
+ {
+ // add the candidate to the list of modules (and
+ // potential parents)
+ modules.add( moduleCandidate );
+
+ // remove the candidate from the candidate pool, because
+ // it's been verified.
+ candidateIterator.remove();
+
+ // increment the change counter, to show that we
+ // verified a new module on this pass.
+ changed++;
+ }
+ }
+ }
+ } while ( changed != 0 );
+
+ // remove the master project from the modules set, now that we're done
+ // using it as a set of potential module
+ // parents...
+ modules.remove( project );
+
+ return modules;
+ }
+
+ private static boolean projectContainsModule( MavenProject mainProject, MavenProject moduleProject )
+ throws IOException
+ {
+ List modules = mainProject.getModules();
+ File basedir = mainProject.getBasedir();
+
+ File moduleFile = moduleProject.getFile().getCanonicalFile();
+
+ File moduleBasedir = moduleProject.getBasedir();
+
+ if ( moduleBasedir == null )
+ {
+ moduleBasedir = new File( "." );
}
+
+ moduleBasedir = moduleBasedir.getCanonicalFile();
- Set projectArtifacts = project.getArtifacts();
- if ( projectArtifacts != null )
+ for ( Iterator it = modules.iterator(); it.hasNext(); )
{
- dependenciesSet.addAll( projectArtifacts );
+ String moduleSubpath = (String) it.next();
+
+ File moduleDir = new File( basedir, moduleSubpath ).getCanonicalFile();
+
+ if ( moduleDir.equals( moduleFile ) || moduleDir.equals( moduleBasedir ) )
+ {
+ return true;
+ }
}
- return dependenciesSet;
+ return false;
}
}
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/PropertyUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/PropertyUtils.java?rev=428215&r1=428214&r2=428215&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/PropertyUtils.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/utils/PropertyUtils.java Wed Aug 2 19:45:53 2006
@@ -17,6 +17,7 @@
*/
import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.interpolation.RegexBasedInterpolator;
import java.io.File;
import java.io.FileInputStream;
@@ -45,15 +46,19 @@
* @param useSystemProps wheter to incorporate System.getProperties settings into the returned Properties object.
* @return the loaded and fully resolved Properties object
*/
- public static Properties loadPropertyFile( File propfile, boolean fail, boolean useSystemProps )
+ public static Properties getInterpolatedPropertiesFromFile( File propfile, boolean fail, boolean useSystemProps )
throws IOException
{
- Properties props = new Properties();
+ Properties props;
if ( useSystemProps )
{
props = new Properties( System.getProperties() );
}
+ else
+ {
+ props = new Properties();
+ }
if ( propfile.exists() )
{
@@ -72,76 +77,18 @@
throw new FileNotFoundException( propfile.toString() );
}
+ RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
+ interpolator.addValueSource( new PropertiesInterpolationValueSource( props ) );
+
for ( Enumeration n = props.propertyNames(); n.hasMoreElements(); )
{
- String k = (String) n.nextElement();
- props.setProperty( k, getPropertyValue( k, props ) );
+ String key = (String) n.nextElement();
+ String value = interpolator.interpolate( props.getProperty( key ), "__properties" );
+
+ props.setProperty( key, value );
}
return props;
}
-
- /**
- * Retrieves a property value, replacing values like ${token}
- * using the Properties to look them up.
- * <p/>
- * It will leave unresolved properties alone, trying for System
- * properties, and implements reparsing (in the case that
- * the value of a property contains a key), and will
- * not loop endlessly on a pair like
- * test = ${test}.
- */
- private static String getPropertyValue( String k, Properties p )
- {
- // This can also be done using InterpolationFilterReader,
- // but it requires reparsing the file over and over until
- // it doesn't change.
-
- String v = p.getProperty( k );
- String ret = "";
- int idx, idx2;
-
- while ( ( idx = v.indexOf( "${" ) ) >= 0 )
- {
- // append prefix to result
- ret += v.substring( 0, idx );
-
- // strip prefix from original
- v = v.substring( idx + 2 );
-
- // if no matching } then bail
- if ( ( idx2 = v.indexOf( '}' ) ) < 0 )
- {
- break;
- }
-
- // strip out the key and resolve it
- // resolve the key/value for the ${statement}
- String nk = v.substring( 0, idx2 );
- v = v.substring( idx2 + 1 );
- String nv = p.getProperty( nk );
-
- // try global environment..
- if ( nv == null )
- {
- nv = System.getProperty( nk );
- }
-
- // if the key cannot be resolved,
- // leave it alone ( and don't parse again )
- // else prefix the original string with the
- // resolved property ( so it can be parsed further )
- // taking recursion into account.
- if ( nv == null || nv.equals( k ) )
- {
- ret += "${" + nk + "}";
- }
- else
- {
- v = nv + v;
- }
- }
- return ret + v;
- }
}
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/component.mdo
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/component.mdo?rev=428215&r1=428214&r2=428215&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/component.mdo (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/component.mdo Wed Aug 2 19:45:53 2006
@@ -1,346 +1,428 @@
-<?xml version="1.0"?>
-
-<!--
- ~ Copyright 2006 The Apache Software Foundation.
- ~
- ~ Licensed 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.
- -->
-
-<!-- Note Definitions of FileSet, FileItem, and DependencySet are
- already defined in descriptor.mod, but repeated here since
- Modello currently does not have capability to share files
--->
-
-<model>
- <id>component</id>
- <name>Component</name>
- <description>
- <![CDATA[
- <p>
- When creating several assemblies for a project with a custom assembly
- descriptor, it can't be helped that you will be duplicating some parts of
- a defined assembly. These duplicates can be extracted and placed in a
- separate file called a descriptor component.
- </p>
- <p>
- Descriptor components contain FileSets, Files, and DependencySets meant
- to be shared by assembly descriptors by referencing them using
- <componentDescriptors>. It allows multiple assemblies to share a set
- of user defined collections.
- </p>
- ]]>
- </description>
- <defaults>
- <default>
- <key>package</key>
- <value>org.apache.maven.plugins.assembly.model</value>
- </default>
- </defaults>
- <classes>
- <class rootElement="true" xml.tagName="component">
- <name>Component</name>
- <description>Describes the component layout and packaging.</description>
- <version>1.0.0</version>
- <fields>
- <field>
- <name>fileSets</name>
- <version>1.0.0</version>
- <association>
- <type>FileSet</type>
- <multiplicity>*</multiplicity>
- </association>
- <description>
- <![CDATA[
- Specifies which groups of files to include in the assembly. A
- fileSet is specified by providing one or more of <fileSet>
- subelements.
- ]]>
- </description>
- </field>
- <field>
- <name>files</name>
- <version>1.0.0</version>
- <association>
- <type>FileItem</type>
- <multiplicity>*</multiplicity>
- </association>
- <description>
- <![CDATA[
- Specifies which single files to include in the assembly. A file
- is specified by providing one or more of <file>
- subelements.
- ]]>
- </description>
- </field>
- <field>
- <name>dependencySets</name>
- <version>1.0.0</version>
- <association>
- <type>DependencySet</type>
- <multiplicity>*</multiplicity>
- </association>
- <description>
- <![CDATA[
- Specifies which dependencies to include in the assembly. A
- dependencySet is specified by providing one or more of
- <dependencySet> subelements.
- ]]>
- </description>
- </field>
- </fields>
- </class>
-
- <class>
- <name>SetBase</name>
- <version>1.0.0</version>
- <fields>
- <field>
- <name>outputDirectory</name>
- <version>1.0.0</version>
- <type>String</type>
- <description>
- Sets the output directory relative to the root
- of the root directory of the assembly. For example,
- "log" will put the specified files in the log directory.
- </description>
- </field>
- <field>
- <name>includes</name>
- <version>1.0.0</version>
- <association>
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- <description>
- <![CDATA[
- When <include> subelements are present, they define a set of
- files and directory to include. If none is present, then
- <includes> represents all valid values.
- ]]>
- </description>
- </field>
- <field>
- <name>excludes</name>
- <version>1.0.0</version>
- <association>
- <type>String</type>
- <multiplicity>*</multiplicity>
- </association>
- <description>
- <![CDATA[
- When <exclude> subelements are present, they define a set of
- files and directory to exclude. If none is present, then
- <excludes> represents no exclusions.
- ]]>
- </description>
- </field>
- <field>
- <name>fileMode</name>
- <version>1.0.0</version>
- <type>String</type>
- <defaultValue>0644</defaultValue>
- <description>
- <![CDATA[
- Similar to a UNIX permission, sets the file mode of the files included.
- Format: (User)(Group)(Other) where each component is a sum of Read = 4,
- Write = 2, and Execute = 1. For example, the default value of 0644
- translates to User read-write, Group and Other read-only.
- <a href="http://www.onlamp.com/pub/a/bsd/2000/09/06/FreeBSD_Basics.html">(more on unix-style permissions)</a>
- ]]>
- </description>
- </field>
- <field>
- <name>directoryMode</name>
- <version>1.0.0</version>
- <type>String</type>
- <defaultValue>0755</defaultValue>
- <description>
- <![CDATA[
- Similar to a UNIX permission, sets the directory mode of the directories
- included. Format: (User)(Group)(Other) where each component is a sum of
- Read = 4, Write = 2, and Execute = 1. For example, the default value of
- 0644 translates to User read-write, Group and Other read-only.
- <a href="http://www.onlamp.com/pub/a/bsd/2000/09/06/FreeBSD_Basics.html">(more on unix-style permissions)</a>
- ]]>
- </description>
- </field>
- </fields>
- </class>
- <class>
- <name>FileSet</name>
- <version>1.0.0</version>
- <superClass>SetBase</superClass>
- <description>
- A fileSet allows the inclusion of groups of files into the assembly.
- </description>
- <fields>
- <field>
- <name>directory</name>
- <version>1.0.0</version>
- <type>String</type>
- <description>
- Sets the absolute or relative location from the module's
- directory. For example, "src/main/bin" would select this
- subdirectory of the project in which this dependency is defined.
- </description>
- <required>true</required>
- </field>
- <field>
- <name>lineEnding</name>
- <version>1.0.0</version>
- <type>String</type>
- <description>
- <![CDATA[
- Sets the line-endings of the files in this fileSet.
- Valid values:
- <ul>
- <li><b>"keep"</b> - Preserve all line endings</li>
- <li><b>"unix"</b> - Use Unix-style line endings</li>
- <li><b>"lf"</b> - Use a single line-feed line endings</li>
- <li><b>"dos"</b> - Use DOS-style line endings</li>
- <li><b>"crlf"</b> - Use Carraige-return, line-feed line endings</li>
- </ul>
- ]]>
- </description>
- </field>
- </fields>
- </class>
- <class>
- <name>FileItem</name>
- <version>1.0.0</version>
- <description>
- A file allows individual file inclusion with the option to change
- the destination filename not supported by fileSets.
- </description>
- <fields>
- <field>
- <name>source</name>
- <version>1.0.0</version>
- <type>String</type>
- <required>true</required>
- <description>
- Sets the absolute or relative path from the module's directory
- of the file to be included in the assembly.
- </description>
- </field>
- <field>
- <name>outputDirectory</name>
- <version>1.0.0</version>
- <type>String</type>
- <required>false</required>
- <description>
- Sets the output directory relative to the root
- of the root directory of the assembly. For example,
- "log" will put the specified files in the log directory.
- </description>
- </field>
- <field>
- <name>destName</name>
- <version>1.0.0</version>
- <type>String</type>
- <description>
- Sets the destination filename in the outputDirectory.
- Default is the same name as the source's file.
- </description>
- </field>
- <field>
- <name>fileMode</name>
- <version>1.0.0</version>
- <type>String</type>
- <defaultValue>0644</defaultValue>
- <description>
- <![CDATA[
- Similar to a UNIX permission, sets the file mode of the files included.
- Format: (User)(Group)(Other) where each component is a sum of Read = 4,
- Write = 2, and Execute = 1. For example, the default value of 0644
- translates to User read-write, Group and Other read-only.
- <a href="http://www.onlamp.com/pub/a/bsd/2000/09/06/FreeBSD_Basics.html">(more on unix-style permissions)</a>
- ]]>
- </description>
- </field>
- <field>
- <name>lineEnding</name>
- <version>1.0.0</version>
- <type>String</type>
- <description>
- <![CDATA[
- Sets the line-endings of the files in this file.
- Valid values are:
- <ul>
- <li><b>"keep"</b> - Preserve all line endings</li>
- <li><b>"unix"</b> - Use Unix-style line endings</li>
- <li><b>"lf"</b> - Use a single line-feed line endings</li>
- <li><b>"dos"</b> - Use DOS-style line endings</li>
- <li><b>"crlf"</b> - Use Carraige-return, line-feed line endings</li>
- </ul>
- ]]>
- </description>
- </field>
- <field>
- <name>filtered</name>
- <version>1.0.0</version>
- <type>boolean</type>
- <description>
- Sets whether to determine if the file is filtered.
- </description>
- </field>
- </fields>
- </class>
-
- <class>
- <name>DependencySet</name>
- <version>1.0.0</version>
- <superClass>SetBase</superClass>
- <description>
- A dependencySet allows inclusion and exclusion of project dependencies
- in the assembly.
- </description>
- <fields>
- <field>
- <name>outputFileNameMapping</name>
- <version>1.0.0</version>
- <type>String</type>
- <defaultValue>${artifactId}-${version}.${extension}</defaultValue>
- <description>
- Sets the mapping pattern for all dependencies included in this
- assembly. Default is ${artifactId}-${version}.${extension}.
- </description>
- </field>
- <field>
- <name>unpack</name>
- <type>boolean</type>
- <defaultValue>false</defaultValue>
- <description>
- If set to true, this property will unpack all dependencies
- into the specified output directory. When set to false
- dependencies will be includes as archives (jars).
- Default value is false.
- </description>
- </field>
- <field>
- <name>scope</name>
- <version>1.0.0</version>
- <type>String</type>
- <defaultValue>runtime</defaultValue>
- <required>true</required>
- <description>
- Sets the dependency scope for this dependencySet.
- Default scope value is "runtime".
- </description>
- </field>
- </fields>
- </class>
-
- </classes>
-</model>
-
+<?xml version="1.0"?>
+
+<!--
+ ~ Copyright 2006 The Apache Software Foundation.
+ ~
+ ~ Licensed 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.
+ -->
+
+<!-- Note Definitions of FileSet, FileItem, and DependencySet are
+ already defined in descriptor.mod, but repeated here since
+ Modello currently does not have capability to share files
+-->
+
+<model>
+ <id>component</id>
+ <name>Component</name>
+ <description>
+ <![CDATA[
+ <p>
+ When creating several assemblies for a project with a custom assembly
+ descriptor, it can't be helped that you will be duplicating some parts of
+ a defined assembly. These duplicates can be extracted and placed in a
+ separate file called a descriptor component.
+ </p>
+ <p>
+ Descriptor components contain FileSets, Files, and DependencySets meant
+ to be shared by assembly descriptors by referencing them using
+ <componentDescriptors>. It allows multiple assemblies to share a set
+ of user defined collections.
+ </p>
+ ]]>
+ </description>
+ <defaults>
+ <default>
+ <key>package</key>
+ <value>org.apache.maven.plugins.assembly.model</value>
+ </default>
+ </defaults>
+ <classes>
+ <class rootElement="true" xml.tagName="component">
+ <name>Component</name>
+ <description>Describes the component layout and packaging.</description>
+ <version>1.0.0</version>
+ <fields>
+ <field>
+ <name>fileSets</name>
+ <version>1.0.0</version>
+ <association>
+ <type>FileSet</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ <description>
+ <![CDATA[
+ Specifies which groups of files to include in the assembly. A
+ fileSet is specified by providing one or more of <fileSet>
+ subelements.
+ ]]>
+ </description>
+ </field>
+ <field>
+ <name>files</name>
+ <version>1.0.0</version>
+ <association>
+ <type>FileItem</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ <description>
+ <![CDATA[
+ Specifies which single files to include in the assembly. A file
+ is specified by providing one or more of <file>
+ subelements.
+ ]]>
+ </description>
+ </field>
+ <field>
+ <name>dependencySets</name>
+ <version>1.0.0</version>
+ <association>
+ <type>DependencySet</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ <description>
+ <![CDATA[
+ Specifies which dependencies to include in the assembly. A
+ dependencySet is specified by providing one or more of
+ <dependencySet> subelements.
+ ]]>
+ </description>
+ </field>
+ <field>
+ <name>repositories</name>
+ <version>1.0.0</version>
+ <association>
+ <type>Repository</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ <description>
+ <![CDATA[
+ Specifies a set of repositories to include in the assembly. A
+ repository is specified by providing one or more of
+ <repository> subelements.
+ ]]>
+ </description>
+ </field>
+ </fields>
+ </class>
+
+ <class>
+ <name>SetBase</name>
+ <version>1.0.0</version>
+ <fields>
+ <field>
+ <name>outputDirectory</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>
+ Sets the output directory relative to the root
+ of the root directory of the assembly. For example,
+ "log" will put the specified files in the log directory.
+ </description>
+ </field>
+ <field>
+ <name>includes</name>
+ <version>1.0.0</version>
+ <association>
+ <type>String</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ <description>
+ <![CDATA[
+ When <include> subelements are present, they define a set of
+ files and directory to include. If none is present, then
+ <includes> represents all valid values.
+ ]]>
+ </description>
+ </field>
+ <field>
+ <name>excludes</name>
+ <version>1.0.0</version>
+ <association>
+ <type>String</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ <description>
+ <![CDATA[
+ When <exclude> subelements are present, they define a set of
+ files and directory to exclude. If none is present, then
+ <excludes> represents no exclusions.
+ ]]>
+ </description>
+ </field>
+ <field>
+ <name>fileMode</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <defaultValue>0644</defaultValue>
+ <description>
+ <![CDATA[
+ Similar to a UNIX permission, sets the file mode of the files included.
+ Format: (User)(Group)(Other) where each component is a sum of Read = 4,
+ Write = 2, and Execute = 1. For example, the default value of 0644
+ translates to User read-write, Group and Other read-only.
+ <a href="http://www.onlamp.com/pub/a/bsd/2000/09/06/FreeBSD_Basics.html">(more on unix-style permissions)</a>
+ ]]>
+ </description>
+ </field>
+ <field>
+ <name>directoryMode</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <defaultValue>0755</defaultValue>
+ <description>
+ <![CDATA[
+ Similar to a UNIX permission, sets the directory mode of the directories
+ included. Format: (User)(Group)(Other) where each component is a sum of
+ Read = 4, Write = 2, and Execute = 1. For example, the default value of
+ 0644 translates to User read-write, Group and Other read-only.
+ <a href="http://www.onlamp.com/pub/a/bsd/2000/09/06/FreeBSD_Basics.html">(more on unix-style permissions)</a>
+ ]]>
+ </description>
+ </field>
+ </fields>
+ </class>
+ <class>
+ <name>FileSet</name>
+ <version>1.0.0</version>
+ <superClass>SetBase</superClass>
+ <description>
+ A fileSet allows the inclusion of groups of files into the assembly.
+ </description>
+ <fields>
+ <field>
+ <name>directory</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>
+ Sets the absolute or relative location from the module's
+ directory. For example, "src/main/bin" would select this
+ subdirectory of the project in which this dependency is defined.
+ </description>
+ <required>true</required>
+ </field>
+ <field>
+ <name>lineEnding</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>
+ <![CDATA[
+ Sets the line-endings of the files in this fileSet.
+ Valid values:
+ <ul>
+ <li><b>"keep"</b> - Preserve all line endings</li>
+ <li><b>"unix"</b> - Use Unix-style line endings</li>
+ <li><b>"lf"</b> - Use a single line-feed line endings</li>
+ <li><b>"dos"</b> - Use DOS-style line endings</li>
+ <li><b>"crlf"</b> - Use Carraige-return, line-feed line endings</li>
+ </ul>
+ ]]>
+ </description>
+ </field>
+ </fields>
+ </class>
+ <class>
+ <name>FileItem</name>
+ <version>1.0.0</version>
+ <description>
+ A file allows individual file inclusion with the option to change
+ the destination filename not supported by fileSets.
+ </description>
+ <fields>
+ <field>
+ <name>source</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <required>true</required>
+ <description>
+ Sets the absolute or relative path from the module's directory
+ of the file to be included in the assembly.
+ </description>
+ </field>
+ <field>
+ <name>outputDirectory</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <required>false</required>
+ <description>
+ Sets the output directory relative to the root
+ of the root directory of the assembly. For example,
+ "log" will put the specified files in the log directory.
+ </description>
+ </field>
+ <field>
+ <name>destName</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>
+ Sets the destination filename in the outputDirectory.
+ Default is the same name as the source's file.
+ </description>
+ </field>
+ <field>
+ <name>fileMode</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <defaultValue>0644</defaultValue>
+ <description>
+ <![CDATA[
+ Similar to a UNIX permission, sets the file mode of the files included.
+ Format: (User)(Group)(Other) where each component is a sum of Read = 4,
+ Write = 2, and Execute = 1. For example, the default value of 0644
+ translates to User read-write, Group and Other read-only.
+ <a href="http://www.onlamp.com/pub/a/bsd/2000/09/06/FreeBSD_Basics.html">(more on unix-style permissions)</a>
+ ]]>
+ </description>
+ </field>
+ <field>
+ <name>lineEnding</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>
+ <![CDATA[
+ Sets the line-endings of the files in this file.
+ Valid values are:
+ <ul>
+ <li><b>"keep"</b> - Preserve all line endings</li>
+ <li><b>"unix"</b> - Use Unix-style line endings</li>
+ <li><b>"lf"</b> - Use a single line-feed line endings</li>
+ <li><b>"dos"</b> - Use DOS-style line endings</li>
+ <li><b>"crlf"</b> - Use Carraige-return, line-feed line endings</li>
+ </ul>
+ ]]>
+ </description>
+ </field>
+ <field>
+ <name>filtered</name>
+ <version>1.0.0</version>
+ <type>boolean</type>
+ <description>
+ Sets whether to determine if the file is filtered.
+ </description>
+ </field>
+ </fields>
+ </class>
+
+ <class>
+ <name>DependencySet</name>
+ <version>1.0.0</version>
+ <superClass>SetBase</superClass>
+ <description>
+ A dependencySet allows inclusion and exclusion of project dependencies
+ in the assembly.
+ </description>
+ <fields>
+ <field>
+ <name>outputFileNameMapping</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <defaultValue>${artifactId}-${version}.${extension}</defaultValue>
+ <description>
+ Sets the mapping pattern for all dependencies included in this
+ assembly. Default is ${artifactId}-${version}.${extension}.
+ </description>
+ </field>
+ <field>
+ <name>unpack</name>
+ <type>boolean</type>
+ <defaultValue>false</defaultValue>
+ <description>
+ If set to true, this property will unpack all dependencies
+ into the specified output directory. When set to false
+ dependencies will be includes as archives (jars).
+ Default value is false.
+ </description>
+ </field>
+ <field>
+ <name>scope</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <defaultValue>runtime</defaultValue>
+ <required>true</required>
+ <description>
+ Sets the dependency scope for this dependencySet.
+ Default scope value is "runtime".
+ </description>
+ </field>
+ </fields>
+ </class>
+
+ <class>
+ <name>Repository</name>
+ <version>1.0.0</version>
+ <superClass>SetBase</superClass>
+ <description>Defines a Maven repository to be included in the assembly.</description>
+ <fields>
+ <field>
+ <name>includeMetadata</name>
+ <version>1.0.0</version>
+ <type>boolean</type>
+ <defaultValue>false</defaultValue>
+ <description>
+ If set to true, this property will trigger the creation of repository
+ metadata which will allow the repository to be used as a functional remote
+ repository.
+ </description>
+ </field>
+ <field>
+ <name>groupVersionAlignments</name>
+ <version>1.0.0</version>
+ <description>Align a group to a version or an individual artifact.</description>
+ <association>
+ <type>GroupVersionAlignment</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ </field>
+ <field>
+ <name>scope</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <defaultValue>runtime</defaultValue>
+ <required>true</required>
+ <description>
+ Specifies the scope for artifacts included in this repository.
+ Default scope value is "runtime".
+ </description>
+ </field>
+ </fields>
+ </class>
+ <class>
+ <name>GroupVersionAlignment</name>
+ <version>1.0.0</version>
+ <description>Defines a Maven repository to be included in the assembly.</description>
+ <fields>
+ <field>
+ <name>id</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>The groupId for which you want to align the versions.</description>
+ </field>
+ <field>
+ <name>version</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>The version you want to align this group to.</description>
+ </field>
+ <field>
+ <name>excludes</name>
+ <version>1.0.0</version>
+ <description>Artifact Ids of the artifacts you want excluded from version alignment.</description>
+ <association>
+ <type>String</type>
+ <multiplicity>*</multiplicity>
+ </association>
+ </field>
+ </fields>
+ </class>
+ </classes>
+</model>
+
Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/descriptor.mdo
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/descriptor.mdo?rev=428215&r1=428214&r2=428215&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/descriptor.mdo (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/mdo/descriptor.mdo Wed Aug 2 19:45:53 2006
@@ -539,7 +539,7 @@
<class>
<name>ModuleSources</name>
<version>1.0.0</version>
- <superClass>SetBase</superClass>
+ <superClass>FileSet</superClass>
<description>
Contains configuration options for including the source files of a
project module in an assembly.
@@ -633,6 +633,17 @@
<type>GroupVersionAlignment</type>
<multiplicity>*</multiplicity>
</association>
+ </field>
+ <field>
+ <name>scope</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <defaultValue>runtime</defaultValue>
+ <required>true</required>
+ <description>
+ Specifies the scope for artifacts included in this repository.
+ Default scope value is "runtime".
+ </description>
</field>
</fields>
</class>
Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolatorTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolatorTest.java?rev=428215&r1=428214&r2=428215&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolatorTest.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolatorTest.java Wed Aug 2 19:45:53 2006
@@ -3,10 +3,14 @@
import org.apache.maven.model.Model;
import org.apache.maven.plugins.assembly.model.Assembly;
import org.apache.maven.plugins.assembly.model.DependencySet;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.logging.console.ConsoleLogger;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
+import java.util.Properties;
import junit.framework.TestCase;
@@ -14,31 +18,186 @@
extends TestCase
{
- public void testDependencyOutputFileNameMappingsAreNotInterpolated()
+ private AssemblyInterpolator interpolator;
+
+ public void setUp()
+ throws IOException
+ {
+ interpolator = new AssemblyInterpolator();
+
+ interpolator.enableLogging( new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) );
+ }
+
+ public void testBlacklistedExpressionsInDependencyOutputFileNameMappingsAreNotInterpolated()
throws IOException, AssemblyInterpolationException
{
- AssemblyInterpolator interpolator = new AssemblyInterpolator();
+ Model model = new Model();
+ model.setArtifactId( "artifact-id" );
+ model.setGroupId( "group.id" );
+ model.setVersion( "1" );
+ model.setPackaging( "jar" );
+
+ Assembly assembly = new Assembly();
+
+ // artifactId is blacklisted, but packaging is not.
+ String outputFileNameMapping = "${artifactId}.${packaging}";
+
+ DependencySet set = new DependencySet();
+ set.setOutputFileNameMapping( outputFileNameMapping );
+ assembly.addDependencySet( set );
+
+ Assembly outputAssembly = interpolator.interpolate( assembly, model, Collections.EMPTY_MAP );
+
+ List outputDependencySets = outputAssembly.getDependencySets();
+ assertEquals( 1, outputDependencySets.size() );
+
+ DependencySet outputSet = (DependencySet) outputDependencySets.get( 0 );
+
+ assertEquals( "${artifactId}.jar", outputSet.getOutputFileNameMapping() );
+ }
+
+ public void testBlacklistedExpressionsInDependencySetOutputDirectoryIsNotInterpolated()
+ throws IOException, AssemblyInterpolationException
+ {
Model model = new Model();
model.setArtifactId( "artifact-id" );
model.setGroupId( "group.id" );
model.setVersion( "1" );
+ model.setPackaging( "jar" );
Assembly assembly = new Assembly();
+ String outputDirectory = "${artifactId}.${packaging}";
+
DependencySet set = new DependencySet();
- set.setOutputFileNameMapping( "${artifactId}.${extension}" );
+ set.setOutputDirectory( outputDirectory );
assembly.addDependencySet( set );
Assembly outputAssembly = interpolator.interpolate( assembly, model, Collections.EMPTY_MAP );
-
+
List outputDependencySets = outputAssembly.getDependencySets();
assertEquals( 1, outputDependencySets.size() );
-
+
DependencySet outputSet = (DependencySet) outputDependencySets.get( 0 );
-
- assertEquals( set.getOutputFileNameMapping(), outputSet.getOutputFileNameMapping() );
+
+ assertEquals( "${artifactId}.jar", outputSet.getOutputDirectory() );
+ }
+
+ public void testShouldResolveModelGroupIdInAssemblyId()
+ throws AssemblyInterpolationException
+ {
+ Model model = new Model();
+ model.setArtifactId( "artifact-id" );
+ model.setGroupId( "group.id" );
+ model.setVersion( "1" );
+ model.setPackaging( "jar" );
+
+ Assembly assembly = new Assembly();
+
+ assembly.setId( "assembly.${groupId}" );
+
+ Assembly result = interpolator.interpolate( assembly, model, Collections.EMPTY_MAP );
+
+ assertEquals( "assembly.group.id", result.getId() );
+ }
+
+ public void testShouldResolveModelPropertyBeforeModelGroupIdInAssemblyId()
+ throws AssemblyInterpolationException
+ {
+ Model model = new Model();
+ model.setArtifactId( "artifact-id" );
+ model.setGroupId( "group.id" );
+ model.setVersion( "1" );
+ model.setPackaging( "jar" );
+
+ Properties props = new Properties();
+ props.setProperty( "groupId", "other.id" );
+
+ model.setProperties( props );
+
+ Assembly assembly = new Assembly();
+
+ assembly.setId( "assembly.${groupId}" );
+
+ Assembly result = interpolator.interpolate( assembly, model, Collections.EMPTY_MAP );
+
+ assertEquals( "assembly.other.id", result.getId() );
+ }
+
+ public void testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId()
+ throws AssemblyInterpolationException
+ {
+ Model model = new Model();
+ model.setArtifactId( "artifact-id" );
+ model.setGroupId( "group.id" );
+ model.setVersion( "1" );
+ model.setPackaging( "jar" );
+
+ Properties props = new Properties();
+ props.setProperty( "groupId", "other.id" );
+
+ model.setProperties( props );
+
+ Assembly assembly = new Assembly();
+
+ assembly.setId( "assembly.${groupId}" );
+
+ Assembly result = interpolator.interpolate( assembly, model, Collections.singletonMap( "groupId",
+ "still.another.id" ) );
+
+ assertEquals( "assembly.still.another.id", result.getId() );
+ }
+
+ public void testShouldResolveEnvarHOMEValueInDependencySetOutputDirectory()
+ throws IOException, AssemblyInterpolationException
+ {
+ Model model = new Model();
+ model.setArtifactId( "artifact-id" );
+ model.setGroupId( "group.id" );
+ model.setVersion( "1" );
+ model.setPackaging( "jar" );
+
+ Assembly assembly = new Assembly();
+
+ Properties envars = CommandLineUtils.getSystemEnvVars();
+
+ String homeValue = envars.getProperty( "PATH" );
+
+ String outputDirectory = "${env.PATH}";
+
+ DependencySet set = new DependencySet();
+ set.setOutputDirectory( outputDirectory );
+
+ assembly.addDependencySet( set );
+
+ Assembly outputAssembly = interpolator.interpolate( assembly, model, Collections.EMPTY_MAP );
+
+ List outputDependencySets = outputAssembly.getDependencySets();
+ assertEquals( 1, outputDependencySets.size() );
+
+ DependencySet outputSet = (DependencySet) outputDependencySets.get( 0 );
+
+ assertEquals( homeValue, outputSet.getOutputDirectory() );
+ }
+
+ public void testShouldNotTouchUnresolvedExpression()
+ throws AssemblyInterpolationException
+ {
+ Model model = new Model();
+ model.setArtifactId( "artifact-id" );
+ model.setGroupId( "group.id" );
+ model.setVersion( "1" );
+ model.setPackaging( "jar" );
+
+ Assembly assembly = new Assembly();
+
+ assembly.setId( "assembly.${unresolved}" );
+
+ Assembly result = interpolator.interpolate( assembly, model, Collections.EMPTY_MAP );
+
+ assertEquals( "assembly.${unresolved}", result.getId() );
}
}