summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Donszelmann <Mark.Donszelmann@gmail.com>2009-11-17 16:33:28 +0100
committerMark Donszelmann <Mark.Donszelmann@gmail.com>2009-11-17 16:33:28 +0100
commit0975240ce6b505db32a87233f31c8d1377b14c54 (patch)
treeedf3933a3bd151673c3ab1bb9338c4411bab89c2
parentbb9f382d1024e60f672b9c484031f40772a54a4b (diff)
downloadmaven-nar-plugin-0975240ce6b505db32a87233f31c8d1377b14c54.tar.gz
maven-nar-plugin-0975240ce6b505db32a87233f31c8d1377b14c54.tar.bz2
maven-nar-plugin-0975240ce6b505db32a87233f31c8d1377b14c54.tar.xz
maven-nar-plugin-0975240ce6b505db32a87233f31c8d1377b14c54.zip
Cleanup
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/AOL.java2
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java36
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/AbstractGnuMojo.java6
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/AbstractNarMojo.java18
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/Compiler.java18
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/Java.java3
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/Javah.java4
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/Library.java34
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/Linker.java4
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java5
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarGnuResources.java4
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarInfo.java34
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java3
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java12
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarLayout20.java10
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarLayout21.java4
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarManager.java18
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java12
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java15
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarUtil.java37
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/Test.java8
21 files changed, 152 insertions, 135 deletions
diff --git a/src/main/java/org/apache/maven/plugin/nar/AOL.java b/src/main/java/org/apache/maven/plugin/nar/AOL.java
index 97306bc..105fca9 100644
--- a/src/main/java/org/apache/maven/plugin/nar/AOL.java
+++ b/src/main/java/org/apache/maven/plugin/nar/AOL.java
@@ -47,7 +47,7 @@ public class AOL
break;
default:
- throw new RuntimeException( "AOL '" + aol + "' cannot be parsed." );
+ throw new IllegalArgumentException( "AOL '" + aol + "' cannot be parsed." );
}
}
diff --git a/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java b/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java
index 98a4640..d51861b 100644
--- a/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java
@@ -144,7 +144,7 @@ public abstract class AbstractCompileMojo
private Project antProject;
- protected Project getAntProject()
+ protected final Project getAntProject()
{
if ( antProject == null )
{
@@ -156,7 +156,7 @@ public abstract class AbstractCompileMojo
return antProject;
}
- protected C getC()
+ protected final C getC()
{
if ( c == null )
{
@@ -166,7 +166,7 @@ public abstract class AbstractCompileMojo
return c;
}
- protected Cpp getCpp()
+ protected final Cpp getCpp()
{
if ( cpp == null )
{
@@ -176,7 +176,7 @@ public abstract class AbstractCompileMojo
return cpp;
}
- protected Fortran getFortran()
+ protected final Fortran getFortran()
{
if ( fortran == null )
{
@@ -186,38 +186,38 @@ public abstract class AbstractCompileMojo
return fortran;
}
- protected int getMaxCores( AOL aol ) throws MojoExecutionException
+ protected final int getMaxCores( AOL aol ) throws MojoExecutionException
{
return getNarInfo().getProperty( aol, "maxCores", maxCores );
}
- protected boolean useLibtool( AOL aol ) throws MojoExecutionException
+ protected final boolean useLibtool( AOL aol ) throws MojoExecutionException
{
return getNarInfo().getProperty( aol, "libtool", libtool );
}
- protected boolean failOnError( AOL aol ) throws MojoExecutionException
+ protected final boolean failOnError( AOL aol ) throws MojoExecutionException
{
return getNarInfo().getProperty( aol, "failOnError", failOnError );
}
- protected String getRuntime( AOL aol ) throws MojoExecutionException
+ protected final String getRuntime( AOL aol ) throws MojoExecutionException
{
return getNarInfo().getProperty( aol, "runtime", runtime );
}
- protected String getOutput( AOL aol ) throws MojoExecutionException
+ protected final String getOutput( AOL aol ) throws MojoExecutionException
{
return getNarInfo().getProperty( aol, "output", output );
}
- protected File getJavaHome( AOL aol ) throws MojoExecutionException
+ protected final File getJavaHome( AOL aol ) throws MojoExecutionException
{
// FIXME should be easier by specifying default...
return getNarInfo().getProperty( aol, "javaHome", NarUtil.getJavaHome( javaHome, getOS() ) );
}
- protected List getLibraries()
+ protected final List getLibraries()
{
if ( libraries == null )
{
@@ -226,7 +226,7 @@ public abstract class AbstractCompileMojo
return libraries;
}
- protected List getTests()
+ protected final List getTests()
{
if ( tests == null )
{
@@ -235,7 +235,7 @@ public abstract class AbstractCompileMojo
return tests;
}
- protected Javah getJavah()
+ protected final Javah getJavah()
{
if ( javah == null )
{
@@ -245,7 +245,7 @@ public abstract class AbstractCompileMojo
return javah;
}
- protected Java getJava()
+ protected final Java getJava()
{
if ( java == null )
{
@@ -255,17 +255,17 @@ public abstract class AbstractCompileMojo
return java;
}
- public void setDependencyLibOrder( List/* <String> */order )
+ public final void setDependencyLibOrder( List/* <String> */order )
{
dependencyLibOrder = order;
}
- protected List/* <String> */getDependencyLibOrder()
+ protected final List/* <String> */getDependencyLibOrder()
{
return dependencyLibOrder;
}
- protected NarInfo getNarInfo() throws MojoExecutionException
+ protected final NarInfo getNarInfo() throws MojoExecutionException
{
if ( narInfo == null )
{
@@ -277,7 +277,7 @@ public abstract class AbstractCompileMojo
}
// FIXME, needs to maybe move up
- protected NarLayout getLayout() throws MojoExecutionException
+ protected final NarLayout getLayout() throws MojoExecutionException
{
if (narLayout == null) {
String className = layout.indexOf( '.' ) < 0 ? NarLayout21.class.getPackage().getName()+"."+layout : layout;
diff --git a/src/main/java/org/apache/maven/plugin/nar/AbstractGnuMojo.java b/src/main/java/org/apache/maven/plugin/nar/AbstractGnuMojo.java
index 65c21bc..658b951 100644
--- a/src/main/java/org/apache/maven/plugin/nar/AbstractGnuMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/AbstractGnuMojo.java
@@ -45,7 +45,7 @@ public abstract class AbstractGnuMojo
* @parameter expression="${basedir}/src/gnu"
* @required
*/
- protected File gnuSourceDirectory;
+ private File gnuSourceDirectory;
/**
* Directory in which gnu sources are copied and "configured"
@@ -74,6 +74,10 @@ public abstract class AbstractGnuMojo
{
return new File( getGnuAOLDirectory(), "target" );
}
+
+ protected File getGnuSourceDirectory() {
+ return gnuSourceDirectory;
+ }
/**
* @return
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 e6db79d..2c4b5a6 100644
--- a/src/main/java/org/apache/maven/plugin/nar/AbstractNarMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/AbstractNarMojo.java
@@ -98,46 +98,46 @@ public abstract class AbstractNarMojo
*/
private MavenProject mavenProject;
- protected boolean shouldSkip()
+ protected final boolean shouldSkip()
{
return skip;
}
- protected String getArchitecture()
+ protected final String getArchitecture()
{
architecture = NarUtil.getArchitecture( architecture );
return architecture;
}
- protected String getOS()
+ protected final String getOS()
{
os = NarUtil.getOS( os );
return os;
}
- protected AOL getAOL()
+ protected final AOL getAOL()
throws MojoFailureException
{
return NarUtil.getAOL( architecture, os, linker, aol );
}
- protected Linker getLinker()
+ protected final Linker getLinker()
{
linker = NarUtil.getLinker( linker );
return linker;
}
- protected File getOutputDirectory()
+ protected final File getOutputDirectory()
{
return outputDirectory;
}
- protected String getFinalName()
+ protected final String getFinalName()
{
return finalName;
}
- protected File getTargetDirectory()
+ protected final File getTargetDirectory()
{
if ( targetDirectory == null )
{
@@ -146,7 +146,7 @@ public abstract class AbstractNarMojo
return targetDirectory;
}
- protected MavenProject getMavenProject()
+ protected final MavenProject getMavenProject()
{
return mavenProject;
}
diff --git a/src/main/java/org/apache/maven/plugin/nar/Compiler.java b/src/main/java/org/apache/maven/plugin/nar/Compiler.java
index 4a79440..2f340fc 100644
--- a/src/main/java/org/apache/maven/plugin/nar/Compiler.java
+++ b/src/main/java/org/apache/maven/plugin/nar/Compiler.java
@@ -224,12 +224,12 @@ public abstract class Compiler
{
}
- public void setAbstractCompileMojo( AbstractCompileMojo mojo )
+ public final void setAbstractCompileMojo( AbstractCompileMojo mojo )
{
this.mojo = mojo;
}
- public List/* <File> */getSourceDirectories()
+ public final List/* <File> */getSourceDirectories()
{
return getSourceDirectories( "dummy" );
}
@@ -289,7 +289,7 @@ public abstract class Compiler
return sourceDirectories;
}
- protected List/* <String> */getIncludePaths( String type )
+ protected final List/* <String> */getIncludePaths( String type )
{
return createIncludePaths( type, type.equals( "test" ) ? testIncludePaths : includePaths );
}
@@ -307,13 +307,13 @@ public abstract class Compiler
return paths;
}
- public Set getIncludes()
+ public final Set getIncludes()
throws MojoFailureException
{
return getIncludes( "main" );
}
- protected Set getIncludes( String type )
+ protected final Set getIncludes( String type )
throws MojoFailureException
{
Set result = new HashSet();
@@ -340,7 +340,7 @@ public abstract class Compiler
return result;
}
- protected Set getExcludes()
+ protected final Set getExcludes()
throws MojoFailureException
{
Set result = new HashSet();
@@ -366,13 +366,13 @@ public abstract class Compiler
return result;
}
- protected String getPrefix()
+ protected final String getPrefix()
throws MojoFailureException
{
return mojo.getAOL().getKey() + "." + getName() + ".";
}
- public CompilerDef getCompiler( String type, String output )
+ public final CompilerDef getCompiler( String type, String output )
throws MojoFailureException
{
@@ -609,7 +609,7 @@ public abstract class Compiler
protected abstract String getName();
- public void copyIncludeFiles( MavenProject mavenProject, File targetDirectory )
+ public final void copyIncludeFiles( MavenProject mavenProject, File targetDirectory )
throws IOException
{
for ( Iterator i = getIncludePaths( "dummy" ).iterator(); i.hasNext(); )
diff --git a/src/main/java/org/apache/maven/plugin/nar/Java.java b/src/main/java/org/apache/maven/plugin/nar/Java.java
index 386dfea..ec93775 100644
--- a/src/main/java/org/apache/maven/plugin/nar/Java.java
+++ b/src/main/java/org/apache/maven/plugin/nar/Java.java
@@ -31,7 +31,6 @@ import net.sf.antcontrib.cpptasks.types.LinkerArgument;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.tools.ant.BuildException;
/**
* Java specifications for NAR
@@ -92,7 +91,7 @@ public class Java
}
public void addIncludePaths( CCTask task, String outType )
- throws MojoFailureException, BuildException, MojoExecutionException
+ throws MojoFailureException, MojoExecutionException
{
if ( include || mojo.getJavah().getJniDirectory().exists() )
{
diff --git a/src/main/java/org/apache/maven/plugin/nar/Javah.java b/src/main/java/org/apache/maven/plugin/nar/Javah.java
index 079357e..eeba43a 100644
--- a/src/main/java/org/apache/maven/plugin/nar/Javah.java
+++ b/src/main/java/org/apache/maven/plugin/nar/Javah.java
@@ -327,11 +327,11 @@ public class Javah
private Toolchain getToolchain()
{
Toolchain toolChain = null;
- ToolchainManager toolchainManager = ((NarJavahMojo)mojo).toolchainManager;
+ ToolchainManager toolchainManager = ((NarJavahMojo)mojo).getToolchainManager();
if ( toolchainManager != null )
{
- toolChain = toolchainManager.getToolchainFromBuildContext( "jdk", ((NarJavahMojo)mojo).session );
+ toolChain = toolchainManager.getToolchainFromBuildContext( "jdk", ((NarJavahMojo)mojo).getSession() );
}
return toolChain;
}
diff --git a/src/main/java/org/apache/maven/plugin/nar/Library.java b/src/main/java/org/apache/maven/plugin/nar/Library.java
index 5a41090..fbcf6dd 100644
--- a/src/main/java/org/apache/maven/plugin/nar/Library.java
+++ b/src/main/java/org/apache/maven/plugin/nar/Library.java
@@ -49,28 +49,28 @@ public class Library
*
* @parameter expression=""
*/
- protected String type = SHARED;
+ private String type = SHARED;
/**
* Link with stdcpp if necessary Defaults to true.
*
* @parameter expression=""
*/
- protected boolean linkCPP = true;
+ private boolean linkCPP = true;
/**
* Link with fortran runtime if necessary Defaults to false.
*
* @parameter expression=""
*/
- protected boolean linkFortran = false;
+ private boolean linkFortran = false;
/**
* If specified will create the NarSystem class with methods to load a JNI library.
*
* @parameter expression=""
*/
- protected String narSystemPackage = null;
+ private String narSystemPackage = null;
/**
* Name of the NarSystem class
@@ -78,7 +78,7 @@ public class Library
* @parameter expression="NarSystem"
* @required
*/
- protected String narSystemName = "NarSystem";
+ private String narSystemName = "NarSystem";
/**
* The target directory into which to generate the output.
@@ -86,14 +86,14 @@ public class Library
* @parameter expression="${project.build.dir}/nar/nar-generated"
* @required
*/
- protected String narSystemDirectory = "nar-generated";
+ private String narSystemDirectory = "nar-generated";
/**
* When true and if type is "executable" run this executable. Defaults to false;
*
* @parameter expression=""
*/
- protected boolean run = false;
+ private boolean run = false;
/**
* Arguments to be used for running this executable. Defaults to empty list. This option is only used if run=true
@@ -101,50 +101,50 @@ public class Library
*
* @parameter expression=""
*/
- protected List/* <String> */args = new ArrayList();
+ private List/* <String> */args = new ArrayList();
- public String getType()
+ public final String getType()
{
return type;
}
- public boolean linkCPP()
+ public final boolean linkCPP()
{
return linkCPP;
}
- public boolean linkFortran()
+ public final boolean linkFortran()
{
return linkFortran;
}
- public String getNarSystemPackage()
+ public final String getNarSystemPackage()
{
return narSystemPackage;
}
- public boolean shouldRun()
+ public final boolean shouldRun()
{
return run;
}
- public List/* <String> */getArgs()
+ public final List/* <String> */getArgs()
{
return args;
}
- public String getNarSystemName()
+ public final String getNarSystemName()
{
return narSystemName;
}
- public String getNarSystemDirectory()
+ public final String getNarSystemDirectory()
{
return narSystemDirectory;
}
// FIXME incomplete
- public String toString()
+ public final String toString()
{
StringBuffer sb = new StringBuffer( "Library: " );
sb.append( "type: " );
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 a21c3c0..42620ee 100644
--- a/src/main/java/org/apache/maven/plugin/nar/Linker.java
+++ b/src/main/java/org/apache/maven/plugin/nar/Linker.java
@@ -188,7 +188,7 @@ public class Linker
if ( name.equals( "g++" ) || name.equals( "gcc" ) )
{
- int r = NarUtil.runCommand( "gcc", new String[] { "--version" }, null, null, out, err, dbg );
+ NarUtil.runCommand( "gcc", new String[] { "--version" }, null, null, out, err, dbg );
Pattern p = Pattern.compile( "\\d+\\.\\d+\\.\\d+" );
Matcher m = p.matcher( out.toString() );
if ( m.find() )
@@ -202,7 +202,7 @@ public class Linker
}
else if ( name.equals( "msvc" ) )
{
- int r = NarUtil.runCommand( "link", new String[] { "/version" }, null, null, out, err, dbg );
+ NarUtil.runCommand( "link", new String[] { "/version" }, null, null, out, err, dbg );
Pattern p = Pattern.compile( "\\d+\\.\\d+\\.\\d+" );
Matcher m = p.matcher( out.toString() );
if ( m.find() )
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 c2ad204..546dc10 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java
@@ -69,14 +69,14 @@ public class NarGnuConfigureMojo
}
File targetDir = getGnuAOLSourceDirectory();
- if ( gnuSourceDirectory.exists() )
+ if ( getGnuSourceDirectory().exists() )
{
getLog().info( "Copying GNU sources" );
try
{
FileUtils.mkdir( targetDir.getPath() );
- NarUtil.copyDirectoryStructure( gnuSourceDirectory, targetDir, null, null );
+ NarUtil.copyDirectoryStructure( getGnuSourceDirectory(), targetDir, null, null );
}
catch ( IOException e )
{
@@ -98,7 +98,6 @@ public class NarGnuConfigureMojo
int result = NarUtil.runCommand( "./" + autogen.getName(), null, targetDir, null, getLog() );
if ( result != 0 )
{
- System.err.println( targetDir );
throw new MojoExecutionException( "'" + AUTOGEN + "' errorcode: " + result );
}
}
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 133203a..63e81d1 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarGnuResources.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarGnuResources.java
@@ -43,13 +43,13 @@ public class NarGnuResources
return;
}
- if ( gnuSourceDirectory.exists() )
+ if ( getGnuSourceDirectory().exists() )
{
int copied = 0;
try
{
- copied += copyIncludes( gnuSourceDirectory );
+ copied += copyIncludes( getGnuSourceDirectory() );
}
catch ( IOException e )
{
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarInfo.java b/src/main/java/org/apache/maven/plugin/nar/NarInfo.java
index 813bcd7..845287a 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarInfo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarInfo.java
@@ -71,7 +71,7 @@ public class NarInfo
}
}
- public String toString()
+ public final String toString()
{
StringBuffer s = new StringBuffer( "NarInfo for " );
s.append( groupId );
@@ -95,12 +95,12 @@ public class NarInfo
return s.toString();
}
- public boolean exists( JarFile jar )
+ public final boolean exists( JarFile jar )
{
return getNarPropertiesEntry( jar ) != null;
}
- public void read( JarFile jar )
+ public final void read( JarFile jar )
throws IOException
{
info.load( jar.getInputStream( getNarPropertiesEntry( jar ) ) );
@@ -117,31 +117,31 @@ public class NarInfo
* @param aol
* @return
*/
- public String getBinding( AOL aol, String defaultBinding )
+ public final String getBinding( AOL aol, String defaultBinding )
{
return getProperty( aol, "libs.binding", defaultBinding );
}
- public void setBinding( AOL aol, String value )
+ public final void setBinding( AOL aol, String value )
{
setProperty( aol, "libs.binding", value );
}
// FIXME replace with list of AttachedNarArtifacts
- public String[] getAttachedNars( AOL aol, String type )
+ public final String[] getAttachedNars( AOL aol, String type )
{
String attachedNars = getProperty( aol, "nar." + type );
return attachedNars != null ? attachedNars.split( "," ) : null;
}
- public void addNar( AOL aol, String type, String nar )
+ public final void addNar( AOL aol, String type, String nar )
{
String nars = getProperty( aol, "nar." + type );
nars = ( nars == null ) ? nar : nars + ", " + nar;
setProperty( aol, "nar." + type, nars );
}
- public void setNar( AOL aol, String type, String nar )
+ public final void setNar( AOL aol, String type, String nar )
{
setProperty( aol, "nar." + type, nar );
}
@@ -151,22 +151,22 @@ public class NarInfo
return aol == null ? null : new AOL( getProperty( aol, aol.toString(), aol.toString() ) );
}
- public String getOptions( AOL aol )
+ public final String getOptions( AOL aol )
{
return getProperty( aol, "linker.options" );
}
- public String getLibs( AOL aol )
+ public final String getLibs( AOL aol )
{
return getProperty( aol, "libs.names", artifactId + "-" + version );
}
- public String getSysLibs( AOL aol )
+ public final String getSysLibs( AOL aol )
{
return getProperty( aol, "syslibs.names" );
}
- public void writeToFile( File file )
+ public final void writeToFile( File file )
throws IOException
{
info.store( new FileOutputStream( ( file ) ), "NAR Properties for " + groupId + "." + artifactId + "-"
@@ -185,12 +185,12 @@ public class NarInfo
}
}
- public String getProperty( AOL aol, String key )
+ public final String getProperty( AOL aol, String key )
{
return getProperty( aol, key, (String) null );
}
- public String getProperty( AOL aol, String key, String defaultValue )
+ public final String getProperty( AOL aol, String key, String defaultValue )
{
if ( key == null )
{
@@ -202,17 +202,17 @@ public class NarInfo
return value;
}
- public int getProperty( AOL aol, String key, int defaultValue )
+ public final int getProperty( AOL aol, String key, int defaultValue )
{
return Integer.parseInt( getProperty( aol, key, Integer.toString( defaultValue ) ) );
}
- public boolean getProperty( AOL aol, String key, boolean defaultValue )
+ public final boolean getProperty( AOL aol, String key, boolean defaultValue )
{
return Boolean.parseBoolean( getProperty( aol, key, String.valueOf( defaultValue ) ) );
}
- public File getProperty( AOL aol, String key, File defaultValue )
+ public final File getProperty( AOL aol, String key, File defaultValue )
{
return new File( getProperty( aol, key, defaultValue.getPath() ) );
}
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 d8b9858..1116106 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java
@@ -184,7 +184,8 @@ public class NarIntegrationTestMojo
* @required
* @readonly
*/
- protected MavenProject project;
+ // DUNS, made private
+ private MavenProject project;
/**
* The classpath elements of the project being tested.
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 24c7d6c..e19310d 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java
@@ -38,7 +38,7 @@ public class NarJavahMojo
/**
* @component
*/
- ToolchainManager toolchainManager;
+ private ToolchainManager toolchainManager;
/**
* The current build session instance.
@@ -47,7 +47,15 @@ public class NarJavahMojo
* @required
* @readonly
*/
- MavenSession session;
+ private MavenSession session;
+
+ protected ToolchainManager getToolchainManager() {
+ return toolchainManager;
+ }
+
+ protected MavenSession getSession() {
+ return session;
+ }
public void execute()
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 d72e640..f011453 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java
@@ -3,6 +3,7 @@ package org.apache.maven.plugin.nar;
import java.io.File;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
@@ -55,16 +56,15 @@ public class NarLayout20
* (non-Javadoc)
* @see org.apache.maven.plugin.nar.NarLayout#getLibDir(java.io.File, org.apache.maven.plugin.nar.AOL, String type)
*/
- public File getLibDirectory( File baseDir, String aol, String type )
+ public File getLibDirectory( File baseDir, String aol, String type ) throws MojoFailureException
{
if ( type.equals( Library.EXECUTABLE ) )
{
- System.err.println( "WARNING, Replace call to getLibDirectory with getBinDirectory" );
- Thread.dumpStack();
+ throw new MojoFailureException( "INTERNAL ERROR, Replace call to getLibDirectory with getBinDirectory" );
}
File dir = new File( baseDir, "lib" );
- dir = new File( dir, aol.toString() );
+ dir = new File( dir, aol );
dir = new File( dir, type );
return dir;
}
@@ -76,7 +76,7 @@ public class NarLayout20
public File getBinDirectory( File baseDir, String aol )
{
File dir = new File( baseDir, "bin" );
- dir = new File( dir, aol.toString() );
+ dir = new File( dir, aol );
return dir;
}
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 3761860..864748a 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java
@@ -81,7 +81,7 @@ public class NarLayout21
File dir = getAolDirectory( baseDir, aol, type );
dir = new File( dir, "lib" );
- dir = new File( dir, aol.toString() );
+ dir = new File( dir, aol );
dir = new File( dir, type );
return dir;
}
@@ -95,7 +95,7 @@ public class NarLayout21
{
File dir = getAolDirectory( baseDir, aol, Library.EXECUTABLE );
dir = new File( dir, "bin" );
- dir = new File( dir, aol.toString() );
+ dir = new File( dir, aol );
return dir;
}
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 e0b4ccb..21b0060 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarManager.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarManager.java
@@ -77,7 +77,7 @@ public class NarManager
/**
* Returns dependencies which are dependent on NAR files (i.e. contain NarInfo)
*/
- public List/* <NarArtifact> */getNarDependencies( String scope )
+ public final List/* <NarArtifact> */getNarDependencies( String scope )
throws MojoExecutionException
{
List narDependencies = new LinkedList();
@@ -101,7 +101,7 @@ public class NarManager
*
* @throws MojoFailureException
*/
- public Map/* <String, List<AttachedNarArtifact>> */getAttachedNarDependencyMap( String scope )
+ public final Map/* <String, List<AttachedNarArtifact>> */getAttachedNarDependencyMap( String scope )
throws MojoExecutionException, MojoFailureException
{
Map attachedNarDependencies = new HashMap();
@@ -120,13 +120,13 @@ public class NarManager
return attachedNarDependencies;
}
- public List/* <AttachedNarArtifact> */getAttachedNarDependencies( List/* <NarArtifacts> */narArtifacts )
+ public final List/* <AttachedNarArtifact> */getAttachedNarDependencies( List/* <NarArtifacts> */narArtifacts )
throws MojoExecutionException, MojoFailureException
{
return getAttachedNarDependencies( narArtifacts, null );
}
- public List/* <AttachedNarArtifact> */getAttachedNarDependencies( List/* <NarArtifacts> */narArtifacts,
+ public final List/* <AttachedNarArtifact> */getAttachedNarDependencies( List/* <NarArtifacts> */narArtifacts,
String classifier )
throws MojoExecutionException, MojoFailureException
{
@@ -161,7 +161,7 @@ public class NarManager
* @throws MojoExecutionException
* @throws MojoFailureException
*/
- public List/* <AttachedNarArtifact> */getAttachedNarDependencies( List/* <NarArtifacts> */narArtifacts, AOL aol,
+ public final List/* <AttachedNarArtifact> */getAttachedNarDependencies( List/* <NarArtifacts> */narArtifacts, AOL aol,
String type )
throws MojoExecutionException, MojoFailureException
{
@@ -251,7 +251,7 @@ public class NarManager
return artifactList;
}
- public NarInfo getNarInfo( Artifact dependency )
+ public final NarInfo getNarInfo( Artifact dependency )
throws MojoExecutionException
{
// FIXME reported to maven developer list, isSnapshot changes behaviour
@@ -297,7 +297,7 @@ public class NarManager
}
}
- public File getNarFile( Artifact dependency )
+ public final File getNarFile( Artifact dependency )
throws MojoFailureException
{
// FIXME reported to maven developer list, isSnapshot changes behaviour
@@ -320,7 +320,7 @@ public class NarManager
return project.getCompileArtifacts();
}
- public void downloadAttachedNars( List/* <NarArtifacts> */narArtifacts, List remoteRepositories,
+ public final void downloadAttachedNars( List/* <NarArtifacts> */narArtifacts, List remoteRepositories,
ArtifactResolver resolver, String classifier )
throws MojoExecutionException, MojoFailureException
{
@@ -356,7 +356,7 @@ public class NarManager
}
}
- public void unpackAttachedNars( List/* <NarArtifacts> */narArtifacts, ArchiverManager manager, String classifier,
+ public final void unpackAttachedNars( List/* <NarArtifacts> */narArtifacts, ArchiverManager manager, String classifier,
String os )
throws MojoExecutionException, MojoFailureException
{
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 96b369f..d921fe6 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java
@@ -58,7 +58,7 @@ public class NarTestCompileMojo
}
// make sure destination is there
- getTargetDirectory().mkdirs();
+ getTestTargetDirectory().mkdirs();
for ( Iterator i = getTests().iterator(); i.hasNext(); )
{
@@ -81,7 +81,7 @@ public class NarTestCompileMojo
task.setOuttype( outTypeEnum );
// outDir
- File outDir = new File( getTargetDirectory(), "bin" );
+ File outDir = new File( getTestTargetDirectory(), "bin" );
outDir = new File( outDir, getAOL().toString() );
outDir.mkdirs();
@@ -91,7 +91,7 @@ public class NarTestCompileMojo
task.setOutfile( outFile );
// object directory
- File objDir = new File( getTargetDirectory(), "obj" );
+ File objDir = new File( getTestTargetDirectory(), "obj" );
objDir = new File( objDir, getAOL().toString() );
objDir.mkdirs();
task.setObjdir( objDir );
@@ -132,8 +132,8 @@ public class NarTestCompileMojo
// FIXME hardcoded values
String libName = getFinalName();
- File includeDir = getLayout().getIncludeDirectory( super.getTargetDirectory() );
- File libDir = getLayout().getLibDirectory( super.getTargetDirectory(), getAOL().toString(), test.getLink() );
+ File includeDir = getLayout().getIncludeDirectory( getTargetDirectory() );
+ File libDir = getLayout().getLibDirectory( getTargetDirectory(), getAOL().toString(), test.getLink() );
// copy shared library
// FIXME why do we do this ?
@@ -235,7 +235,7 @@ public class NarTestCompileMojo
}
}
- protected File getTargetDirectory()
+ protected File getTestTargetDirectory()
{
return new File( getMavenProject().getBuild().getDirectory(), "test-nar" );
}
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 b9ecafc..fd3d8fe 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java
@@ -29,7 +29,6 @@ import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.StringUtils;
@@ -79,7 +78,7 @@ public class NarTestMojo
// run if requested
if ( test.shouldRun() )
{
- String name = getTargetDirectory().getPath() + "/bin/" + getAOL() + "/" + test.getName();
+ String name = getTestTargetDirectory().getPath() + "/bin/" + getAOL() + "/" + test.getName();
getLog().info( "Running test " + name );
File workingDir = getMavenProject().getBasedir();
@@ -87,7 +86,7 @@ public class NarTestMojo
List args = test.getArgs();
int result =
NarUtil.runCommand( name, (String[]) args.toArray( new String[args.size()] ), workingDir,
- generateEnvironment( test, getLog() ), getLog() );
+ generateEnvironment(), getLog() );
if ( result != 0 )
{
throw new MojoFailureException( "Test " + name + " failed with exit code: " + result + " 0x"
@@ -104,13 +103,13 @@ public class NarTestMojo
MavenProject project = getMavenProject();
// FIXME NAR-90, we could make dure we get the final name from layout
File executable =
- new File( getLayout().getBinDirectory( super.getTargetDirectory(), getAOL().toString() ),
+ new File( getLayout().getBinDirectory( getTargetDirectory(), getAOL().toString() ),
project.getArtifactId() );
getLog().info( "Running executable " + executable );
List args = library.getArgs();
int result =
NarUtil.runCommand( executable.getPath(), (String[]) args.toArray( new String[args.size()] ), null,
- generateEnvironment( library, getLog() ), getLog() );
+ generateEnvironment(), getLog() );
if ( result != 0 )
{
throw new MojoFailureException( "Test " + executable + " failed with exit code: " + result + " 0x"
@@ -119,12 +118,12 @@ public class NarTestMojo
}
}
- protected File getTargetDirectory()
+ protected File getTestTargetDirectory()
{
return new File( getMavenProject().getBuild().getDirectory(), "test-nar" );
}
- private String[] generateEnvironment( Executable exec, Log log )
+ private String[] generateEnvironment()
throws MojoExecutionException, MojoFailureException
{
List env = new ArrayList();
@@ -138,7 +137,7 @@ public class NarTestMojo
if ( lib.getType().equals( Library.SHARED ) )
{
File path =
- getLayout().getLibDirectory( super.getTargetDirectory(), getAOL().toString(), lib.getType() );
+ getLayout().getLibDirectory( getTargetDirectory(), getAOL().toString(), lib.getType() );
getLog().debug( "Adding path to shared library: " + path );
sharedPaths.add( path );
}
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarUtil.java b/src/main/java/org/apache/maven/plugin/nar/NarUtil.java
index a18c97c..3dae4de 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarUtil.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarUtil.java
@@ -30,7 +30,6 @@ import java.util.Map;
import java.util.Properties;
import java.util.regex.Pattern;
-import org.apache.bcel.classfile.ClassFormatException;
import org.apache.bcel.classfile.ClassParser;
import org.apache.bcel.classfile.JavaClass;
import org.apache.maven.plugin.MojoExecutionException;
@@ -43,9 +42,13 @@ import org.codehaus.plexus.util.cli.Commandline;
/**
* @author Mark Donszelmann
*/
-public class NarUtil
+public final class NarUtil
{
+ private NarUtil() {
+ // never instantiate
+ }
+
private static Properties defaults;
public static Properties getDefaults()
@@ -189,7 +192,7 @@ public class NarUtil
runRanlib( files[i], log );
}
}
- if ( file.isFile() && file.canRead() && file.canWrite() && !file.isHidden() && file.getName().endsWith( ".a" ) )
+ if ( file.isFile() && file.canWrite() && !file.isHidden() && file.getName().endsWith( ".a" ) )
{
// ranlib file
int result = runCommand( "ranlib", new String[] { file.getPath() }, null, null, log );
@@ -206,10 +209,10 @@ public class NarUtil
*
* @param filename the absolute file name of the class
* @return the Bcel Class.
- * @throws IOException, ClassFormatException
+ * @throws IOException
*/
- public static final JavaClass getBcelClass( String filename )
- throws IOException, ClassFormatException
+ public static JavaClass getBcelClass( String filename )
+ throws IOException
{
ClassParser parser = new ClassParser( filename );
return parser.parse();
@@ -221,7 +224,7 @@ public class NarUtil
* @param filename the absolute file name of the class
* @return the header file name.
*/
- public static final String getHeaderName( String base, String filename )
+ public static String getHeaderName( String base, String filename )
{
base = base.replaceAll( "\\\\", "/" );
filename = filename.replaceAll( "\\\\", "/" );
@@ -492,8 +495,9 @@ public class NarUtil
outputGobbler.start();
process.waitFor();
dbg.println( "ExitValue: " + process.exitValue() );
- errorGobbler.join( 5000 );
- outputGobbler.join( 5000 );
+ final int timeout = 5000;
+ errorGobbler.join( timeout );
+ outputGobbler.join( timeout );
return process.exitValue();
}
catch ( Exception e )
@@ -502,14 +506,13 @@ public class NarUtil
}
}
- static class StreamGobbler
+ private final static class StreamGobbler
extends Thread
{
- InputStream is;
+ private InputStream is;
+ private TextStream ts;
- TextStream ts;
-
- StreamGobbler( InputStream is, TextStream ts )
+ private StreamGobbler( InputStream is, TextStream ts )
{
this.is = is;
this.ts = ts;
@@ -529,7 +532,11 @@ public class NarUtil
}
catch ( IOException e )
{
- e.printStackTrace();
+ // e.printStackTrace()
+ StackTraceElement[] stackTrace = e.getStackTrace();
+ for (int i=0; i<stackTrace.length; i++) {
+ ts.println( stackTrace[i].toString());
+ }
}
}
}
diff --git a/src/main/java/org/apache/maven/plugin/nar/Test.java b/src/main/java/org/apache/maven/plugin/nar/Test.java
index 139867f..1bc8838 100644
--- a/src/main/java/org/apache/maven/plugin/nar/Test.java
+++ b/src/main/java/org/apache/maven/plugin/nar/Test.java
@@ -39,28 +39,28 @@ public class Test
* @required
* @parameter expression=""
*/
- protected String name = null;
+ private String name = null;
/**
* Type of linking used for this test Possible choices are: "shared" or "static". Defaults to "shared".
*
* @parameter expression=""
*/
- protected String link = Library.SHARED;
+ private String link = Library.SHARED;
/**
* When true run this test. Defaults to true;
*
* @parameter expresssion=""
*/
- protected boolean run = true;
+ private boolean run = true;
/**
* Arguments to be used for running this test. Defaults to empty list. This option is only used if run=true.
*
* @parameter expression=""
*/
- protected List/* <String> */args = new ArrayList();
+ private List/* <String> */args = new ArrayList();
public String getName()
throws MojoFailureException