From cd4ddec0a0c14db770877eb0211327c57c0cff08 Mon Sep 17 00:00:00 2001 From: Mark Donszelmann Date: Wed, 2 Dec 2009 15:17:54 +0100 Subject: Fixed NAR-12 --- .../maven/plugin/nar/AbstractResourcesMojo.java | 6 +++--- .../java/org/apache/maven/plugin/nar/Linker.java | 2 +- .../java/org/apache/maven/plugin/nar/NarLayout.java | 20 +++++++++++++++----- .../org/apache/maven/plugin/nar/NarLayout20.java | 9 +++++++++ .../org/apache/maven/plugin/nar/NarLayout21.java | 8 ++++---- .../apache/maven/plugin/nar/NarResourcesMojo.java | 19 +++++++++++++++++++ 6 files changed, 51 insertions(+), 13 deletions(-) (limited to 'src/main/java/org/apache/maven') diff --git a/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java b/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java index 2aedf8b..2b6b5bb 100644 --- a/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java @@ -168,15 +168,15 @@ public abstract class AbstractResourcesMojo } catch ( IOException e ) { - throw new MojoExecutionException( "NAR: Could not copy resources", e ); + throw new MojoExecutionException( "NAR: Could not copy resources for " + aol, e ); } catch ( NoSuchArchiverException e ) { - throw new MojoExecutionException( "NAR: Could not find archiver", e ); + throw new MojoExecutionException( "NAR: Could not find archiver for " + aol, e ); } catch ( ArchiverException e ) { - throw new MojoExecutionException( "NAR: Could not unarchive jar file", e ); + throw new MojoExecutionException( "NAR: Could not unarchive jar file for " + aol, e ); } getLog().info( "Copied " + copied + " resources for " + aol ); } diff --git a/src/main/java/org/apache/maven/plugin/nar/Linker.java b/src/main/java/org/apache/maven/plugin/nar/Linker.java index 51c89cb..9b9edcb 100644 --- a/src/main/java/org/apache/maven/plugin/nar/Linker.java +++ b/src/main/java/org/apache/maven/plugin/nar/Linker.java @@ -177,7 +177,7 @@ public class Linker return name; } - public final String getVersion() + public final String getVersion() throws MojoFailureException, MojoExecutionException { if ( name == null ) 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 062bec9..cdb4ba7 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarLayout.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout.java @@ -36,32 +36,42 @@ import org.codehaus.plexus.archiver.manager.ArchiverManager; */ public interface NarLayout { + /** + * Specifies where all the "no architecture" specific files are stored + */ + File getNoArchDirectory( File baseDir ) + throws MojoExecutionException, MojoFailureException; + /** * Specifies where libraries are stored * * @return - * @throws MojoExecutionException, MojoFailureException + * @throws MojoExecutionException, MojoFailureException */ - File getLibDirectory( File baseDir, String aol, String type ) throws MojoExecutionException, MojoFailureException; + File getLibDirectory( File baseDir, String aol, String type ) + throws MojoExecutionException, MojoFailureException; /** * Specifies where includes are stored * * @return */ - File getIncludeDirectory( File targetDirectory ) throws MojoExecutionException, MojoFailureException; + File getIncludeDirectory( File baseDir ) + throws MojoExecutionException, MojoFailureException; /** * Specifies where binaries are stored * * @return */ - File getBinDirectory( File baseDir, String aol ) throws MojoExecutionException, MojoFailureException; + File getBinDirectory( File baseDir, String aol ) + throws MojoExecutionException, MojoFailureException; /** * 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, ArchiverManager archiverManager, 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 23b9f19..e2e0207 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java @@ -44,6 +44,15 @@ import org.codehaus.plexus.archiver.manager.ArchiverManager; public class NarLayout20 extends AbstractNarLayout { + /* (non-Javadoc) + * @see org.apache.maven.plugin.nar.NarLayout#getNoArchDirectory(java.io.File) + */ + public File getNoArchDirectory( File baseDir ) + throws MojoExecutionException, MojoFailureException + { + return baseDir; + } + /* * (non-Javadoc) * @see org.apache.maven.plugin.nar.NarLayout#getIncludeDirectory(java.io.File) 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 8301330..623e3fa 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java @@ -42,7 +42,7 @@ import org.codehaus.plexus.archiver.manager.ArchiverManager; public class NarLayout21 extends AbstractNarLayout { - private File getNoarchDirectory( File baseDir ) + public File getNoArchDirectory( File baseDir ) { return new File( baseDir, NarConstants.NAR_NO_ARCH ); } @@ -63,7 +63,7 @@ public class NarLayout21 */ public final File getIncludeDirectory( File baseDir ) { - return new File( getNoarchDirectory( baseDir ), "include" ); + return new File( getNoArchDirectory( baseDir ), "include" ); } /* @@ -108,9 +108,9 @@ public class NarLayout21 public final void attachNars( File baseDir, ArchiverManager archiverManager, MavenProjectHelper projectHelper, MavenProject project, NarInfo narInfo ) throws MojoExecutionException { - if ( getNoarchDirectory( baseDir ).exists() ) + if ( getNoArchDirectory( baseDir ).exists() ) { - attachNar( archiverManager, 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 ); } diff --git a/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java index fa05acd..b730a52 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java @@ -20,6 +20,7 @@ package org.apache.maven.plugin.nar; */ import java.io.File; +import java.io.IOException; import java.util.Iterator; import org.apache.maven.plugin.MojoExecutionException; @@ -57,6 +58,24 @@ public class NarResourcesMojo public final void narExecute() throws MojoExecutionException, MojoFailureException { + // noarch resources + try + { + int copied = 0; + File noarchDir = new File( resourceDirectory, NarConstants.NAR_NO_ARCH ); + if ( noarchDir.exists() ) + { + File noarchDstDir = getLayout().getNoArchDirectory( getTargetDirectory() ); + getLog().debug( "Copying noarch from " + noarchDir + " to " + noarchDstDir ); + copied += NarUtil.copyDirectoryStructure( noarchDir, noarchDstDir, null, NarUtil.DEFAULT_EXCLUDES ); + } + getLog().info( "Copied " + copied + " resources" ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "NAR: Could not copy resources", e ); + } + // scan resourceDirectory for AOLs File aolDir = new File( resourceDirectory, NarConstants.NAR_AOL ); if ( aolDir.exists() ) -- cgit v1.2.3