From 11d70333d325cd542f4c44f2b62a1e1e242b058d Mon Sep 17 00:00:00 2001 From: Volker Schumacher Date: Fri, 18 Dec 2009 14:38:15 +0800 Subject: NarAssemblyMojo: when classifiers not specified, assume all available classifiers. --- .../apache/maven/plugin/nar/NarAssemblyMojo.java | 60 ++++++++++------------ .../org/apache/maven/plugin/nar/NarManager.java | 30 ++++++++++- 2 files changed, 56 insertions(+), 34 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/apache/maven/plugin/nar/NarAssemblyMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarAssemblyMojo.java index 0efe342..ed3fffd 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarAssemblyMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarAssemblyMojo.java @@ -45,9 +45,6 @@ public class NarAssemblyMojo /** * List of classifiers which you want to assemble. Example ppc-MacOSX-g++-static, x86-Windows-msvc-shared, * i386-Linux-g++-executable, .... - * - * @parameter expression="" - * @required */ private List classifiers; @@ -57,46 +54,43 @@ public class NarAssemblyMojo public final void narExecute() throws MojoExecutionException, MojoFailureException { - for ( Iterator j = classifiers.iterator(); j.hasNext(); ) - { - String classifier = (String) j.next(); + List narArtifacts = getNarManager().getNarDependencies( "compile" ); + + List dependencies = getNarManager().getAttachedNarDependencies( narArtifacts, classifiers ); - List narArtifacts = getNarManager().getNarDependencies( "compile" ); - List dependencies = getNarManager().getAttachedNarDependencies( narArtifacts, classifier ); - // this may make some extra copies... - for ( Iterator d = dependencies.iterator(); d.hasNext(); ) - { - Artifact dependency = (Artifact) d.next(); - getLog().debug( "Assemble from " + dependency ); + // this may make some extra copies... + for ( Iterator d = dependencies.iterator(); d.hasNext(); ) + { + Artifact dependency = (Artifact) d.next(); + getLog().debug( "Assemble from " + dependency ); - // FIXME reported to maven developer list, isSnapshot - // changes behaviour - // of getBaseVersion, called in pathOf. - dependency.isSnapshot(); + // FIXME reported to maven developer list, isSnapshot + // changes behaviour + // of getBaseVersion, called in pathOf. + dependency.isSnapshot(); - File srcDir = getLayout().getNarUnpackDirectory( - getUnpackDirectory(), - getNarManager().getNarFile( dependency )); + File srcDir = getLayout().getNarUnpackDirectory( + getUnpackDirectory(), + getNarManager().getNarFile( dependency )); // File srcDir = new File( getLocalRepository().pathOf( dependency ) ); // srcDir = new File( getLocalRepository().getBasedir(), srcDir.getParent() ); // srcDir = new File( srcDir, "nar/" ); - File dstDir = getTargetDirectory(); - try - { - FileUtils.mkdir( dstDir.getPath() ); - getLog().debug( "SrcDir: " + srcDir ); - if ( srcDir.exists() ) - { - FileUtils.copyDirectoryStructure( srcDir, dstDir ); - } - } - catch ( IOException ioe ) + File dstDir = getTargetDirectory(); + try + { + FileUtils.mkdir( dstDir.getPath() ); + getLog().debug( "SrcDir: " + srcDir ); + if ( srcDir.exists() ) { - throw new MojoExecutionException( "Failed to copy directory for dependency " + dependency - + " from " + srcDir + " to " + dstDir, ioe ); + FileUtils.copyDirectoryStructure( srcDir, dstDir ); } } + catch ( IOException ioe ) + { + throw new MojoExecutionException( "Failed to copy directory for dependency " + dependency + + " from " + srcDir + " to " + dstDir, ioe ); + } } } } diff --git a/src/main/java/org/apache/maven/plugin/nar/NarManager.java b/src/main/java/org/apache/maven/plugin/nar/NarManager.java index 19cbeff..476eee8 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarManager.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarManager.java @@ -120,7 +120,7 @@ public class NarManager public final List/* */getAttachedNarDependencies( List/* */narArtifacts ) throws MojoExecutionException, MojoFailureException { - return getAttachedNarDependencies( narArtifacts, null ); + return getAttachedNarDependencies( narArtifacts, ( String )null ); } public final List/* */getAttachedNarDependencies( List/* */narArtifacts, @@ -146,6 +146,34 @@ public class NarManager return getAttachedNarDependencies( narArtifacts, aol, type ); } + public final List/* */getAttachedNarDependencies( + List/* */narArtifacts, List classifiers) + throws MojoExecutionException, MojoFailureException + { + String[] types; + + List artifactList = new ArrayList(); + + if( classifiers != null && !classifiers.isEmpty() ) + { + types = (String[]) classifiers.toArray(); + + for ( int j = 0; j < types.length; j++ ) + { + if ( artifactList != null ) + { + artifactList.addAll( getAttachedNarDependencies( narArtifacts, types[j] )); + } + } +} + else + { + artifactList.addAll( getAttachedNarDependencies( narArtifacts, ( String )null )); + } + + return artifactList; + } + /** * Returns a list of all attached nar dependencies for a specific binding and "noarch", but not where "local" is * specified -- cgit v1.2.3