From b2334d66b00ce4574654df77202abd970332751f Mon Sep 17 00:00:00 2001 From: Mark Donszelmann Date: Wed, 21 Oct 2009 23:15:24 +0200 Subject: Fixed NAR-28 --- .../java/org/apache/maven/plugin/nar/Compiler.java | 43 ++++++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) (limited to 'src/main/java') 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 97423f8..13be6f3 100644 --- a/src/main/java/org/apache/maven/plugin/nar/Compiler.java +++ b/src/main/java/org/apache/maven/plugin/nar/Compiler.java @@ -64,6 +64,14 @@ public abstract class Compiler */ private File sourceDirectory; + /** + * Source directory for native test files + * + * @parameter expression="${basedir}/src/test" + * @required + */ + private File testSourceDirectory; + /** * Include patterns for sources * @@ -174,6 +182,13 @@ public abstract class Compiler */ private List includePaths; + /** + * Test Include Paths. Defaults to "${testSourceDirectory}/include" + * + * @parameter expression="" + */ + private List testIncludePaths; + /** * System Include Paths, which are added at the end of all include paths * @@ -223,10 +238,17 @@ public abstract class Compiler { List sourceDirectories = new ArrayList(); - if ( sourceDirectory == null ) + if ( type.equals( "test" ) ) + { + if ( testSourceDirectory == null ) + testSourceDirectory = new File( mojo.getMavenProject().getBasedir(), "/src/test" ); + sourceDirectories.add( testSourceDirectory ); + } + else { - sourceDirectories.add( new File( mojo.getMavenProject().getBasedir(), "src/" - + ( type.equals( "test" ) ? "test" : "main" ) ) ); + if ( sourceDirectory == null ) + sourceDirectory = new File( mojo.getMavenProject().getBasedir(), "src/main" ); + sourceDirectories.add( sourceDirectory ); } // FIXME, see NAR-69 @@ -236,15 +258,20 @@ public abstract class Compiler protected List/* */getIncludePaths( String type ) { - if ( includePaths == null || ( includePaths.size() == 0 ) ) + return createIncludePaths( type, type.equals( "test" ) ? testIncludePaths : includePaths ); + } + + private List/* */createIncludePaths( String type, List paths ) + { + if ( paths == null || ( paths.size() == 0 ) ) { - includePaths = new ArrayList(); + paths = new ArrayList(); for ( Iterator i = getSourceDirectories( type ).iterator(); i.hasNext(); ) { - includePaths.add( new File( (File) i.next(), "include" ).getPath() ); + paths.add( new File( (File) i.next(), "include" ).getPath() ); } } - return includePaths; + return paths; } public Set getIncludes() @@ -512,7 +539,7 @@ public abstract class Compiler for ( Iterator i = srcDirs.iterator(); i.hasNext(); ) { File srcDir = (File) i.next(); - mojo.getLog().debug( "Checking for existence of " + getName() + " sourceDirectory: " + srcDir ); + mojo.getLog().debug( "Checking for existence of " + getName() + " source directory: " + srcDir ); if ( srcDir.exists() ) { ConditionalFileSet fileSet = new ConditionalFileSet(); -- cgit v1.2.3