diff options
author | Mark Donszelmann <Mark.Donszelmann@gmail.com> | 2009-10-16 16:52:34 +0200 |
---|---|---|
committer | Mark Donszelmann <Mark.Donszelmann@gmail.com> | 2009-10-16 16:52:34 +0200 |
commit | 982b7a322e648d388cc77c06f80b2947a7bd8a52 (patch) | |
tree | 74c042cd7871a7099e0cc43538ee4f8175ca4f80 /src | |
parent | 9b1643ef71a5b0d6c9db8cb9859b045c4adad911 (diff) | |
download | maven-nar-plugin-982b7a322e648d388cc77c06f80b2947a7bd8a52.tar.gz maven-nar-plugin-982b7a322e648d388cc77c06f80b2947a7bd8a52.tar.bz2 maven-nar-plugin-982b7a322e648d388cc77c06f80b2947a7bd8a52.tar.xz maven-nar-plugin-982b7a322e648d388cc77c06f80b2947a7bd8a52.zip |
Fixed NAR-71 and part of NAR-69
Diffstat (limited to 'src')
5 files changed, 74 insertions, 30 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 ca263cf..97423f8 100644 --- a/src/main/java/org/apache/maven/plugin/nar/Compiler.java +++ b/src/main/java/org/apache/maven/plugin/nar/Compiler.java @@ -214,19 +214,24 @@ public abstract class Compiler this.mojo = mojo; } - public File getSourceDirectory() + public List/* <File> */getSourceDirectories() { - return getSourceDirectory( "dummy" ); + return getSourceDirectories( "dummy" ); } - protected File getSourceDirectory( String type ) + private List/* <File> */getSourceDirectories( String type ) { + List sourceDirectories = new ArrayList(); + if ( sourceDirectory == null ) { - sourceDirectory = - new File( mojo.getMavenProject().getBasedir(), "src/" + ( type.equals( "test" ) ? "test" : "main" ) ); + sourceDirectories.add( new File( mojo.getMavenProject().getBasedir(), "src/" + + ( type.equals( "test" ) ? "test" : "main" ) ) ); } - return sourceDirectory; + + // FIXME, see NAR-69 + sourceDirectories.add( new File( mojo.getMavenProject().getBasedir(), "target/swig" ) ); + return sourceDirectories; } protected List/* <String> */getIncludePaths( String type ) @@ -234,7 +239,10 @@ public abstract class Compiler if ( includePaths == null || ( includePaths.size() == 0 ) ) { includePaths = new ArrayList(); - includePaths.add( new File( getSourceDirectory( type ), "include" ).getPath() ); + for ( Iterator i = getSourceDirectories( type ).iterator(); i.hasNext(); ) + { + includePaths.add( new File( (File) i.next(), "include" ).getPath() ); + } } return includePaths; } @@ -487,7 +495,7 @@ public abstract class Compiler } // Add default fileset (if exists) - File srcDir = getSourceDirectory( type ); + List srcDirs = getSourceDirectories( type ); Set includes = getIncludes(); Set excludes = getExcludes(); @@ -501,18 +509,22 @@ public abstract class Compiler } } - mojo.getLog().debug( "Checking for existence of " + getName() + " sourceDirectory: " + srcDir ); - if ( srcDir.exists() ) + for ( Iterator i = srcDirs.iterator(); i.hasNext(); ) { - ConditionalFileSet fileSet = new ConditionalFileSet(); - fileSet.setProject( mojo.getAntProject() ); - fileSet.setIncludes( StringUtils.join( includes.iterator(), "," ) ); - fileSet.setExcludes( StringUtils.join( excludes.iterator(), "," ) ); - fileSet.setDir( srcDir ); - compiler.addFileset( fileSet ); + File srcDir = (File) i.next(); + mojo.getLog().debug( "Checking for existence of " + getName() + " sourceDirectory: " + 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.setDir( srcDir ); + compiler.addFileset( fileSet ); + } } - // add other sources + // add other sources, FIXME seems if ( !type.equals( "test" ) ) { for ( Iterator i = mojo.getMavenProject().getCompileSourceRoots().iterator(); i.hasNext(); ) 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 f5727f6..5785ac6 100644 --- a/src/main/java/org/apache/maven/plugin/nar/Library.java +++ b/src/main/java/org/apache/maven/plugin/nar/Library.java @@ -143,4 +143,13 @@ public class Library { return narSystemDirectory; } + + // FIXME incomplete + public String toString() + { + StringBuffer sb = new StringBuffer( "Library: " ); + sb.append( "type: " ); + sb.append( getType() ); + return sb.toString(); + } } 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 26256cb..d6d8345 100644 --- a/src/main/java/org/apache/maven/plugin/nar/Linker.java +++ b/src/main/java/org/apache/maven/plugin/nar/Linker.java @@ -192,27 +192,36 @@ public class Linker Set defs = new HashSet(); try { - File cSrcDir = mojo.getC().getSourceDirectory(); - if ( cSrcDir.exists() ) - defs.addAll( FileUtils.getFiles( cSrcDir, "**/*.def", null ) ); + List cSrcDirs = mojo.getC().getSourceDirectories(); + for (Iterator i = cSrcDirs.iterator(); i.hasNext(); ) { + File dir = (File)i.next(); + if ( dir.exists() ) + defs.addAll( FileUtils.getFiles( dir, "**/*.def", null ) ); + } } catch ( IOException e ) { } try { - File cppSrcDir = mojo.getCpp().getSourceDirectory(); - if ( cppSrcDir.exists() ) - defs.addAll( FileUtils.getFiles( cppSrcDir, "**/*.def", null ) ); + List cppSrcDirs = mojo.getCpp().getSourceDirectories(); + for (Iterator i = cppSrcDirs.iterator(); i.hasNext(); ) { + File dir = (File)i.next(); + if ( dir.exists() ) + defs.addAll( FileUtils.getFiles( dir, "**/*.def", null ) ); + } } catch ( IOException e ) { } try { - File fortranSrcDir = mojo.getFortran().getSourceDirectory(); - if ( fortranSrcDir.exists() ) - defs.addAll( FileUtils.getFiles( fortranSrcDir, "**/*.def", null ) ); + List fortranSrcDirs = mojo.getFortran().getSourceDirectories(); + for (Iterator i = fortranSrcDirs.iterator(); i.hasNext(); ) { + File dir = (File)i.next(); + if ( dir.exists() ) + defs.addAll( FileUtils.getFiles( dir, "**/*.def", null ) ); + } } catch ( IOException e ) { 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 7cab1de..47c6f76 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java @@ -21,6 +21,7 @@ package org.apache.maven.plugin.nar; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; @@ -70,11 +71,16 @@ public class NarCompileMojo noOfSources += getSourcesFor( getFortran() ).size(); if ( noOfSources > 0 ) { + getLog().info( "Compiling " + noOfSources + " native files" ); for ( Iterator i = getLibraries().iterator(); i.hasNext(); ) { createLibrary( getAntProject(), (Library) i.next() ); } } + else + { + getLog().info( "Nothing to compile" ); + } try { @@ -92,10 +98,16 @@ public class NarCompileMojo { try { - File srcDir = compiler.getSourceDirectory(); - return srcDir.exists() ? FileUtils.getFiles( srcDir, StringUtils.join( compiler.getIncludes().iterator(), - "," ), null ) - : Collections.EMPTY_LIST; + List files = new ArrayList(); + List srcDirs = compiler.getSourceDirectories(); + for ( Iterator i = srcDirs.iterator(); i.hasNext(); ) + { + File dir = (File) i.next(); + if ( dir.exists() ) + files.addAll( FileUtils.getFiles( dir, StringUtils.join( compiler.getIncludes().iterator(), "," ), + null ) ); + } + return files; } catch ( IOException e ) { @@ -106,6 +118,7 @@ public class NarCompileMojo private void createLibrary( Project antProject, Library library ) throws MojoExecutionException, MojoFailureException { + getLog().debug( "Creating Library " + library ); // configure task CCTask task = new CCTask(); task.setProject( antProject ); diff --git a/src/main/java/org/apache/maven/plugin/nar/NarSystemGenerate.java b/src/main/java/org/apache/maven/plugin/nar/NarSystemGenerate.java index 72857cf..84db06e 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarSystemGenerate.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarSystemGenerate.java @@ -73,6 +73,7 @@ public class NarSystemGenerate fullDir.mkdirs(); File narSystem = new File( fullDir, narSystemName + ".java" ); + getLog().info("Generating "+narSystem); try { FileOutputStream fos = new FileOutputStream( narSystem ); |