summaryrefslogtreecommitdiff
path: root/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java
diff options
context:
space:
mode:
authorMark Donszelmann <Mark.Donszelmann@gmail.com>2009-10-06 14:44:29 +0200
committerMark Donszelmann <Mark.Donszelmann@gmail.com>2009-10-06 14:44:29 +0200
commit3dca89f0015613ab3f287945965e9f92a6079cd8 (patch)
treea00619a63c55b74c16ac8116d04b21f322e1747b /src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java
parent75b9fcffc6709f9c65990f6d04d593d3bfb4743d (diff)
downloadmaven-nar-plugin-3dca89f0015613ab3f287945965e9f92a6079cd8.tar.gz
maven-nar-plugin-3dca89f0015613ab3f287945965e9f92a6079cd8.tar.bz2
maven-nar-plugin-3dca89f0015613ab3f287945965e9f92a6079cd8.tar.xz
maven-nar-plugin-3dca89f0015613ab3f287945965e9f92a6079cd8.zip
Reformat all source files and add licenses to tests
Diffstat (limited to 'src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java')
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java344
1 files changed, 172 insertions, 172 deletions
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 995a76f..9b5a98f 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java
@@ -45,198 +45,198 @@ import org.apache.tools.ant.Project;
* @requiresDependencyResolution test
* @author Mark Donszelmann
*/
-public class NarTestCompileMojo extends AbstractCompileMojo {
-
- public void execute() throws MojoExecutionException, MojoFailureException {
- if (shouldSkip())
- return;
-
- // make sure destination is there
- getTargetDirectory().mkdirs();
-
- for (Iterator i = getTests().iterator(); i.hasNext();) {
- createTest(getAntProject(), (Test) i.next());
- }
- }
-
- private void createTest(Project antProject, Test test)
- throws MojoExecutionException, MojoFailureException {
- String type = "test";
-
- // configure task
- CCTask task = new CCTask();
- task.setProject(antProject);
-
- // outtype
- OutputTypeEnum outTypeEnum = new OutputTypeEnum();
- outTypeEnum.setValue(Library.EXECUTABLE);
- task.setOuttype(outTypeEnum);
-
- // outDir
- File outDir = new File(getTargetDirectory(), "bin");
- outDir = new File(outDir, getAOL().toString());
- outDir.mkdirs();
-
- // outFile
- File outFile = new File(outDir, test.getName());
- getLog().debug("NAR - output: '" + outFile + "'");
- task.setOutfile(outFile);
-
- // object directory
- File objDir = new File(getTargetDirectory(), "obj");
- objDir = new File(objDir, getAOL().toString());
- objDir.mkdirs();
- task.setObjdir(objDir);
-
- // failOnError, libtool
- task.setFailonerror(failOnError(getAOL()));
- task.setLibtool(useLibtool(getAOL()));
-
- // runtime
- RuntimeType runtimeType = new RuntimeType();
- runtimeType.setValue(getRuntime(getAOL()));
- task.setRuntime(runtimeType);
-
- // add C++ compiler
- task.addConfiguredCompiler(getCpp().getCompiler(type, test.getName()));
-
- // add C compiler
- task.addConfiguredCompiler(getC().getCompiler(type, test.getName()));
-
- // add Fortran compiler
- task.addConfiguredCompiler(getFortran().getCompiler(type,
- test.getName()));
-
- // add java include paths
- getJava().addIncludePaths(task, type);
-
- // add dependency include paths
- for (Iterator i = getNarManager().getNarDependencies("test").iterator(); i
- .hasNext();) {
- File include = new File(getNarManager().getNarFile(
- (Artifact) i.next()).getParentFile(), "nar/include");
- if (include.exists()) {
- task.createIncludePath().setPath(include.getPath());
- }
- }
-
- // add linker
- task.addConfiguredLinker(getLinker().getLinker(this, antProject,
- getOS(), getAOL().getKey() + "linker.", type));
-
- // FIXME hardcoded values
- String libName = getFinalName();
- File includeDir = new File(getMavenProject().getBuild().getDirectory(),
- "nar/include");
- File libDir = new File(getMavenProject().getBuild().getDirectory(),
- "nar/lib/" + getAOL() + "/" + test.getLink());
-
- // copy shared library
- // FIXME why do we do this ?
-/* Removed in alpha-10
- if (test.getLink().equals(Library.SHARED)) {
- try {
- // defaults are Unix
- String libPrefix = NarUtil.getDefaults().getProperty(
- getAOLKey() + "shared.prefix", "lib");
- String libExt = NarUtil.getDefaults().getProperty(
- getAOLKey() + "shared.extension", "so");
- File copyDir = new File(getTargetDirectory(), (getOS().equals(
- "Windows") ? "bin" : "lib")
- + "/" + getAOL() + "/" + test.getLink());
- FileUtils.copyFileToDirectory(new File(libDir, libPrefix
- + libName + "." + libExt), copyDir);
- if (!getOS().equals(OS.WINDOWS)) {
- libDir = copyDir;
- }
- } catch (IOException e) {
- throw new MojoExecutionException(
- "NAR: Could not copy shared library", e);
- }
- }
-*/
- // FIXME what about copying the other shared libs?
-
- // add include of this package
- if (includeDir.exists()) {
- task.createIncludePath().setLocation(includeDir);
- }
-
- // add library of this package
- if (libDir.exists()) {
- LibrarySet libSet = new LibrarySet();
- libSet.setProject(antProject);
- libSet.setLibs(new CUtil.StringArrayBuilder(libName));
- LibraryTypeEnum libType = new LibraryTypeEnum();
- libType.setValue(test.getLink());
- libSet.setType(libType);
- libSet.setDir(libDir);
- task.addLibset(libSet);
- }
-
- // add dependency libraries
+public class NarTestCompileMojo
+ extends AbstractCompileMojo
+{
+
+ public void execute()
+ throws MojoExecutionException, MojoFailureException
+ {
+ if ( shouldSkip() )
+ return;
+
+ // make sure destination is there
+ getTargetDirectory().mkdirs();
+
+ for ( Iterator i = getTests().iterator(); i.hasNext(); )
+ {
+ createTest( getAntProject(), (Test) i.next() );
+ }
+ }
+
+ private void createTest( Project antProject, Test test )
+ throws MojoExecutionException, MojoFailureException
+ {
+ String type = "test";
+
+ // configure task
+ CCTask task = new CCTask();
+ task.setProject( antProject );
+
+ // outtype
+ OutputTypeEnum outTypeEnum = new OutputTypeEnum();
+ outTypeEnum.setValue( Library.EXECUTABLE );
+ task.setOuttype( outTypeEnum );
+
+ // outDir
+ File outDir = new File( getTargetDirectory(), "bin" );
+ outDir = new File( outDir, getAOL().toString() );
+ outDir.mkdirs();
+
+ // outFile
+ File outFile = new File( outDir, test.getName() );
+ getLog().debug( "NAR - output: '" + outFile + "'" );
+ task.setOutfile( outFile );
+
+ // object directory
+ File objDir = new File( getTargetDirectory(), "obj" );
+ objDir = new File( objDir, getAOL().toString() );
+ objDir.mkdirs();
+ task.setObjdir( objDir );
+
+ // failOnError, libtool
+ task.setFailonerror( failOnError( getAOL() ) );
+ task.setLibtool( useLibtool( getAOL() ) );
+
+ // runtime
+ RuntimeType runtimeType = new RuntimeType();
+ runtimeType.setValue( getRuntime( getAOL() ) );
+ task.setRuntime( runtimeType );
+
+ // add C++ compiler
+ task.addConfiguredCompiler( getCpp().getCompiler( type, test.getName() ) );
+
+ // add C compiler
+ task.addConfiguredCompiler( getC().getCompiler( type, test.getName() ) );
+
+ // add Fortran compiler
+ task.addConfiguredCompiler( getFortran().getCompiler( type, test.getName() ) );
+
+ // add java include paths
+ getJava().addIncludePaths( task, type );
+
+ // add dependency include paths
+ for ( Iterator i = getNarManager().getNarDependencies( "test" ).iterator(); i.hasNext(); )
+ {
+ File include = new File( getNarManager().getNarFile( (Artifact) i.next() ).getParentFile(), "nar/include" );
+ if ( include.exists() )
+ {
+ task.createIncludePath().setPath( include.getPath() );
+ }
+ }
+
+ // add linker
+ task.addConfiguredLinker( getLinker().getLinker( this, antProject, getOS(), getAOL().getKey() + "linker.", type ) );
+
+ // FIXME hardcoded values
+ String libName = getFinalName();
+ File includeDir = new File( getMavenProject().getBuild().getDirectory(), "nar/include" );
+ File libDir =
+ new File( getMavenProject().getBuild().getDirectory(), "nar/lib/" + getAOL() + "/" + test.getLink() );
+
+ // copy shared library
+ // FIXME why do we do this ?
+ /*
+ * Removed in alpha-10 if (test.getLink().equals(Library.SHARED)) { try { // defaults are Unix String libPrefix
+ * = NarUtil.getDefaults().getProperty( getAOLKey() + "shared.prefix", "lib"); String libExt =
+ * NarUtil.getDefaults().getProperty( getAOLKey() + "shared.extension", "so"); File copyDir = new
+ * File(getTargetDirectory(), (getOS().equals( "Windows") ? "bin" : "lib") + "/" + getAOL() + "/" +
+ * test.getLink()); FileUtils.copyFileToDirectory(new File(libDir, libPrefix + libName + "." + libExt),
+ * copyDir); if (!getOS().equals(OS.WINDOWS)) { libDir = copyDir; } } catch (IOException e) { throw new
+ * MojoExecutionException( "NAR: Could not copy shared library", e); } }
+ */
+ // FIXME what about copying the other shared libs?
+
+ // add include of this package
+ if ( includeDir.exists() )
+ {
+ task.createIncludePath().setLocation( includeDir );
+ }
+
+ // add library of this package
+ if ( libDir.exists() )
+ {
+ LibrarySet libSet = new LibrarySet();
+ libSet.setProject( antProject );
+ libSet.setLibs( new CUtil.StringArrayBuilder( libName ) );
+ LibraryTypeEnum libType = new LibraryTypeEnum();
+ libType.setValue( test.getLink() );
+ libSet.setType( libType );
+ libSet.setDir( libDir );
+ task.addLibset( libSet );
+ }
+
+ // add dependency libraries
List depLibOrder = getDependencyLibOrder();
- List depLibs = getNarManager().getNarDependencies("test");
+ List depLibs = getNarManager().getNarDependencies( "test" );
// reorder the libraries that come from the nar dependencies
// to comply with the order specified by the user
- if ((depLibOrder != null) && !depLibOrder.isEmpty()) {
+ if ( ( depLibOrder != null ) && !depLibOrder.isEmpty() )
+ {
List tmp = new LinkedList();
- for (Iterator i = depLibOrder.iterator(); i.hasNext();) {
+ for ( Iterator i = depLibOrder.iterator(); i.hasNext(); )
+ {
- String depToOrderName = (String)i.next();
+ String depToOrderName = (String) i.next();
- for (Iterator j = depLibs.iterator(); j.hasNext();) {
+ for ( Iterator j = depLibs.iterator(); j.hasNext(); )
+ {
- NarArtifact dep = (NarArtifact)j.next();
+ NarArtifact dep = (NarArtifact) j.next();
String depName = dep.getGroupId() + ":" + dep.getArtifactId();
- if (depName.equals(depToOrderName)) {
+ if ( depName.equals( depToOrderName ) )
+ {
- tmp.add(dep);
+ tmp.add( dep );
j.remove();
}
}
}
- tmp.addAll(depLibs);
+ tmp.addAll( depLibs );
depLibs = tmp;
}
- for (Iterator i = depLibs.iterator(); i.hasNext();) {
-
- Artifact dependency = (Artifact) i.next();
- // FIXME: this should be preferred binding
- File lib = new File(getNarManager().getNarFile(dependency)
- .getParentFile(), "nar/lib/" + getAOL() + "/"
- + test.getLink());
- if (lib.exists()) {
- LibrarySet libset = new LibrarySet();
- libset.setProject(antProject);
- libset.setLibs(new CUtil.StringArrayBuilder(dependency
- .getArtifactId()
- + "-" + dependency.getVersion()));
- libset.setDir(lib);
- task.addLibset(libset);
- }
- }
-
- // Add JVM to linker
- getJava().addRuntime(task, getJavaHome(getAOL()), getOS(),
- getAOL().getKey() + ".java.");
-
- // execute
- try {
- task.execute();
- } catch (BuildException e) {
- throw new MojoExecutionException("NAR: Test-Compile failed", e);
- }
- }
-
- protected File getTargetDirectory() {
- return new File(getMavenProject().getBuild().getDirectory(), "test-nar");
- }
+ for ( Iterator i = depLibs.iterator(); i.hasNext(); )
+ {
+
+ Artifact dependency = (Artifact) i.next();
+ // FIXME: this should be preferred binding
+ File lib =
+ new File( getNarManager().getNarFile( dependency ).getParentFile(), "nar/lib/" + getAOL() + "/"
+ + test.getLink() );
+ if ( lib.exists() )
+ {
+ LibrarySet libset = new LibrarySet();
+ libset.setProject( antProject );
+ libset.setLibs( new CUtil.StringArrayBuilder( dependency.getArtifactId() + "-"
+ + dependency.getVersion() ) );
+ libset.setDir( lib );
+ task.addLibset( libset );
+ }
+ }
+
+ // Add JVM to linker
+ getJava().addRuntime( task, getJavaHome( getAOL() ), getOS(), getAOL().getKey() + ".java." );
+
+ // execute
+ try
+ {
+ task.execute();
+ }
+ catch ( BuildException e )
+ {
+ throw new MojoExecutionException( "NAR: Test-Compile failed", e );
+ }
+ }
+
+ protected File getTargetDirectory()
+ {
+ return new File( getMavenProject().getBuild().getDirectory(), "test-nar" );
+ }
}