summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/Compiler.java52
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java26
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java24
3 files changed, 68 insertions, 34 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 3c18951..0c71aa2 100644
--- a/src/main/java/org/apache/maven/plugin/nar/Compiler.java
+++ b/src/main/java/org/apache/maven/plugin/nar/Compiler.java
@@ -218,7 +218,7 @@ public abstract class Compiler
* @required
*/
private boolean clearDefaultOptions;
-
+
/**
* Comma separated list of filenames to compile in order
*
@@ -229,25 +229,22 @@ public abstract class Compiler
private AbstractCompileMojo mojo;
private static final String TEST = "test";
-
+
protected Compiler()
{
}
- private String getName() throws MojoFailureException {
+ 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;
@@ -304,11 +301,12 @@ public abstract class Compiler
}
}
- if (mojo.getLog().isDebugEnabled()) {
- for ( Iterator i = sourceDirectories.iterator(); i.hasNext(); )
+ if ( mojo.getLog().isDebugEnabled() )
{
- mojo.getLog().debug( "Added to sourceDirectory: " + ((File)i.next()).getPath() );
- }
+ for ( Iterator i = sourceDirectories.iterator(); i.hasNext(); )
+ {
+ mojo.getLog().debug( "Added to sourceDirectory: " + ( (File) i.next() ).getPath() );
+ }
}
return sourceDirectories;
}
@@ -349,17 +347,13 @@ public abstract class Compiler
else
{
String defaultIncludes = NarUtil.getDefaults().getProperty( getPrefix() + "includes" );
- if ( defaultIncludes == null )
- {
- throw new MojoFailureException(
- "NAR: Please specify <Includes> as part of <Cpp>, <C> or <Fortran> for "
- + getPrefix() );
- }
-
- String[] include = defaultIncludes.split( " " );
- for ( int i = 0; i < include.length; i++ )
+ if ( defaultIncludes != null )
{
- result.add( include[i].trim() );
+ String[] include = defaultIncludes.split( " " );
+ for ( int i = 0; i < include.length; i++ )
+ {
+ result.add( include[i].trim() );
+ }
}
}
return result;
@@ -400,10 +394,13 @@ public abstract class Compiler
public final CompilerDef getCompiler( String type, String output )
throws MojoFailureException
{
+ String name = getName();
+ if (name == null) return null;
+
CompilerDef compiler = new CompilerDef();
compiler.setProject( mojo.getAntProject() );
CompilerEnum compilerName = new CompilerEnum();
- compilerName.setValue( getName() );
+ compilerName.setValue( name );
compiler.setName( compilerName );
// debug, exceptions, rtti, multiThreaded
@@ -590,10 +587,11 @@ public abstract class Compiler
mojo.getLog().debug( "Checking for existence of " + getLanguage() + " source directory: " + srcDir );
if ( srcDir.exists() )
{
- if (compileOrder != null) {
- compiler.setOrder(Arrays.asList(StringUtils.split(compileOrder, ", ")));
+ if ( compileOrder != null )
+ {
+ compiler.setOrder( Arrays.asList( StringUtils.split( compileOrder, ", " ) ) );
}
-
+
ConditionalFileSet fileSet = new ConditionalFileSet();
fileSet.setProject( mojo.getAntProject() );
fileSet.setIncludes( StringUtils.join( includeSet.iterator(), "," ) );
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 e447b59..ddf1407 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java
@@ -29,6 +29,7 @@ import java.util.List;
import net.sf.antcontrib.cpptasks.CCTask;
import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.CompilerDef;
import net.sf.antcontrib.cpptasks.LinkerDef;
import net.sf.antcontrib.cpptasks.OutputTypeEnum;
import net.sf.antcontrib.cpptasks.RuntimeType;
@@ -184,15 +185,32 @@ public class NarCompileMojo
runtimeType.setValue( getRuntime( getAOL() ) );
task.setRuntime( runtimeType );
+ int noOfCompilers = 0;
+
// add C++ compiler
- task.addConfiguredCompiler( getCpp().getCompiler( type, getOutput( getAOL() ) ) );
+ CompilerDef cpp = getCpp().getCompiler( type, getOutput( getAOL() ) );
+ if ( cpp != null )
+ {
+ task.addConfiguredCompiler( cpp );
+ noOfCompilers++;
+ }
// add C compiler
- task.addConfiguredCompiler( getC().getCompiler( type, getOutput( getAOL() ) ) );
+ CompilerDef c = getC().getCompiler( type, getOutput( getAOL() ) );
+ if ( c != null )
+ {
+ task.addConfiguredCompiler( c );
+ noOfCompilers++;
+ }
// add Fortran compiler
- task.addConfiguredCompiler( getFortran().getCompiler( type, getOutput( getAOL() ) ) );
-
+ CompilerDef fortran = getFortran().getCompiler( type, getOutput( getAOL() ) );
+ if ( fortran != null )
+ {
+ task.addConfiguredCompiler( fortran );
+ noOfCompilers++;
+ }
+
// add javah include path
File jniDirectory = getJavah().getJniDirectory();
if ( jniDirectory.exists() )
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 64eec84..5c2bd36 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java
@@ -26,6 +26,7 @@ import java.util.List;
import net.sf.antcontrib.cpptasks.CCTask;
import net.sf.antcontrib.cpptasks.CUtil;
+import net.sf.antcontrib.cpptasks.CompilerDef;
import net.sf.antcontrib.cpptasks.OutputTypeEnum;
import net.sf.antcontrib.cpptasks.RuntimeType;
import net.sf.antcontrib.cpptasks.types.LibrarySet;
@@ -105,14 +106,31 @@ public class NarTestCompileMojo
runtimeType.setValue( getRuntime( getAOL() ) );
task.setRuntime( runtimeType );
+ int noOfCompilers = 0;
+
// add C++ compiler
- task.addConfiguredCompiler( getCpp().getCompiler( type, test.getName() ) );
+ CompilerDef cpp = getCpp().getCompiler( type, test.getName() );
+ if ( cpp != null )
+ {
+ task.addConfiguredCompiler( cpp );
+ noOfCompilers++;
+ }
// add C compiler
- task.addConfiguredCompiler( getC().getCompiler( type, test.getName() ) );
+ CompilerDef c = getC().getCompiler( type, test.getName() );
+ if ( c != null )
+ {
+ task.addConfiguredCompiler( c );
+ noOfCompilers++;
+ }
// add Fortran compiler
- task.addConfiguredCompiler( getFortran().getCompiler( type, test.getName() ) );
+ CompilerDef fortran = getFortran().getCompiler( type, test.getName() );
+ if ( fortran != null )
+ {
+ task.addConfiguredCompiler( fortran );
+ noOfCompilers++;
+ }
// add java include paths
getJava().addIncludePaths( task, type );