diff options
author | Mark Donszelmann <Mark.Donszelmann@gmail.com> | 2009-12-16 11:26:50 +0100 |
---|---|---|
committer | Mark Donszelmann <Mark.Donszelmann@gmail.com> | 2009-12-16 11:26:50 +0100 |
commit | cc559c07b2d923b29124655f22bdd974107107c3 (patch) | |
tree | 6cecb7e68b50debc21c97ee8c213ec9d49757806 /src/main | |
parent | d1ac55c70b41dca59afde48caf49138fe06878c2 (diff) | |
download | maven-nar-plugin-cc559c07b2d923b29124655f22bdd974107107c3.tar.gz maven-nar-plugin-cc559c07b2d923b29124655f22bdd974107107c3.tar.bz2 maven-nar-plugin-cc559c07b2d923b29124655f22bdd974107107c3.tar.xz maven-nar-plugin-cc559c07b2d923b29124655f22bdd974107107c3.zip |
Fixed NAR-119
Diffstat (limited to 'src/main')
11 files changed, 48 insertions, 44 deletions
diff --git a/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java b/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java index a38a1b5..c04660d 100644 --- a/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java @@ -130,12 +130,14 @@ public abstract class AbstractCompileMojo private Java java; /** - * Layout to be used for building and upacking artifacts + * Layout to be used for building and unpacking artifacts * * @parameter expression="${nar.layout}" default-value="org.apache.maven.plugin.nar.NarLayout21" * @required */ private String layout; + + private NarLayout narLayout; diff --git a/src/main/java/org/apache/maven/plugin/nar/AbstractNarMojo.java b/src/main/java/org/apache/maven/plugin/nar/AbstractNarMojo.java index 3725d71..0923600 100644 --- a/src/main/java/org/apache/maven/plugin/nar/AbstractNarMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/AbstractNarMojo.java @@ -92,7 +92,7 @@ public abstract class AbstractNarMojo private String finalName; /** - * Target directory for Nar file construction Defaults to "${project.build.directory}/nar" for "nar-compile" goal + * Target directory for Nar file construction. Defaults to "${project.build.directory}/nar" for "nar-compile" goal * Defaults to "${project.build.directory}/test-nar" for "nar-testCompile" goal * * @parameter expression="" @@ -100,6 +100,13 @@ public abstract class AbstractNarMojo private File targetDirectory; /** + * Target directory for Nar file unpacking. Defaults to "${targetDirectory}/depenencies" + * + * @parameter expression="" + */ + private File unpackDirectory; + + /** * @parameter expression="${project}" * @readonly * @required @@ -121,6 +128,11 @@ public abstract class AbstractNarMojo { targetDirectory = new File( mavenProject.getBuild().getDirectory(), "nar" ); } + + if ( unpackDirectory == null ) + { + unpackDirectory = new File( targetDirectory, "dependencies" ); + } } protected final String getArchitecture() @@ -159,6 +171,11 @@ public abstract class AbstractNarMojo return targetDirectory; } + protected final File getUnpackDirectory() + { + return unpackDirectory; + } + protected final MavenProject getMavenProject() { return mavenProject; diff --git a/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java index 7ffc0d8..8812755 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java @@ -284,7 +284,7 @@ public class NarCompileMojo getLog().debug( "Looking for " + narDependency + " found binding " + binding ); if ( !binding.equals( Library.JNI ) ) { - File unpackDirectory = getNarManager().getUnpackDirectory( narDependency ); + File unpackDirectory = getUnpackDirectory(); File include = getLayout().getIncludeDirectory( unpackDirectory, narDependency.getArtifactId(), narDependency.getVersion() ); @@ -352,7 +352,7 @@ public class NarCompileMojo if ( !binding.equals( Library.JNI ) ) { - File unpackDirectory = getNarManager().getUnpackDirectory( dependency ); + File unpackDirectory = getUnpackDirectory(); File dir = getLayout().getLibDirectory( unpackDirectory, dependency.getArtifactId(), diff --git a/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java index a905a77..ac4fcf7 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java @@ -1019,9 +1019,8 @@ public class NarIntegrationTestMojo if ( !binding.equals( Library.STATIC ) ) { File depLibPathEntry = - getLayout().getLibDirectory( getNarManager().getUnpackDirectory( dependency ), - dependency.getArtifactId(), dependency.getVersion(), - getAOL().toString(), binding ); + getLayout().getLibDirectory( getUnpackDirectory(), dependency.getArtifactId(), + dependency.getVersion(), getAOL().toString(), binding ); if ( depLibPathEntry.exists() ) { getLog().debug( "Adding dependency directory to java.library.path: " + depLibPathEntry ); diff --git a/src/main/java/org/apache/maven/plugin/nar/NarLayout.java b/src/main/java/org/apache/maven/plugin/nar/NarLayout.java index 64455aa..9529473 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarLayout.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout.java @@ -80,6 +80,6 @@ public interface NarLayout * @param defaultAOL * @param linkerName */ - void unpackNar( ArchiverManager archiverManager, File file, String os, String linkerName, AOL defaultAOL ) + void unpackNar( File baseDir, ArchiverManager archiverManager, File file, String os, String linkerName, AOL defaultAOL ) throws MojoExecutionException, MojoFailureException; } diff --git a/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java b/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java index 299e706..304278f 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java @@ -96,7 +96,7 @@ public class NarLayout20 */ public final File getBinDirectory( File baseDir, String artifactId, String version, String aol ) { - File dir = new File( baseDir, fileLayout.getBinDirectory( aol )); + File dir = new File( baseDir, fileLayout.getBinDirectory( aol ) ); return dir; } @@ -159,18 +159,17 @@ public class NarLayout20 } } - public void unpackNar( ArchiverManager archiverManager, File file, String os, String linkerName, AOL defaultAOL ) + public void unpackNar( File unpackDir, ArchiverManager archiverManager, File file, String os, String linkerName, + AOL defaultAOL ) throws MojoExecutionException, MojoFailureException { - File narLocation = new File( file.getParentFile(), "nar" ); - File flagFile = - new File( narLocation, FileUtils.basename( file.getPath(), "." + NarConstants.NAR_EXTENSION ) + ".flag" ); + new File( unpackDir, FileUtils.basename( file.getPath(), "." + NarConstants.NAR_EXTENSION ) + ".flag" ); boolean process = false; - if ( !narLocation.exists() ) + if ( !unpackDir.exists() ) { - narLocation.mkdirs(); + unpackDir.mkdirs(); process = true; } else if ( !flagFile.exists() ) @@ -186,7 +185,7 @@ public class NarLayout20 { try { - unpackNarAndProcess( archiverManager, file, narLocation, os, linkerName, defaultAOL ); + unpackNarAndProcess( archiverManager, file, unpackDir, os, linkerName, defaultAOL ); FileUtils.fileDelete( flagFile.getPath() ); FileUtils.fileWrite( flagFile.getPath(), "" ); } diff --git a/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java b/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java index ddfc3c2..8e70641 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java @@ -174,17 +174,17 @@ public class NarLayout21 } } - public void unpackNar( ArchiverManager archiverManager, File file, String os, String linkerName, AOL defaultAOL ) + public void unpackNar( File unpackDirectory, ArchiverManager archiverManager, File file, String os, String linkerName, + AOL defaultAOL ) throws MojoExecutionException, MojoFailureException { - File narLocation = new File( file.getParentFile(), "nar" ); - File dir = new File( narLocation, FileUtils.basename( file.getPath(), "." + NarConstants.NAR_EXTENSION ) ); + File dir = new File( unpackDirectory, FileUtils.basename( file.getPath(), "." + NarConstants.NAR_EXTENSION ) ); boolean process = false; - - if ( !narLocation.exists() ) + + if ( !unpackDirectory.exists() ) { - narLocation.mkdirs(); + unpackDirectory.mkdirs(); process = true; } else if ( !dir.exists() ) 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 e6c5b3a..7181a35 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarManager.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarManager.java @@ -357,7 +357,7 @@ public class NarManager } public final void unpackAttachedNars( List/* <NarArtifacts> */narArtifacts, ArchiverManager archiverManager, - String classifier, String os, NarLayout layout ) + String classifier, String os, NarLayout layout, File unpackDir ) throws MojoExecutionException, MojoFailureException { log.debug( "Unpack called for OS: " + os + ", classifier: " + classifier + " for NarArtifacts {" ); @@ -374,17 +374,7 @@ public class NarManager log.debug( "Unpack " + dependency ); File file = getNarFile( dependency ); - layout.unpackNar(archiverManager, file, os, linkerName, defaultAOL); + layout.unpackNar(unpackDir, archiverManager, file, os, linkerName, defaultAOL); } } - - /** - * @param narDependency - * @return - * @throws MojoFailureException - */ - public File getUnpackDirectory( Artifact narDependency ) throws MojoFailureException - { - return new File(getNarFile( narDependency ).getParentFile(), "nar"); - } } diff --git a/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java index a2f36db..921aef7 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java @@ -142,8 +142,7 @@ public class NarTestCompileMojo { Artifact artifact = (Artifact) i.next(); File include = - getLayout().getIncludeDirectory( getNarManager().getUnpackDirectory( artifact ), - artifact.getArtifactId(), artifact.getVersion() ); + getLayout().getIncludeDirectory( getUnpackDirectory(), artifact.getArtifactId(), artifact.getVersion() ); if ( include.exists() ) { task.createIncludePath().setPath( include.getPath() ); @@ -235,9 +234,8 @@ public class NarTestCompileMojo Artifact dependency = (Artifact) i.next(); // FIXME: this should be preferred binding File libDirectory = - getLayout().getLibDirectory( getNarManager().getUnpackDirectory( dependency ), - dependency.getArtifactId(), dependency.getVersion(), getAOL().toString(), - test.getLink() ); + getLayout().getLibDirectory( getUnpackDirectory(), dependency.getArtifactId(), dependency.getVersion(), + getAOL().toString(), test.getLink() ); if ( libDirectory.exists() ) { LibrarySet libset = new LibrarySet(); diff --git a/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java index c39feca..a1da230 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java @@ -155,9 +155,8 @@ public class NarTestMojo dependency.isSnapshot(); File libDirectory = - getLayout().getLibDirectory( getNarManager().getUnpackDirectory( dependency ), - dependency.getArtifactId(), dependency.getVersion(), getAOL().toString(), - Library.SHARED ); + getLayout().getLibDirectory( getUnpackDirectory(), dependency.getArtifactId(), dependency.getVersion(), + getAOL().toString(), Library.SHARED ); sharedPaths.add( libDirectory ); } diff --git a/src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java index ad4cb25..b32b0ba 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java @@ -61,13 +61,13 @@ public class NarUnpackMojo List narArtifacts = getNarManager().getNarDependencies( "compile" ); if ( classifiers == null ) { - getNarManager().unpackAttachedNars( narArtifacts, archiverManager, null, getOS(), getLayout() ); + getNarManager().unpackAttachedNars( narArtifacts, archiverManager, null, getOS(), getLayout(), getUnpackDirectory() ); } else { for ( Iterator j = classifiers.iterator(); j.hasNext(); ) { - getNarManager().unpackAttachedNars( narArtifacts, archiverManager, (String) j.next(), getOS(), getLayout() ); + getNarManager().unpackAttachedNars( narArtifacts, archiverManager, (String) j.next(), getOS(), getLayout(), getUnpackDirectory() ); } } } |