From 5e248c00779692c8cd3763de1de4707b7a6591a8 Mon Sep 17 00:00:00 2001 From: Mark Donszelmann Date: Tue, 1 Dec 2009 15:38:04 +0100 Subject: Fixed NAR-13 --- .../apache/maven/plugin/nar/AbstractNarMojo.java | 61 +++++++++++++++++++--- .../apache/maven/plugin/nar/NarAssemblyMojo.java | 31 ++--------- .../apache/maven/plugin/nar/NarCompileMojo.java | 9 +--- .../apache/maven/plugin/nar/NarDownloadMojo.java | 9 +--- .../maven/plugin/nar/NarGnuConfigureMojo.java | 8 +-- .../apache/maven/plugin/nar/NarGnuMakeMojo.java | 9 +--- .../org/apache/maven/plugin/nar/NarGnuProcess.java | 9 +--- .../apache/maven/plugin/nar/NarGnuResources.java | 9 +--- .../maven/plugin/nar/NarIntegrationTestMojo.java | 11 +--- .../org/apache/maven/plugin/nar/NarJavahMojo.java | 9 +--- .../apache/maven/plugin/nar/NarPackageMojo.java | 9 +--- .../apache/maven/plugin/nar/NarResourcesMojo.java | 9 +--- .../org/apache/maven/plugin/nar/NarSystemMojo.java | 9 +--- .../maven/plugin/nar/NarTestCompileMojo.java | 9 +--- .../org/apache/maven/plugin/nar/NarTestMojo.java | 9 +--- .../org/apache/maven/plugin/nar/NarUnpackMojo.java | 9 +--- .../apache/maven/plugin/nar/NarValidateMojo.java | 16 +----- 17 files changed, 74 insertions(+), 161 deletions(-) (limited to 'src/main') 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 5c6bdc1..3725d71 100644 --- a/src/main/java/org/apache/maven/plugin/nar/AbstractNarMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/AbstractNarMojo.java @@ -41,6 +41,13 @@ public abstract class AbstractNarMojo */ private boolean skip; + /** + * Ignore errors and failures. + * + * @parameter expression="${nar.ignore}" default-value="false" + */ + private boolean ignore; + /** * The Architecture for the nar, Some choices are: "x86", "i386", "amd64", "ppc", "sparc", ... Defaults to a derived * value from ${os.arch} @@ -98,10 +105,12 @@ public abstract class AbstractNarMojo * @required */ private MavenProject mavenProject; - + private AOL aolId; - protected final void validate() throws MojoFailureException, MojoExecutionException { + protected final void validate() + throws MojoFailureException, MojoExecutionException + { linker = NarUtil.getLinker( linker ); architecture = NarUtil.getArchitecture( architecture ); @@ -113,14 +122,9 @@ public abstract class AbstractNarMojo targetDirectory = new File( mavenProject.getBuild().getDirectory(), "nar" ); } } - - protected final boolean shouldSkip() - { - return skip; - } protected final String getArchitecture() - { + { return architecture; } @@ -159,4 +163,45 @@ public abstract class AbstractNarMojo { return mavenProject; } + + public final void execute() + throws MojoExecutionException, MojoFailureException + { + if ( skip ) + { + getLog().info( getClass().getName() + " skipped" ); + return; + } + + try + { + validate(); + narExecute(); + } + catch ( MojoFailureException mfe ) + { + if ( ignore ) + { + getLog().warn( "IGNORED: " + mfe.getMessage() ); + } + else + { + throw mfe; + } + } + catch ( MojoExecutionException mee ) + { + if ( ignore ) + { + getLog().warn( "IGNORED: " + mee.getMessage() ); + } + else + { + throw mee; + } + } + } + + public abstract void narExecute() + throws MojoFailureException, MojoExecutionException; } diff --git a/src/main/java/org/apache/maven/plugin/nar/NarAssemblyMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarAssemblyMojo.java index 846aba1..e5dd1dc 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarAssemblyMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarAssemblyMojo.java @@ -54,20 +54,9 @@ public class NarAssemblyMojo /** * Copies the unpacked nar libraries and files into the projects target area */ - public final void execute() + public final void narExecute() throws MojoExecutionException, MojoFailureException { - if ( shouldSkip() ) - { - getLog().info( "***********************************************************************" ); - getLog().info( "NAR Assembly SKIPPED since no NAR libraries were built/downloaded." ); - getLog().info( "***********************************************************************" ); - // NOTE: continue since the standard assemble mojo fails if we do - // not create the directories... - } - - validate(); - for ( Iterator j = classifiers.iterator(); j.hasNext(); ) { String classifier = (String) j.next(); @@ -92,22 +81,10 @@ public class NarAssemblyMojo try { FileUtils.mkdir( dstDir.getPath() ); - if ( shouldSkip() ) - { - File note = new File( dstDir, "NAR_ASSEMBLY_SKIPPED" ); - FileUtils.fileWrite( - note.getPath(), - "The NAR Libraries of this distribution are missing because \n" - + "the NAR dependencies were not built/downloaded, presumably because\n" - + "the the distribution was built with the '-Dnar.skip=true' flag." ); - } - else + getLog().debug( "SrcDir: " + srcDir ); + if ( srcDir.exists() ) { - getLog().debug( "SrcDir: " + srcDir ); - if ( srcDir.exists() ) - { - FileUtils.copyDirectoryStructure( srcDir, dstDir ); - } + FileUtils.copyDirectoryStructure( srcDir, dstDir ); } } catch ( IOException ioe ) 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 fcdd322..f773211 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java @@ -55,16 +55,9 @@ import org.codehaus.plexus.util.StringUtils; public class NarCompileMojo extends AbstractCompileMojo { - public final void execute() + public final void narExecute() throws MojoExecutionException, MojoFailureException { - if ( shouldSkip() ) - { - return; - } - - validate(); - // make sure destination is there getTargetDirectory().mkdirs(); 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 ea049fa..d7f6343 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarDownloadMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarDownloadMojo.java @@ -64,16 +64,9 @@ public class NarDownloadMojo */ private List classifiers; - public final void execute() + public final void narExecute() throws MojoExecutionException, MojoFailureException { - if ( shouldSkip() ) - { - return; - } - - validate(); - List narArtifacts = getNarManager().getNarDependencies( "compile" ); if ( classifiers == null ) { diff --git a/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java index c6f4eb4..4e15f48 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java @@ -55,15 +55,9 @@ public class NarGnuConfigureMojo private static final String CONFIGURE = "configure"; - public final void execute() + public final void narExecute() throws MojoExecutionException, MojoFailureException { - if ( shouldSkip() ) - { - return; - } - - validate(); if ( !useGnu() ) { diff --git a/src/main/java/org/apache/maven/plugin/nar/NarGnuMakeMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarGnuMakeMojo.java index c99e0d3..b2eae70 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarGnuMakeMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarGnuMakeMojo.java @@ -35,16 +35,9 @@ import org.apache.maven.plugin.MojoFailureException; public class NarGnuMakeMojo extends AbstractGnuMojo { - public final void execute() + public final void narExecute() throws MojoExecutionException, MojoFailureException { - if ( shouldSkip() ) - { - return; - } - - validate(); - if ( !useGnu() ) { return; diff --git a/src/main/java/org/apache/maven/plugin/nar/NarGnuProcess.java b/src/main/java/org/apache/maven/plugin/nar/NarGnuProcess.java index f919d92..7bbf48f 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarGnuProcess.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarGnuProcess.java @@ -35,16 +35,9 @@ import org.apache.maven.plugin.MojoFailureException; public class NarGnuProcess extends AbstractGnuMojo { - public final void execute() + public final void narExecute() throws MojoExecutionException, MojoFailureException { - if ( shouldSkip() ) - { - return; - } - - validate(); - File srcDir = getGnuAOLTargetDirectory(); if ( srcDir.exists() ) { diff --git a/src/main/java/org/apache/maven/plugin/nar/NarGnuResources.java b/src/main/java/org/apache/maven/plugin/nar/NarGnuResources.java index 39eb3a5..0122ebc 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarGnuResources.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarGnuResources.java @@ -35,16 +35,9 @@ import org.apache.maven.plugin.MojoFailureException; public class NarGnuResources extends AbstractGnuMojo { - public final void execute() + public final void narExecute() throws MojoExecutionException, MojoFailureException { - if ( shouldSkip() ) - { - return; - } - - validate(); - if ( getGnuSourceDirectory().exists() ) { int copied = 0; 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 bd86ed8..ffab127 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java @@ -555,12 +555,10 @@ public class NarIntegrationTestMojo private MavenSession session; - public void execute() + // DUNS, changed name + public void narExecute() throws MojoExecutionException, MojoFailureException { - // DUNS - validate(); - if ( verifyParameters() ) { SurefireBooter surefireBooter = constructSurefireBooter(); @@ -622,11 +620,6 @@ public class NarIntegrationTestMojo private boolean verifyParameters() throws MojoFailureException { - // DUNS - if (shouldSkip() ) { - return false; - } - // DUNS if ( skipNar || skipNarTests || skipNarExec ) { diff --git a/src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java index c570461..9edc963 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java @@ -57,16 +57,9 @@ public class NarJavahMojo return session; } - public final void execute() + public final void narExecute() throws MojoExecutionException, MojoFailureException { - if ( shouldSkip() ) - { - return; - } - - validate(); - getJavah().execute(); } } \ No newline at end of file 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 751f85c..f2a01ec 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java @@ -60,16 +60,9 @@ public class NarPackageMojo */ private MavenProjectHelper projectHelper; - public final void execute() + public final void narExecute() throws MojoExecutionException, MojoFailureException { - if ( shouldSkip() ) - { - return; - } - - validate(); - // Avoid that -DupdateReleaseInfo copies to a .nar file getMavenProject().getArtifact().setArtifactHandler( narArtifactHandler ); 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 e3fcfe0..fa05acd 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java @@ -54,16 +54,9 @@ public class NarResourcesMojo */ private File resourceDirectory; - public final void execute() + public final void narExecute() throws MojoExecutionException, MojoFailureException { - if ( shouldSkip() ) - { - return; - } - - validate(); - // scan resourceDirectory for AOLs File aolDir = new File( resourceDirectory, NarConstants.NAR_AOL ); if ( aolDir.exists() ) diff --git a/src/main/java/org/apache/maven/plugin/nar/NarSystemMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarSystemMojo.java index c778228..0eb2905 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarSystemMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarSystemMojo.java @@ -40,16 +40,9 @@ public class NarSystemMojo extends AbstractCompileMojo { - public final void execute() + public final void narExecute() throws MojoExecutionException, MojoFailureException { - if ( shouldSkip() ) - { - return; - } - - validate(); - // get packageName if specified for JNI. String packageName = null; String narSystemName = null; 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 db5c3bf..70fcd8b 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java @@ -56,16 +56,9 @@ public class NarTestCompileMojo */ private boolean skipNar; - public final void execute() + public final void narExecute() throws MojoExecutionException, MojoFailureException { - if ( shouldSkip() || skipNar) - { - return; - } - - validate(); - // make sure destination is there getTestTargetDirectory().mkdirs(); 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 d361728..db4e68d 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java @@ -52,16 +52,9 @@ public class NarTestMojo */ private List classpathElements; - public final void execute() + public final void narExecute() throws MojoExecutionException, MojoFailureException { - if ( shouldSkip() ) - { - return; - } - - validate(); - // run all tests for ( Iterator i = getTests().iterator(); i.hasNext(); ) { 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 0e9d347..991f3e3 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java @@ -55,16 +55,9 @@ public class NarUnpackMojo */ private ArchiverManager archiverManager; - public final void execute() + public final void narExecute() throws MojoExecutionException, MojoFailureException { - if ( shouldSkip() ) - { - return; - } - - validate(); - List narArtifacts = getNarManager().getNarDependencies( "compile" ); if ( classifiers == null ) { diff --git a/src/main/java/org/apache/maven/plugin/nar/NarValidateMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarValidateMojo.java index d6e0e48..e299dfb 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarValidateMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarValidateMojo.java @@ -33,21 +33,9 @@ import org.apache.maven.plugin.MojoFailureException; public class NarValidateMojo extends AbstractCompileMojo { - public final void execute() + public final void narExecute() throws MojoExecutionException, MojoFailureException - { - if ( shouldSkip() ) - { - getLog().info( "***********************************************************************" ); - getLog().info( "NAR Plugin SKIPPED, no NAR Libraries will be produced." ); - getLog().info( "***********************************************************************" ); - - return; - } - - // first validate - validate(); - + { // check aol AOL aol = getAOL(); getLog().info( "Using AOL: " + aol ); -- cgit v1.2.3