summaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/AbstractNarLayout.java13
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarConstants.java2
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarLayout.java3
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarLayout20.java9
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarLayout21.java7
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarManager.java4
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java21
7 files changed, 41 insertions, 18 deletions
diff --git a/src/main/java/org/apache/maven/plugin/nar/AbstractNarLayout.java b/src/main/java/org/apache/maven/plugin/nar/AbstractNarLayout.java
index 21e67e5..e5dc7b5 100644
--- a/src/main/java/org/apache/maven/plugin/nar/AbstractNarLayout.java
+++ b/src/main/java/org/apache/maven/plugin/nar/AbstractNarLayout.java
@@ -27,10 +27,11 @@ import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
+import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
import org.codehaus.plexus.archiver.zip.ZipArchiver;
/**
- *
* @author Mark Donszelmann (Mark.Donszelmann@gmail.com)
* @version $Id$
*/
@@ -38,8 +39,8 @@ public abstract class AbstractNarLayout
implements NarLayout, NarConstants
{
- protected final void attachNar( MavenProjectHelper projectHelper, MavenProject project, String classifier, File dir,
- String include )
+ protected final void attachNar( ArchiverManager archiverManager, MavenProjectHelper projectHelper, MavenProject project,
+ String classifier, File dir, String include )
throws MojoExecutionException
{
File narFile =
@@ -49,13 +50,17 @@ public abstract class AbstractNarLayout
{
narFile.delete();
}
- Archiver archiver = new ZipArchiver();
try
{
+ Archiver archiver = archiverManager.getArchiver( NarConstants.NAR_ROLE_HINT );
archiver.addDirectory( dir, new String[] { include }, null );
archiver.setDestFile( narFile );
archiver.createArchive();
}
+ catch ( NoSuchArchiverException e )
+ {
+ throw new MojoExecutionException( "NAR: cannot find archiver", e );
+ }
catch ( ArchiverException e )
{
throw new MojoExecutionException( "NAR: cannot create NAR archive '" + narFile + "'", e );
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarConstants.java b/src/main/java/org/apache/maven/plugin/nar/NarConstants.java
index 5969c64..a176f18 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarConstants.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarConstants.java
@@ -32,7 +32,7 @@ public interface NarConstants
String NAR_AOL = "aol";
- String NAR_ROLE_HINT = "nar-library";
+ String NAR_ROLE_HINT = NAR;
String NAR_TYPE = NAR;
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 9d03cff..062bec9 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarLayout.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout.java
@@ -6,6 +6,7 @@ import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
/*
@@ -61,6 +62,6 @@ public interface NarLayout
* Called to attach nars to main jar file. This method needs to produce all the attached nar files and set NarInfo
* accordingly.
*/
- void attachNars( File baseDir, MavenProjectHelper projectHelper, MavenProject project, NarInfo narInfo )
+ void attachNars( File baseDir, ArchiverManager archiverManager, MavenProjectHelper projectHelper, MavenProject project, NarInfo narInfo )
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 140007f..23b9f19 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java
@@ -6,6 +6,7 @@ import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -85,12 +86,12 @@ public class NarLayout20
* @see org.apache.maven.plugin.nar.NarLayout#attachNars(java.io.File, org.apache.maven.project.MavenProjectHelper,
* org.apache.maven.project.MavenProject, org.apache.maven.plugin.nar.NarInfo)
*/
- public final void attachNars( File baseDir, MavenProjectHelper projectHelper, MavenProject project, NarInfo narInfo )
+ public final void attachNars( File baseDir, ArchiverManager archiverManager, MavenProjectHelper projectHelper, MavenProject project, NarInfo narInfo )
throws MojoExecutionException
{
if ( getIncludeDirectory( baseDir ).exists() )
{
- attachNar( projectHelper, project, "noarch", baseDir, "include/**" );
+ attachNar( archiverManager, projectHelper, project, "noarch", baseDir, "include/**" );
narInfo.setNar( null, "noarch", project.getGroupId() + ":" + project.getArtifactId() + ":"
+ NarConstants.NAR_TYPE + ":" + "noarch" );
}
@@ -98,7 +99,7 @@ public class NarLayout20
String[] binAOL = new File( baseDir, "bin" ).list();
for ( int i = 0; ( binAOL != null ) && ( i < binAOL.length ); i++ )
{
- attachNar( projectHelper, project, binAOL[i] + "-" + Library.EXECUTABLE, baseDir, "bin/" + binAOL[i]
+ attachNar( archiverManager, projectHelper, project, binAOL[i] + "-" + Library.EXECUTABLE, baseDir, "bin/" + binAOL[i]
+ "/**" );
narInfo.setNar( null, Library.EXECUTABLE, project.getGroupId() + ":" + project.getArtifactId() + ":"
+ NarConstants.NAR_TYPE + ":" + "${aol}" + "-" + Library.EXECUTABLE );
@@ -114,7 +115,7 @@ public class NarLayout20
String[] libType = new File( libDir, libAOL[i] ).list();
for ( int j = 0; ( libType != null ) && ( j < libType.length ); j++ )
{
- attachNar( projectHelper, project, libAOL[i] + "-" + libType[j], baseDir, "lib/" + libAOL[i] + "/"
+ attachNar( archiverManager, projectHelper, project, libAOL[i] + "-" + libType[j], baseDir, "lib/" + libAOL[i] + "/"
+ libType[j] + "/**" );
narInfo.setNar( null, libType[j], project.getGroupId() + ":" + project.getArtifactId() + ":"
+ NarConstants.NAR_TYPE + ":" + "${aol}" + "-" + libType[j] );
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 9968caf..8301330 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java
@@ -5,6 +5,7 @@ import java.io.File;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -104,12 +105,12 @@ public class NarLayout21
* @see org.apache.maven.plugin.nar.NarLayout#attachNars(java.io.File, org.apache.maven.project.MavenProjectHelper,
* org.apache.maven.project.MavenProject, org.apache.maven.plugin.nar.NarInfo)
*/
- public final void attachNars( File baseDir, MavenProjectHelper projectHelper, MavenProject project, NarInfo narInfo )
+ public final void attachNars( File baseDir, ArchiverManager archiverManager, MavenProjectHelper projectHelper, MavenProject project, NarInfo narInfo )
throws MojoExecutionException
{
if ( getNoarchDirectory( baseDir ).exists() )
{
- attachNar( projectHelper, project, NarConstants.NAR_NO_ARCH, getNoarchDirectory( baseDir ), "*/**" );
+ attachNar( archiverManager, projectHelper, project, NarConstants.NAR_NO_ARCH, getNoarchDirectory( baseDir ), "*/**" );
narInfo.setNar( null, NarConstants.NAR_NO_ARCH, project.getGroupId() + ":" + project.getArtifactId() + ":"
+ NarConstants.NAR_TYPE + ":" + NarConstants.NAR_NO_ARCH );
}
@@ -119,7 +120,7 @@ public class NarLayout21
for ( int i = 0; ( classifier != null ) && ( i < classifier.length ); i++ )
{
File dir = new File( classifierDir, classifier[i] );
- attachNar( projectHelper, project, classifier[i], dir, "*/**" );
+ attachNar( archiverManager, projectHelper, project, classifier[i], dir, "*/**" );
String type = null;
AOL aol = null;
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 54694f1..5bb83fc 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarManager.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarManager.java
@@ -434,13 +434,13 @@ public class NarManager
}
}
- private void unpackNar( ArchiverManager manager, File file, File location )
+ private void unpackNar( ArchiverManager archiverManager, File file, File location )
throws MojoExecutionException
{
try
{
UnArchiver unArchiver;
- unArchiver = manager.getUnArchiver( NarConstants.NAR_ROLE_HINT );
+ unArchiver = archiverManager.getUnArchiver( NarConstants.NAR_ROLE_HINT );
unArchiver.setSourceFile( file );
unArchiver.setDestDirectory( location );
unArchiver.extract();
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 772b1b9..1f21490 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java
@@ -22,9 +22,11 @@ package org.apache.maven.plugin.nar;
import java.io.File;
import java.io.IOException;
+import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProjectHelper;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
/**
* Jars up the NAR files.
@@ -37,7 +39,20 @@ import org.apache.maven.project.MavenProjectHelper;
public class NarPackageMojo
extends AbstractCompileMojo
{
-
+ /**
+ * @component role="org.apache.maven.artifact.handler.ArtifactHandler" roleHint="nar-package"
+ * @required
+ */
+ private ArtifactHandler narArtifactHandler;
+
+ /**
+ * To look up Archiver/UnArchiver implementations
+ *
+ * @component role="org.codehaus.plexus.archiver.manager.ArchiverManager"
+ * @required
+ */
+ private ArchiverManager archiverManager;
+
/**
* Used for attaching the artifact in the project
*
@@ -54,10 +69,10 @@ public class NarPackageMojo
}
// Avoid that -DupdateReleaseInfo copies to a .nar file
- getMavenProject().getArtifact().setArtifactHandler( new NarArtifactHandler() );
+ getMavenProject().getArtifact().setArtifactHandler( narArtifactHandler );
// let the layout decide which nars to attach
- getLayout().attachNars( getTargetDirectory(), projectHelper, getMavenProject(), getNarInfo() );
+ getLayout().attachNars( getTargetDirectory(), archiverManager, projectHelper, getMavenProject(), getNarInfo() );
try
{