From bfe32fa8112c622d29026549091716776240ba3b Mon Sep 17 00:00:00 2001 From: Mark Donszelmann Date: Fri, 18 Dec 2009 14:31:04 +0100 Subject: Fixed NAR-121 --- .../java/org/apache/maven/plugin/nar/NarDownloadMojo.java | 4 ++-- .../org/apache/maven/plugin/nar/NarIntegrationTestMojo.java | 6 +++--- src/main/java/org/apache/maven/plugin/nar/NarLayout.java | 2 +- src/main/java/org/apache/maven/plugin/nar/NarManager.java | 12 ++++++------ .../java/org/apache/maven/plugin/nar/NarPackageMojo.java | 10 +++++++--- src/main/resources/META-INF/plexus/components.xml | 6 ++++++ 6 files changed, 25 insertions(+), 15 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/apache/maven/plugin/nar/NarDownloadMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarDownloadMojo.java index d7f6343..fa83de7 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarDownloadMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarDownloadMojo.java @@ -40,7 +40,7 @@ public class NarDownloadMojo { /** - * Artifact resolver, needed to download source jars for inclusion in classpath. + * Artifact resolver, needed to download the attached nar files. * * @component role="org.apache.maven.artifact.resolver.ArtifactResolver" * @required @@ -49,7 +49,7 @@ public class NarDownloadMojo private ArtifactResolver artifactResolver; /** - * Remote repositories which will be searched for source attachments. + * Remote repositories which will be searched for nar attachments. * * @parameter expression="${project.remoteArtifactRepositories}" * @required 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 ac4fcf7..7f929bf 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java @@ -999,9 +999,9 @@ public class NarIntegrationTestMojo // add jar file to classpath, as one may want to read a // properties file for artifactId and version - String jarFile = "target/" + project.getArtifactId() + "-" + project.getVersion() + ".jar"; - getLog().debug( "Adding to surefire test classpath: " + jarFile ); - surefireBooter.addClassPathUrl( jarFile ); + String narFile = "target/" + project.getArtifactId() + "-" + project.getVersion() + ".jar"; + getLog().debug( "Adding to surefire test classpath: " + narFile ); + surefireBooter.addClassPathUrl( narFile ); } List dependencies = getNarManager().getNarDependencies( "test" ); 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 9529473..6e12eaa 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarLayout.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout.java @@ -68,7 +68,7 @@ public interface NarLayout throws MojoExecutionException, MojoFailureException; /** - * Called to attach nars to main jar file. This method needs to produce all the attached nar files and set NarInfo + * Called to attach nars to main nar/jar file. This method needs to produce all the attached nar files and set NarInfo * accordingly. */ void attachNars( File baseDir, ArchiverManager archiverManager, MavenProjectHelper projectHelper, 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 7181a35..4e75cd4 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarManager.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarManager.java @@ -264,17 +264,17 @@ public class NarManager return null; } - JarFile jar = null; + JarFile nar = null; try { - jar = new JarFile( file ); + nar = new JarFile( file ); NarInfo info = new NarInfo( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), log ); - if ( !info.exists( jar ) ) + if ( !info.exists( nar ) ) { return null; } - info.read( jar ); + info.read( nar ); return info; } catch ( IOException e ) @@ -283,11 +283,11 @@ public class NarManager } finally { - if ( jar != null ) + if ( nar != null ) { try { - jar.close(); + nar.close(); } catch ( IOException e ) { diff --git a/src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java index f2a01ec..8c55f5c 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java @@ -40,7 +40,9 @@ public class NarPackageMojo extends AbstractCompileMojo { /** - * @component role="org.apache.maven.artifact.handler.ArtifactHandler" roleHint="nar-package" + * NAR-121 was nar-package + * + * @component role="org.apache.maven.artifact.handler.ArtifactHandler" roleHint="nar" * @required */ private ArtifactHandler narArtifactHandler; @@ -64,8 +66,10 @@ public class NarPackageMojo throws MojoExecutionException, MojoFailureException { // Avoid that -DupdateReleaseInfo copies to a .nar file - getMavenProject().getArtifact().setArtifactHandler( narArtifactHandler ); - + // NAR-121 +// getMavenProject().getArtifact().setArtifactHandler( narArtifactHandler ); + System.err.println("***"+getMavenProject().getArtifact().getArtifactHandler().getExtension()); + System.err.println("***"+getFinalName()); // let the layout decide which nars to attach getLayout().attachNars( getTargetDirectory(), archiverManager, projectHelper, getMavenProject(), getNarInfo() ); diff --git a/src/main/resources/META-INF/plexus/components.xml b/src/main/resources/META-INF/plexus/components.xml index 4b508c1..aa6d8b2 100644 --- a/src/main/resources/META-INF/plexus/components.xml +++ b/src/main/resources/META-INF/plexus/components.xml @@ -73,12 +73,18 @@ org.apache.maven.artifact.handler.ArtifactHandler + + nar org.apache.maven.artifact.handler.DefaultArtifactHandler nar + + nar nar java true -- cgit v1.2.3