From 9e80bf8629df3b01238778088b5444024036929a Mon Sep 17 00:00:00 2001 From: Mark Donszelmann Date: Wed, 4 Nov 2009 10:46:47 +0100 Subject: Fixed NAR-101 --- .../java/org/apache/maven/plugin/nar/Compiler.java | 34 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) 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 13be6f3..9d4cb09 100644 --- a/src/main/java/org/apache/maven/plugin/nar/Compiler.java +++ b/src/main/java/org/apache/maven/plugin/nar/Compiler.java @@ -237,22 +237,46 @@ public abstract class Compiler private List/* */getSourceDirectories( String type ) { List sourceDirectories = new ArrayList(); + File baseDir = mojo.getMavenProject().getBasedir(); if ( type.equals( "test" ) ) { if ( testSourceDirectory == null ) - testSourceDirectory = new File( mojo.getMavenProject().getBasedir(), "/src/test" ); - sourceDirectories.add( testSourceDirectory ); + testSourceDirectory = new File( baseDir, "/src/test" ); + if ( testSourceDirectory.exists() ) + sourceDirectories.add( testSourceDirectory ); + + for ( Iterator i = mojo.getMavenProject().getTestCompileSourceRoots().iterator(); i.hasNext(); ) + { + File extraTestSourceDirectory = new File( (String) i.next() ); + if ( extraTestSourceDirectory.exists() ) + sourceDirectories.add( extraTestSourceDirectory ); + } } else { if ( sourceDirectory == null ) - sourceDirectory = new File( mojo.getMavenProject().getBasedir(), "src/main" ); - sourceDirectories.add( sourceDirectory ); + sourceDirectory = new File( baseDir, "src/main" ); + if ( sourceDirectory.exists() ) + sourceDirectories.add( sourceDirectory ); + + for ( Iterator i = mojo.getMavenProject().getCompileSourceRoots().iterator(); i.hasNext(); ) + { + File extraSourceDirectory = new File( (String) i.next() ); + if ( extraSourceDirectory.exists() ) + sourceDirectories.add( extraSourceDirectory ); + } } // FIXME, see NAR-69 - sourceDirectories.add( new File( mojo.getMavenProject().getBasedir(), "target/swig" ) ); + File swigDir = new File( baseDir, "target/swig" ); + if ( swigDir.exists() ) + sourceDirectories.add( swigDir ); + + if (mojo.getLog().isDebugEnabled()) { + for ( Iterator i = sourceDirectories.iterator(); i.hasNext(); ) + mojo.getLog().debug( "Added to sourceDirectory: " + ((File)i.next()).getPath() ); + } return sourceDirectories; } -- cgit v1.2.3