diff options
author | Mark Donszelmann <Mark.Donszelmann@gmail.com> | 2009-11-18 16:40:23 +0100 |
---|---|---|
committer | Mark Donszelmann <Mark.Donszelmann@gmail.com> | 2009-11-18 16:40:23 +0100 |
commit | 4c70a81345c566d7b4dd6dc2fad51fe70726c8f0 (patch) | |
tree | e4394385ba7610bdee04af81abedcbbc0bc169ae /src/main/java | |
parent | 59a81bc23a42a82dca675b8c7cd661a3c0fa40db (diff) | |
download | maven-nar-plugin-4c70a81345c566d7b4dd6dc2fad51fe70726c8f0.tar.gz maven-nar-plugin-4c70a81345c566d7b4dd6dc2fad51fe70726c8f0.tar.bz2 maven-nar-plugin-4c70a81345c566d7b4dd6dc2fad51fe70726c8f0.tar.xz maven-nar-plugin-4c70a81345c566d7b4dd6dc2fad51fe70726c8f0.zip |
Further cleanup
Diffstat (limited to 'src/main/java')
30 files changed, 167 insertions, 148 deletions
diff --git a/src/main/java/org/apache/maven/plugin/nar/AbstractDependencyMojo.java b/src/main/java/org/apache/maven/plugin/nar/AbstractDependencyMojo.java index e675292..aade4c3 100644 --- a/src/main/java/org/apache/maven/plugin/nar/AbstractDependencyMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/AbstractDependencyMojo.java @@ -36,12 +36,12 @@ public abstract class AbstractDependencyMojo */ private ArtifactRepository localRepository; - protected ArtifactRepository getLocalRepository() + protected final ArtifactRepository getLocalRepository() { return localRepository; } - protected NarManager getNarManager() + protected final NarManager getNarManager() throws MojoFailureException { return new NarManager( getLog(), getLocalRepository(), getMavenProject(), getArchitecture(), getOS(), 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 b5a5706..21e67e5 100644 --- a/src/main/java/org/apache/maven/plugin/nar/AbstractNarLayout.java +++ b/src/main/java/org/apache/maven/plugin/nar/AbstractNarLayout.java @@ -38,7 +38,7 @@ public abstract class AbstractNarLayout implements NarLayout, NarConstants { - protected void attachNar( MavenProjectHelper projectHelper, MavenProject project, String classifier, File dir, + protected final void attachNar( MavenProjectHelper projectHelper, MavenProject project, String classifier, File dir, String include ) throws MojoExecutionException { 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 463034e..888d50e 100644 --- a/src/main/java/org/apache/maven/plugin/nar/AttachedNarArtifact.java +++ b/src/main/java/org/apache/maven/plugin/nar/AttachedNarArtifact.java @@ -33,7 +33,6 @@ import org.apache.maven.artifact.versioning.VersionRange; public class AttachedNarArtifact extends DefaultArtifact { - public AttachedNarArtifact( String groupId, String artifactId, String version, String scope, String type, String classifier, boolean optional ) throws InvalidVersionSpecificationException diff --git a/src/main/java/org/apache/maven/plugin/nar/C.java b/src/main/java/org/apache/maven/plugin/nar/C.java index 45c5de8..f300a68 100644 --- a/src/main/java/org/apache/maven/plugin/nar/C.java +++ b/src/main/java/org/apache/maven/plugin/nar/C.java @@ -32,7 +32,7 @@ public class C { } - public String getName() + public final String getLanguage() { return "c"; } 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 3185201..bfbece5 100644 --- a/src/main/java/org/apache/maven/plugin/nar/Compiler.java +++ b/src/main/java/org/apache/maven/plugin/nar/Compiler.java @@ -49,7 +49,7 @@ public abstract class Compiler { /** - * The name of the compiler Some choices are: "msvc", "g++", "gcc", "CC", "cc", "icc", "icpc", ... Default is + * The name of the compiler. Some choices are: "msvc", "g++", "gcc", "CC", "cc", "icc", "icpc", ... Default is * Architecture-OS-Linker specific: FIXME: table missing * * @parameter expression="" @@ -226,6 +226,20 @@ public abstract class Compiler { } + private String getName() throws MojoFailureException { + // adjust default values + if ( name == null ) + { + name = NarUtil.getDefaults().getProperty( getPrefix() + "compiler" ); + } + if ( name == null ) + { + throw new MojoFailureException( "NAR: No compiler name defined for aol: " + + getPrefix() ); + } + return name; + } + public final void setAbstractCompileMojo( AbstractCompileMojo mojo ) { this.mojo = mojo; @@ -298,15 +312,16 @@ public abstract class Compiler private List/* <String> */createIncludePaths( String type, List paths ) { - if ( paths == null || ( paths.size() == 0 ) ) + List includeList = paths; + if ( includeList == null || ( paths.size() == 0 ) ) { - paths = new ArrayList(); + includeList = new ArrayList(); for ( Iterator i = getSourceDirectories( type ).iterator(); i.hasNext(); ) { - paths.add( new File( (File) i.next(), "include" ).getPath() ); + includeList.add( new File( (File) i.next(), "include" ).getPath() ); } } - return paths; + return includeList; } public final Set getIncludes() @@ -371,28 +386,16 @@ public abstract class Compiler protected final String getPrefix() throws MojoFailureException { - return mojo.getAOL().getKey() + "." + getName() + "."; + return mojo.getAOL().getKey() + "." + getLanguage() + "."; } public final CompilerDef getCompiler( String type, String output ) throws MojoFailureException { - - // adjust default values - if ( name == null ) - { - name = NarUtil.getDefaults().getProperty( getPrefix() + "compiler" ); - } - if ( name == null ) - { - throw new MojoFailureException( "NAR: Please specify <Name> as part of <Cpp>, <C> or <Fortran> for " - + getPrefix() ); - } - CompilerDef compiler = new CompilerDef(); compiler.setProject( mojo.getAntProject() ); CompilerEnum compilerName = new CompilerEnum(); - compilerName.setValue( name ); + compilerName.setValue( getName() ); compiler.setName( compilerName ); // debug, exceptions, rtti, multiThreaded @@ -450,16 +453,16 @@ public abstract class Compiler // add defines if ( defines != null ) { - DefineSet defineSet = new DefineSet(); + DefineSet ds = new DefineSet(); for ( Iterator i = defines.iterator(); i.hasNext(); ) { DefineArgument define = new DefineArgument(); String[] pair = ( (String) i.next() ).split( "=", 2 ); define.setName( pair[0] ); define.setValue( pair.length > 1 ? pair[1] : null ); - defineSet.addDefine( define ); + ds.addDefine( define ); } - compiler.addConfiguredDefineset( defineSet ); + compiler.addConfiguredDefineset( ds ); } if ( defineSet != null ) @@ -485,28 +488,28 @@ public abstract class Compiler if ( !clearDefaultDefines ) { - DefineSet defineSet = new DefineSet(); + DefineSet ds = new DefineSet(); String defaultDefines = NarUtil.getDefaults().getProperty( getPrefix() + "defines" ); if ( defaultDefines != null ) { - defineSet.setDefine( new CUtil.StringArrayBuilder( defaultDefines ) ); + ds.setDefine( new CUtil.StringArrayBuilder( defaultDefines ) ); } - compiler.addConfiguredDefineset( defineSet ); + compiler.addConfiguredDefineset( ds ); } // add undefines if ( undefines != null ) { - DefineSet undefineSet = new DefineSet(); + DefineSet us = new DefineSet(); for ( Iterator i = undefines.iterator(); i.hasNext(); ) { DefineArgument undefine = new DefineArgument(); String[] pair = ( (String) i.next() ).split( "=", 2 ); undefine.setName( pair[0] ); undefine.setValue( pair.length > 1 ? pair[1] : null ); - undefineSet.addUndefine( undefine ); + us.addUndefine( undefine ); } - compiler.addConfiguredDefineset( undefineSet ); + compiler.addConfiguredDefineset( us ); } if ( undefineSet != null ) @@ -532,13 +535,13 @@ public abstract class Compiler if ( !clearDefaultUndefines ) { - DefineSet undefineSet = new DefineSet(); + DefineSet us = new DefineSet(); String defaultUndefines = NarUtil.getDefaults().getProperty( getPrefix() + "undefines" ); if ( defaultUndefines != null ) { - undefineSet.setUndefine( new CUtil.StringArrayBuilder( defaultUndefines ) ); + us.setUndefine( new CUtil.StringArrayBuilder( defaultUndefines ) ); } - compiler.addConfiguredDefineset( undefineSet ); + compiler.addConfiguredDefineset( us ); } // add include path @@ -560,8 +563,8 @@ public abstract class Compiler // Add default fileset (if exists) List srcDirs = getSourceDirectories( type ); - Set includes = getIncludes(); - Set excludes = getExcludes(); + Set includeSet = getIncludes(); + Set excludeSet = getExcludes(); // now add all but the current test to the excludes for ( Iterator i = mojo.getTests().iterator(); i.hasNext(); ) @@ -569,20 +572,20 @@ public abstract class Compiler Test test = (Test) i.next(); if ( !test.getName().equals( output ) ) { - excludes.add( "**/" + test.getName() + ".*" ); + excludeSet.add( "**/" + test.getName() + ".*" ); } } for ( Iterator i = srcDirs.iterator(); i.hasNext(); ) { File srcDir = (File) i.next(); - mojo.getLog().debug( "Checking for existence of " + getName() + " source directory: " + srcDir ); + mojo.getLog().debug( "Checking for existence of " + getLanguage() + " source directory: " + srcDir ); if ( srcDir.exists() ) { ConditionalFileSet fileSet = new ConditionalFileSet(); fileSet.setProject( mojo.getAntProject() ); - fileSet.setIncludes( StringUtils.join( includes.iterator(), "," ) ); - fileSet.setExcludes( StringUtils.join( excludes.iterator(), "," ) ); + fileSet.setIncludes( StringUtils.join( includeSet.iterator(), "," ) ); + fileSet.setExcludes( StringUtils.join( excludeSet.iterator(), "," ) ); fileSet.setDir( srcDir ); compiler.addFileset( fileSet ); } @@ -594,13 +597,13 @@ public abstract class Compiler for ( Iterator i = mojo.getMavenProject().getCompileSourceRoots().iterator(); i.hasNext(); ) { File dir = new File( (String) i.next() ); - mojo.getLog().debug( "Checking for existence of " + getName() + " sourceCompileRoot: " + dir ); + mojo.getLog().debug( "Checking for existence of " + getLanguage() + " sourceCompileRoot: " + dir ); if ( dir.exists() ) { ConditionalFileSet otherFileSet = new ConditionalFileSet(); otherFileSet.setProject( mojo.getAntProject() ); - otherFileSet.setIncludes( StringUtils.join( includes.iterator(), "," ) ); - otherFileSet.setExcludes( StringUtils.join( excludes.iterator(), "," ) ); + otherFileSet.setIncludes( StringUtils.join( includeSet.iterator(), "," ) ); + otherFileSet.setExcludes( StringUtils.join( excludeSet.iterator(), "," ) ); otherFileSet.setDir( dir ); compiler.addFileset( otherFileSet ); } @@ -609,7 +612,7 @@ public abstract class Compiler return compiler; } - protected abstract String getName(); + protected abstract String getLanguage(); public final void copyIncludeFiles( MavenProject mavenProject, File targetDirectory ) throws IOException diff --git a/src/main/java/org/apache/maven/plugin/nar/Cpp.java b/src/main/java/org/apache/maven/plugin/nar/Cpp.java index bf44b32..18aeab0 100644 --- a/src/main/java/org/apache/maven/plugin/nar/Cpp.java +++ b/src/main/java/org/apache/maven/plugin/nar/Cpp.java @@ -31,7 +31,7 @@ public class Cpp { } - public String getName() + public final String getLanguage() { return "cpp"; } diff --git a/src/main/java/org/apache/maven/plugin/nar/Fortran.java b/src/main/java/org/apache/maven/plugin/nar/Fortran.java index 6287647..aef297d 100644 --- a/src/main/java/org/apache/maven/plugin/nar/Fortran.java +++ b/src/main/java/org/apache/maven/plugin/nar/Fortran.java @@ -32,7 +32,7 @@ public class Fortran { } - public String getName() + public final String getLanguage() { return "fortran"; } 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 ab6e925..d2e7adb 100644 --- a/src/main/java/org/apache/maven/plugin/nar/Lib.java +++ b/src/main/java/org/apache/maven/plugin/nar/Lib.java @@ -72,57 +72,69 @@ public class Lib */ private List/* <Lib> */libs; - public void addLibSet( AbstractDependencyMojo mojo, LinkerDef linker, Project antProject ) + public final void addLibSet( AbstractDependencyMojo mojo, LinkerDef linker, Project antProject ) throws MojoFailureException, MojoExecutionException { + if ( name == null ) + { + throw new MojoFailureException( "NAR: Please specify <Name> as part of <Lib>" ); + } addLibSet( mojo, linker, antProject, name, directory ); } private void addLibSet( AbstractDependencyMojo mojo, LinkerDef linker, Project antProject, String name, File dir ) throws MojoFailureException, MojoExecutionException { - if ( name == null ) - { - throw new MojoFailureException( "NAR: Please specify <Name> as part of <Lib>" ); - } if ( libs == null ) { - if ( !type.equals( "framework" ) && ( dir == null ) ) - { - throw new MojoFailureException( "NAR: Please specify <Directory> as part of <Lib>" ); - } - LibrarySet libSet = new LibrarySet(); - libSet.setProject( antProject ); - libSet.setLibs( new CUtil.StringArrayBuilder( name ) ); - LibraryTypeEnum libType = new LibraryTypeEnum(); - libType.setValue( type ); - libSet.setType( libType ); - libSet.setDir( dir ); - linker.addLibset( libSet ); + addSingleLibSet( linker, antProject, name, dir ); } else { - List dependencies = mojo.getNarManager().getNarDependencies( "compile" ); - for ( Iterator i = libs.iterator(); i.hasNext(); ) + addMultipleLibSets( mojo, linker, antProject, name ); + } + } + + private void addSingleLibSet( LinkerDef linker, Project antProject, String name, File dir ) + throws MojoFailureException, MojoExecutionException + { + if ( !type.equals( "framework" ) && ( dir == null ) ) + { + throw new MojoFailureException( "NAR: Please specify <Directory> as part of <Lib>" ); + } + LibrarySet libSet = new LibrarySet(); + libSet.setProject( antProject ); + libSet.setLibs( new CUtil.StringArrayBuilder( name ) ); + LibraryTypeEnum libType = new LibraryTypeEnum(); + libType.setValue( type ); + libSet.setType( libType ); + libSet.setDir( dir ); + linker.addLibset( libSet ); + } + + private void addMultipleLibSets( AbstractDependencyMojo mojo, LinkerDef linker, Project antProject, String name ) + throws MojoFailureException, MojoExecutionException + { + List dependencies = mojo.getNarManager().getNarDependencies( "compile" ); + for ( Iterator i = libs.iterator(); i.hasNext(); ) + { + Lib lib = (Lib) i.next(); + String[] ids = name.split( ":", 2 ); + if ( ids.length != 2 ) { - Lib lib = (Lib) i.next(); - String[] ids = name.split( ":", 2 ); - if ( ids.length != 2 ) - { - throw new MojoFailureException( - "NAR: Please specify <Name> as part of <Lib> in format 'groupId:artifactId'" ); - } - for ( Iterator j = dependencies.iterator(); j.hasNext(); ) + throw new MojoFailureException( + "NAR: Please specify <Name> as part of <Lib> in format 'groupId:artifactId'" ); + } + for ( Iterator j = dependencies.iterator(); j.hasNext(); ) + { + Artifact dependency = (Artifact) j.next(); + if ( dependency.getGroupId().equals( ids[0] ) && dependency.getArtifactId().equals( ids[1] ) ) { - Artifact dependency = (Artifact) j.next(); - if ( dependency.getGroupId().equals( ids[0] ) && dependency.getArtifactId().equals( ids[1] ) ) - { - File narDir = - new File( mojo.getNarManager().getNarFile( dependency ).getParentFile(), "nar/lib/" - + mojo.getAOL() + "/" + lib.type ); - String narName = dependency.getArtifactId() + "-" + lib.name + "-" + dependency.getVersion(); - lib.addLibSet( mojo, linker, antProject, narName, narDir ); - } + File narDir = + new File( mojo.getNarManager().getNarFile( dependency ).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/Linker.java b/src/main/java/org/apache/maven/plugin/nar/Linker.java index fa863eb..951e06b 100644 --- a/src/main/java/org/apache/maven/plugin/nar/Linker.java +++ b/src/main/java/org/apache/maven/plugin/nar/Linker.java @@ -334,14 +334,14 @@ public class Linker if ( !clearDefaultOptions ) { - String options = NarUtil.getDefaults().getProperty( prefix + "options" ); - if ( options != null ) + String option = NarUtil.getDefaults().getProperty( prefix + "options" ); + if ( option != null ) { - String[] option = options.split( " " ); - for ( int i = 0; i < option.length; i++ ) + String[] opt = option.split( " " ); + for ( int i = 0; i < opt.length; i++ ) { LinkerArgument arg = new LinkerArgument(); - arg.setValue( option[i] ); + arg.setValue( opt[i] ); linker.addConfiguredLinkerArg( arg ); } } @@ -353,11 +353,11 @@ public class Linker List libOrder = new LinkedList(); - String[] libs = narDependencyLibOrder.split( "," ); + String[] lib = narDependencyLibOrder.split( "," ); - for ( int i = 0; i < libs.length; i++ ) + for ( int i = 0; i < lib.length; i++ ) { - libOrder.add( libs[i].trim() ); + libOrder.add( lib[i].trim() ); } mojo.setDependencyLibOrder( libOrder ); 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 bd9f67a..4372b2c 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarArtifact.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarArtifact.java @@ -39,7 +39,7 @@ public class NarArtifact this.narInfo = narInfo; } - public NarInfo getNarInfo() + public final NarInfo getNarInfo() { return narInfo; } 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 5fe3849..c0dab04 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarAssemblyMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarAssemblyMojo.java @@ -54,7 +54,7 @@ public class NarAssemblyMojo /** * Copies the unpacked nar libraries and files into the projects target area */ - public void execute() + public final void execute() throws MojoExecutionException, MojoFailureException { if ( shouldSkip() ) 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 f8b8e81..b67f0dd 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java @@ -54,7 +54,7 @@ import org.codehaus.plexus.util.StringUtils; public class NarCompileMojo extends AbstractCompileMojo { - public void execute() + public final void execute() throws MojoExecutionException, MojoFailureException { if ( shouldSkip() ) 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 cf7fa1b..6f4ec41 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarDownloadMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarDownloadMojo.java @@ -64,7 +64,7 @@ public class NarDownloadMojo */ private List classifiers; - public void execute() + public final void execute() throws MojoExecutionException, MojoFailureException { getLog().info( "Using AOL: " + getAOL() ); 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 546dc10..5c312ce 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java @@ -55,7 +55,7 @@ public class NarGnuConfigureMojo private static final String CONFIGURE = "configure"; - public void execute() + public final void execute() throws MojoExecutionException, MojoFailureException { if ( shouldSkip() ) 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 08dd305..b700c46 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarGnuMakeMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarGnuMakeMojo.java @@ -35,7 +35,7 @@ import org.apache.maven.plugin.MojoFailureException; public class NarGnuMakeMojo extends AbstractGnuMojo { - public void execute() + public final void execute() throws MojoExecutionException, MojoFailureException { if ( shouldSkip() ) 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 b0de375..85e342d 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarGnuProcess.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarGnuProcess.java @@ -35,7 +35,7 @@ import org.apache.maven.plugin.MojoFailureException; public class NarGnuProcess extends AbstractGnuMojo { - public void execute() + public final void execute() throws MojoExecutionException, MojoFailureException { if ( shouldSkip() ) 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 63e81d1..574a93d 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarGnuResources.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarGnuResources.java @@ -35,7 +35,7 @@ import org.apache.maven.plugin.MojoFailureException; public class NarGnuResources extends AbstractGnuMojo { - public void execute() + public final void execute() throws MojoExecutionException, MojoFailureException { if ( shouldSkip() ) 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 1c6b116..504d44e 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarInfo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarInfo.java @@ -146,7 +146,7 @@ public class NarInfo setProperty( aol, NarConstants.NAR+"." + type, nar ); } - public AOL getAOL( AOL aol ) + public final AOL getAOL( AOL aol ) { return aol == null ? null : new AOL( getProperty( aol, aol.toString(), aol.toString() ) ); } 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 1116106..65515fa 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java @@ -783,8 +783,8 @@ public class NarIntegrationTestMojo } else { - List includes; - List excludes; + List includeList; + List excludeList; if ( test != null ) { @@ -793,9 +793,9 @@ public class NarIntegrationTestMojo // FooTest -> **/FooTest.java - includes = new ArrayList(); + includeList = new ArrayList(); - excludes = new ArrayList(); + excludeList = new ArrayList(); if ( failIfNoTests == null ) { @@ -813,26 +813,26 @@ public class NarIntegrationTestMojo } // Allow paths delimited by '.' or '/' testRegex = testRegex.replace('.', '/'); - includes.add( "**/" + testRegex + ".java" ); + includeList.add( "**/" + testRegex + ".java" ); } } else { - includes = this.includes; + includeList = this.includes; - excludes = this.excludes; + excludeList = this.excludes; // defaults here, qdox doesn't like the end javadoc value // Have to wrap in an ArrayList as surefire expects an ArrayList instead of a List for some reason - if ( includes == null || includes.size() == 0 ) + if ( includeList == null || includeList.size() == 0 ) { - includes = + includeList = new ArrayList( Arrays.asList( new String[] { "**/Test*.java", "**/*Test.java", "**/*TestCase.java" } ) ); } - if ( excludes == null || excludes.size() == 0 ) + if ( excludeList == null || excludeList.size() == 0 ) { - excludes = + excludeList = new ArrayList( Arrays.asList( new String[] { "**/*$*" } ) ); } } @@ -840,7 +840,7 @@ public class NarIntegrationTestMojo if ( testNgArtifact != null ) { surefireBooter.addTestSuite( "org.apache.maven.surefire.testng.TestNGDirectoryTestSuite", new Object[] { - testClassesDirectory, includes, excludes, testSourceDirectory.getAbsolutePath(), + testClassesDirectory, includeList, excludeList, testSourceDirectory.getAbsolutePath(), testNgArtifact.getVersion(), testNgArtifact.getClassifier(), properties, reportsDirectory} ); } else @@ -858,8 +858,8 @@ public class NarIntegrationTestMojo // fall back to JUnit, which also contains POJO support. Also it can run // classes compiled against JUnit since it has a dependency on JUnit itself. - surefireBooter.addTestSuite( junitDirectoryTestSuite, new Object[] { testClassesDirectory, includes, - excludes } ); + surefireBooter.addTestSuite( junitDirectoryTestSuite, new Object[] { testClassesDirectory, includeList, + excludeList } ); } } diff --git a/src/main/java/org/apache/maven/plugin/nar/NarLogger.java b/src/main/java/org/apache/maven/plugin/nar/NarLogger.java index 911d8a2..31bc83b 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarLogger.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarLogger.java @@ -64,7 +64,7 @@ public class NarLogger { } - public void messageLogged( BuildEvent event ) + public final void messageLogged( BuildEvent event ) { String msg = event.getMessage(); switch ( event.getPriority() ) 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 904550e..54694f1 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarManager.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarManager.java @@ -161,11 +161,12 @@ public class NarManager * @throws MojoExecutionException * @throws MojoFailureException */ - public final List/* <AttachedNarArtifact> */getAttachedNarDependencies( List/* <NarArtifacts> */narArtifacts, AOL aol, + public final List/* <AttachedNarArtifact> */getAttachedNarDependencies( List/* <NarArtifacts> */narArtifacts, AOL archOsLinker, String type ) throws MojoExecutionException, MojoFailureException { boolean noarch = false; + AOL aol = archOsLinker; if ( aol == null ) { noarch = true; @@ -199,9 +200,10 @@ public class NarManager return artifactList; } - private List/* <AttachedNarArtifact> */getAttachedNarDependencies( Artifact dependency, AOL aol, String type ) + private List/* <AttachedNarArtifact> */getAttachedNarDependencies( Artifact dependency, AOL archOsLinker, String type ) throws MojoExecutionException, MojoFailureException { + AOL aol = archOsLinker; log.debug( "GetNarDependencies for " + dependency + ", aol: " + aol + ", type: " + type ); List artifactList = new ArrayList(); NarInfo narInfo = getNarInfo( dependency ); 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 2bd0d41..772b1b9 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java @@ -45,7 +45,7 @@ public class NarPackageMojo */ private MavenProjectHelper projectHelper; - public void execute() + public final void execute() throws MojoExecutionException, MojoFailureException { if ( shouldSkip() ) 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 cecb138..d0db151 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java @@ -54,7 +54,7 @@ public class NarResourcesMojo */ private File resourceDirectory; - public void execute() + public final void execute() throws MojoExecutionException, MojoFailureException { if ( shouldSkip() ) 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 47e969f..bd37bc6 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarSystemMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarSystemMojo.java @@ -40,7 +40,7 @@ public class NarSystemMojo extends AbstractCompileMojo { - public void execute() + public final void execute() throws MojoExecutionException, MojoFailureException { if ( shouldSkip() ) @@ -94,7 +94,7 @@ public class NarSystemMojo p.println( " *" ); p.println( " * @author maven-nar-plugin" ); p.println( " */" ); - p.println( "public class NarSystem" ); + p.println( "public final class NarSystem" ); p.println( "{" ); p.println( "" ); p.println( " private NarSystem() " ); 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 d921fe6..64eec84 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java @@ -49,7 +49,7 @@ public class NarTestCompileMojo extends AbstractCompileMojo { - public void execute() + public final void execute() throws MojoExecutionException, MojoFailureException { if ( shouldSkip() ) @@ -235,7 +235,7 @@ public class NarTestCompileMojo } } - protected File getTestTargetDirectory() + protected final 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 fd3d8fe..f520c01 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java @@ -52,7 +52,7 @@ public class NarTestMojo */ private List classpathElements; - public void execute() + public final void execute() throws MojoExecutionException, MojoFailureException { if ( shouldSkip() ) @@ -118,7 +118,7 @@ public class NarTestMojo } } - protected File getTestTargetDirectory() + protected final File getTestTargetDirectory() { return new File( getMavenProject().getBuild().getDirectory(), "test-nar" ); } 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 6f1da03..265dbf1 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java @@ -55,7 +55,7 @@ public class NarUnpackMojo */ private ArchiverManager archiverManager; - public void execute() + public final void execute() throws MojoExecutionException, MojoFailureException { if ( shouldSkip() ) 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 62817f1..b3d6ac5 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarUtil.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarUtil.java @@ -67,8 +67,9 @@ public final class NarUtil return defaults; } - public static String getOS( String os ) + public static String getOS( String defaultOs ) { + String os = defaultOs; // adjust OS if not given if ( os == null ) { @@ -97,11 +98,12 @@ public final class NarUtil public static Linker getLinker( Linker linker ) { - if ( linker == null ) + Linker link = linker; + if ( link == null ) { - linker = new Linker(); + link = new Linker(); } - return linker; + return link; } public static String getLinkerName( String architecture, String os, Linker linker ) @@ -136,16 +138,17 @@ public final class NarUtil public static File getJavaHome( File javaHome, String os ) { + File home = javaHome; // adjust JavaHome - if ( javaHome == null ) + if ( home == null ) { - javaHome = new File( System.getProperty( "java.home" ) ); + home = new File( System.getProperty( "java.home" ) ); if ( !getOS( os ).equals( OS.MACOSX ) ) { - javaHome = new File( javaHome, ".." ); + home = new File( home, ".." ); } } - return javaHome; + return home; } public static void makeExecutable( File file, final Log log ) @@ -224,15 +227,15 @@ public final class NarUtil * @param filename the absolute file name of the class * @return the header file name. */ - public static String getHeaderName( String base, String filename ) + public static String getHeaderName( String basename, String filename ) { - base = base.replaceAll( "\\\\", "/" ); - filename = filename.replaceAll( "\\\\", "/" ); - if ( !filename.startsWith( base ) ) + String base = basename.replaceAll( "\\\\", "/" ); + String file = filename.replaceAll( "\\\\", "/" ); + if ( !file.startsWith( base ) ) { - throw new IllegalArgumentException( "Error " + filename + " does not start with " + base ); + throw new IllegalArgumentException( "Error " + file + " does not start with " + base ); } - String header = filename.substring( base.length() + 1 ); + String header = file.substring( base.length() + 1 ); header = header.replaceAll( "/", "_" ); header = header.replaceAll( "\\.class", ".h" ); return header; @@ -413,14 +416,15 @@ public final class NarUtil value = NarUtil.getEnv( pathName, pathName, null ); } - path = path.replace( File.pathSeparatorChar, separator ); + String libPath = path; + libPath = libPath.replace( File.pathSeparatorChar, separator ); if ( value != null ) { - value += separator + path; + value += separator + libPath; } else { - value = path; + value = libPath; } if ( environment != null ) { diff --git a/src/main/java/org/apache/maven/plugin/nar/StringTextStream.java b/src/main/java/org/apache/maven/plugin/nar/StringTextStream.java index 5bc3b15..8acf4e0 100644 --- a/src/main/java/org/apache/maven/plugin/nar/StringTextStream.java +++ b/src/main/java/org/apache/maven/plugin/nar/StringTextStream.java @@ -43,13 +43,13 @@ public class StringTextStream * (non-Javadoc) * @see org.apache.maven.plugin.nar.TextStream#println(java.lang.String) */ - public void println( String text ) + public final void println( String text ) { sb.append( text ); sb.append( lineSeparator ); } - public String toString() + public final String toString() { return sb.toString(); } diff --git a/src/main/java/org/apache/maven/plugin/nar/SysLib.java b/src/main/java/org/apache/maven/plugin/nar/SysLib.java index 58a0c6e..cf3e0e7 100644 --- a/src/main/java/org/apache/maven/plugin/nar/SysLib.java +++ b/src/main/java/org/apache/maven/plugin/nar/SysLib.java @@ -33,7 +33,6 @@ import org.apache.tools.ant.Project; */ public class SysLib { - /** * Name of the system library * @@ -50,7 +49,7 @@ public class SysLib */ private String type = Library.SHARED; - public SystemLibrarySet getSysLibSet( Project antProject ) + public final SystemLibrarySet getSysLibSet( Project antProject ) throws MojoFailureException { if ( name == null ) |