summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/AttachedNarArtifact.java6
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/Lib.java3
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarArtifact.java1
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java2
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarManager.java27
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java16
6 files changed, 18 insertions, 37 deletions
diff --git a/src/main/java/org/apache/maven/plugin/nar/AttachedNarArtifact.java b/src/main/java/org/apache/maven/plugin/nar/AttachedNarArtifact.java
index 888d50e..e6aa014 100644
--- a/src/main/java/org/apache/maven/plugin/nar/AttachedNarArtifact.java
+++ b/src/main/java/org/apache/maven/plugin/nar/AttachedNarArtifact.java
@@ -19,6 +19,8 @@ package org.apache.maven.plugin.nar;
* under the License.
*/
+import java.io.File;
+
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
@@ -34,14 +36,16 @@ public class AttachedNarArtifact
extends DefaultArtifact
{
public AttachedNarArtifact( String groupId, String artifactId, String version, String scope, String type,
- String classifier, boolean optional )
+ String classifier, boolean optional, File file )
throws InvalidVersionSpecificationException
{
super( groupId, artifactId, VersionRange.createFromVersionSpec( version ), scope, type, classifier, null,
optional );
setArtifactHandler( new Handler( classifier ) );
+ setFile(new File(file.getParentFile(), artifactId+"-"+VersionRange.createFromVersionSpec( version )+"-"+classifier+"."+type));
}
+ // NOTE: not used
public AttachedNarArtifact( Artifact parent, String type, String classifier )
{
super( parent.getGroupId(), parent.getArtifactId(), parent.getVersionRange(), parent.getScope(), type,
diff --git a/src/main/java/org/apache/maven/plugin/nar/Lib.java b/src/main/java/org/apache/maven/plugin/nar/Lib.java
index d2e7adb..e970a69 100644
--- a/src/main/java/org/apache/maven/plugin/nar/Lib.java
+++ b/src/main/java/org/apache/maven/plugin/nar/Lib.java
@@ -130,8 +130,9 @@ public class Lib
Artifact dependency = (Artifact) j.next();
if ( dependency.getGroupId().equals( ids[0] ) && dependency.getArtifactId().equals( ids[1] ) )
{
+ // FIXME NAR-90
File narDir =
- new File( mojo.getNarManager().getNarFile( dependency ).getParentFile(), "nar/lib/"
+ new File( dependency.getFile().getParentFile(), "nar/lib/"
+ mojo.getAOL() + "/" + lib.type );
String narName = dependency.getArtifactId() + "-" + lib.name + "-" + dependency.getVersion();
lib.addLibSet( mojo, linker, antProject, narName, narDir );
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarArtifact.java b/src/main/java/org/apache/maven/plugin/nar/NarArtifact.java
index 3da6abd..9758aef 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarArtifact.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarArtifact.java
@@ -36,6 +36,7 @@ public class NarArtifact
super( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersionRange(),
dependency.getScope(), dependency.getType(), dependency.getClassifier(),
dependency.getArtifactHandler(), dependency.isOptional() );
+ this.setFile( dependency.getFile() );
this.narInfo = narInfo;
}
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 8812755..40ab692 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java
@@ -100,7 +100,7 @@ public class NarCompileMojo
//
if ( dependency.getArtifactId().equals( project.getArtifactId() )
&& dependency.getGroupId().equals( project.getGroupId() )
- && dependency.getVersion().equals( project.getVersion() ) && dependency.getType().equals( "jar" ) )
+ && dependency.getVersion().equals( project.getVersion() ) && dependency.getType().equals( "nar" ) )
{
getLog().info(
"Added intermodule dependency to " + project.getArtifact() + " in "
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 4e75cd4..ee3cbdb 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarManager.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarManager.java
@@ -232,8 +232,9 @@ public class NarManager
classifier = NarUtil.replace( "${aol}", aol.toString(), classifier );
}
String version = nar.length >= 5 ? nar[4].trim() : dependency.getVersion();
+ File file = dependency.getFile();
artifactList.add( new AttachedNarArtifact( groupId, artifactId, version, dependency.getScope(),
- ext, classifier, dependency.isOptional() ) );
+ ext, classifier, dependency.isOptional(), file ) );
}
catch ( InvalidVersionSpecificationException e )
{
@@ -258,12 +259,7 @@ public class NarManager
// of getBaseVersion, called in pathOf.
dependency.isSnapshot();
- File file = new File( repository.getBasedir(), repository.pathOf( dependency ) );
- if ( !file.exists() )
- {
- return null;
- }
-
+ File file = dependency.getFile();
JarFile nar = null;
try
{
@@ -297,16 +293,6 @@ public class NarManager
}
}
- public final File getNarFile( Artifact dependency )
- throws MojoFailureException
- {
- // FIXME reported to maven developer list, isSnapshot changes behaviour
- // of getBaseVersion, called in pathOf.
- dependency.isSnapshot();
- return new File( repository.getBasedir(), NarUtil.replace( "${aol}", defaultAOL.toString(),
- repository.pathOf( dependency ) ) );
- }
-
private List getDependencies( String scope )
{
if ( scope.equals( Artifact.SCOPE_TEST ) )
@@ -338,6 +324,10 @@ public class NarManager
for ( Iterator i = dependencies.iterator(); i.hasNext(); )
{
Artifact dependency = (Artifact) i.next();
+ File file = dependency.getFile();
+ if ( file != null && file.exists() )
+ continue;
+
try
{
log.debug( "Resolving " + dependency );
@@ -372,9 +362,8 @@ public class NarManager
{
Artifact dependency = (Artifact) i.next();
log.debug( "Unpack " + dependency );
- File file = getNarFile( dependency );
- layout.unpackNar(unpackDir, archiverManager, file, os, linkerName, defaultAOL);
+ layout.unpackNar( unpackDir, archiverManager, dependency.getFile(), os, linkerName, defaultAOL );
}
}
}
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 8c55f5c..4fd8de6 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java
@@ -22,7 +22,6 @@ 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;
@@ -38,15 +37,7 @@ import org.codehaus.plexus.archiver.manager.ArchiverManager;
*/
public class NarPackageMojo
extends AbstractCompileMojo
-{
- /**
- * NAR-121 was nar-package
- *
- * @component role="org.apache.maven.artifact.handler.ArtifactHandler" roleHint="nar"
- * @required
- */
- private ArtifactHandler narArtifactHandler;
-
+{
/**
* To look up Archiver/UnArchiver implementations
*
@@ -65,11 +56,6 @@ public class NarPackageMojo
public final void narExecute()
throws MojoExecutionException, MojoFailureException
{
- // Avoid that -DupdateReleaseInfo copies to a .nar file
- // 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() );