diff options
author | Volker Schumacher <volker@antenna500.local> | 2009-12-18 14:38:15 +0800 |
---|---|---|
committer | Mark Donszelmann <Mark.Donszelmann@gmail.com> | 2010-01-08 16:28:11 +0800 |
commit | 11d70333d325cd542f4c44f2b62a1e1e242b058d (patch) | |
tree | 82697445b3d16dfa89d1a8e2e96deb4a98f979ed | |
parent | 122cee678fdbe6faf86c76e322e874e08f1cd499 (diff) | |
download | maven-nar-plugin-11d70333d325cd542f4c44f2b62a1e1e242b058d.tar.gz maven-nar-plugin-11d70333d325cd542f4c44f2b62a1e1e242b058d.tar.bz2 maven-nar-plugin-11d70333d325cd542f4c44f2b62a1e1e242b058d.tar.xz maven-nar-plugin-11d70333d325cd542f4c44f2b62a1e1e242b058d.zip |
NarAssemblyMojo: when classifiers not specified, assume all available classifiers.
-rw-r--r-- | src/main/java/org/apache/maven/plugin/nar/NarAssemblyMojo.java | 60 | ||||
-rw-r--r-- | src/main/java/org/apache/maven/plugin/nar/NarManager.java | 30 |
2 files changed, 56 insertions, 34 deletions
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/* <AttachedNarArtifact> */getAttachedNarDependencies( List/* <NarArtifacts> */narArtifacts ) throws MojoExecutionException, MojoFailureException { - return getAttachedNarDependencies( narArtifacts, null ); + return getAttachedNarDependencies( narArtifacts, ( String )null ); } public final List/* <AttachedNarArtifact> */getAttachedNarDependencies( List/* <NarArtifacts> */narArtifacts, @@ -146,6 +146,34 @@ public class NarManager return getAttachedNarDependencies( narArtifacts, aol, type ); } + public final List/* <AttachedNarArtifact> */getAttachedNarDependencies( + List/* <NarArtifacts> */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 |