summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/AbstractDownloadMojo.java60
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/AbstractNarMojo.java31
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/AbstractUnpackMojo.java51
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarDownloadMojo.java27
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java32
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarTestDownloadMojo.java59
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java26
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarTestUnpackMojo.java60
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java27
9 files changed, 295 insertions, 78 deletions
diff --git a/src/main/java/org/apache/maven/plugin/nar/AbstractDownloadMojo.java b/src/main/java/org/apache/maven/plugin/nar/AbstractDownloadMojo.java
new file mode 100644
index 0000000..5315939
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugin/nar/AbstractDownloadMojo.java
@@ -0,0 +1,60 @@
+package org.apache.maven.plugin.nar;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * Downloads any dependent NAR files. This includes the noarch and aol type NAR files.
+ */
+public abstract class AbstractDownloadMojo
+ extends AbstractDependencyMojo
+{
+
+ /**
+ * Artifact resolver, needed to download the attached nar files.
+ *
+ * @component role="org.apache.maven.artifact.resolver.ArtifactResolver"
+ * @required
+ * @readonly
+ */
+ protected ArtifactResolver artifactResolver;
+
+ /**
+ * Remote repositories which will be searched for nar attachments.
+ *
+ * @parameter expression="${project.remoteArtifactRepositories}"
+ * @required
+ * @readonly
+ */
+ protected List remoteArtifactRepositories;
+
+ /**
+ * List of classifiers which you want download. Example ppc-MacOSX-g++, x86-Windows-msvc, i386-Linux-g++.
+ *
+ * @parameter expression=""
+ */
+ protected List classifiers;
+}
diff --git a/src/main/java/org/apache/maven/plugin/nar/AbstractNarMojo.java b/src/main/java/org/apache/maven/plugin/nar/AbstractNarMojo.java
index eb71a9f..f2e7da4 100644
--- a/src/main/java/org/apache/maven/plugin/nar/AbstractNarMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/AbstractNarMojo.java
@@ -95,13 +95,19 @@ public abstract class AbstractNarMojo
/**
* Target directory for Nar file construction. Defaults to "${project.build.directory}/nar" for "nar-compile" goal
- * Defaults to "${project.build.directory}/test-nar" for "nar-testCompile" goal
*
* @parameter expression=""
*/
private File targetDirectory;
/**
+ * Target directory for Nar test construction. Defaults to "${project.build.directory}/test-nar" for "nar-testCompile" goal
+ *
+ * @parameter expression=""
+ */
+ private File testTargetDirectory;
+
+ /**
* Target directory for Nar file unpacking. Defaults to "${targetDirectory}"
*
* @parameter expression=""
@@ -109,6 +115,13 @@ public abstract class AbstractNarMojo
private File unpackDirectory;
/**
+ * Target directory for Nar test unpacking. Defaults to "${testTargetDirectory}"
+ *
+ * @parameter expression=""
+ */
+ private File testUnpackDirectory;
+
+ /**
* Layout to be used for building and unpacking artifacts
*
* @parameter expression="${nar.layout}" default-value="org.apache.maven.plugin.nar.NarLayout21"
@@ -149,11 +162,19 @@ public abstract class AbstractNarMojo
{
targetDirectory = new File( mavenProject.getBuild().getDirectory(), "nar" );
}
+ if ( testTargetDirectory == null )
+ {
+ testTargetDirectory = new File( mavenProject.getBuild().getDirectory(), "test-nar" );
+ }
if ( unpackDirectory == null )
{
unpackDirectory = targetDirectory;
}
+ if ( testUnpackDirectory == null )
+ {
+ testUnpackDirectory = testTargetDirectory;
+ }
}
protected final String getArchitecture()
@@ -191,11 +212,19 @@ public abstract class AbstractNarMojo
{
return targetDirectory;
}
+ protected final File getTestTargetDirectory()
+ {
+ return testTargetDirectory;
+ }
protected final File getUnpackDirectory()
{
return unpackDirectory;
}
+ protected final File getTestUnpackDirectory()
+ {
+ return testUnpackDirectory;
+ }
protected final NarLayout getLayout()
throws MojoExecutionException
diff --git a/src/main/java/org/apache/maven/plugin/nar/AbstractUnpackMojo.java b/src/main/java/org/apache/maven/plugin/nar/AbstractUnpackMojo.java
new file mode 100644
index 0000000..9a201ed
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugin/nar/AbstractUnpackMojo.java
@@ -0,0 +1,51 @@
+package org.apache.maven.plugin.nar;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
+
+/**
+ * Unpacks NAR files. Unpacking happens in the local repository, and also sets flags on binaries and corrects static
+ * libraries.
+ */
+public abstract class AbstractUnpackMojo
+ extends AbstractCompileMojo
+{
+
+ /**
+ * List of classifiers which you want unpack. Example ppc-MacOSX-g++, x86-Windows-msvc, i386-Linux-g++.
+ *
+ * @parameter expression=""
+ */
+ protected List classifiers;
+
+ /**
+ * To look up Archiver/UnArchiver implementations
+ *
+ * @component role="org.codehaus.plexus.archiver.manager.ArchiverManager"
+ * @required
+ */
+ protected ArchiverManager archiverManager;
+}
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarDownloadMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarDownloadMojo.java
index fa83de7..8992665 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarDownloadMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarDownloadMojo.java
@@ -36,34 +36,9 @@ import org.apache.maven.plugin.MojoFailureException;
* @author Mark Donszelmann
*/
public class NarDownloadMojo
- extends AbstractDependencyMojo
+ extends AbstractDownloadMojo
{
- /**
- * Artifact resolver, needed to download the attached nar files.
- *
- * @component role="org.apache.maven.artifact.resolver.ArtifactResolver"
- * @required
- * @readonly
- */
- private ArtifactResolver artifactResolver;
-
- /**
- * Remote repositories which will be searched for nar attachments.
- *
- * @parameter expression="${project.remoteArtifactRepositories}"
- * @required
- * @readonly
- */
- private List remoteArtifactRepositories;
-
- /**
- * List of classifiers which you want download. Example ppc-MacOSX-g++, x86-Windows-msvc, i386-Linux-g++.
- *
- * @parameter expression=""
- */
- private List classifiers;
-
public final void narExecute()
throws MojoExecutionException, MojoFailureException
{
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 266adfc..259484b 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java
@@ -144,10 +144,18 @@ public class NarTestCompileMojo
for ( Iterator i = getNarManager().getNarDependencies( "test" ).iterator(); i.hasNext(); )
{
Artifact artifact = (Artifact) i.next();
- File include =
+
+ // check if it exists in the normal unpack directory
+ File include =
getLayout().getIncludeDirectory( getUnpackDirectory(), artifact.getArtifactId(), artifact.getVersion() );
- if ( include.exists() )
+ if ( !include.exists() )
{
+ // otherwise try the test unpack directory
+ include =
+ getLayout().getIncludeDirectory( getTestUnpackDirectory(), artifact.getArtifactId(), artifact.getVersion() );
+ }
+ if ( include.exists() )
+ {
task.createIncludePath().setPath( include.getPath() );
}
}
@@ -248,13 +256,20 @@ public class NarTestCompileMojo
if ( !binding.equals( Library.JNI ) && !binding.equals( Library.NONE ) )
{
- File unpackDirectory = getUnpackDirectory();
-
+ // check if it exists in the normal unpack directory
File dir =
- getLayout().getLibDirectory( unpackDirectory, dependency.getArtifactId(),
+ getLayout().getLibDirectory( getUnpackDirectory(), dependency.getArtifactId(),
dependency.getVersion(), aol.toString(), binding );
-
getLog().debug( "Looking for Library Directory: " + dir );
+ if ( !dir.exists() )
+ {
+ getLog().debug( "Library Directory " + dir + " does NOT exist." );
+
+ // otherwise try the test unpack directory
+ dir = getLayout().getLibDirectory( getTestUnpackDirectory(), dependency.getArtifactId(),
+ dependency.getVersion(), aol.toString(), binding );
+ getLog().debug( "Looking for Library Directory: " + dir );
+ }
if ( dir.exists() )
{
LibrarySet libSet = new LibrarySet();
@@ -312,9 +327,4 @@ public class NarTestCompileMojo
}
}
- protected final File getTestTargetDirectory()
- {
- return new File( getMavenProject().getBuild().getDirectory(), "test-nar" );
- }
-
}
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarTestDownloadMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarTestDownloadMojo.java
new file mode 100644
index 0000000..988bc88
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugin/nar/NarTestDownloadMojo.java
@@ -0,0 +1,59 @@
+package org.apache.maven.plugin.nar;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * Downloads any dependent NAR files. This includes the noarch and aol type NAR files.
+ *
+ * @goal nar-testDownload
+ * @phase generate-test-sources
+ * @requiresProject
+ * @requiresDependencyResolution test
+ * @author Mark Donszelmann
+ */
+public class NarTestDownloadMojo
+ extends AbstractDownloadMojo
+{
+
+ public final void narExecute()
+ throws MojoExecutionException, MojoFailureException
+ {
+ List narArtifacts = getNarManager().getNarDependencies( "test" );
+ if ( classifiers == null )
+ {
+ getNarManager().downloadAttachedNars( narArtifacts, remoteArtifactRepositories, artifactResolver, null );
+ }
+ else
+ {
+ for ( Iterator j = classifiers.iterator(); j.hasNext(); )
+ {
+ getNarManager().downloadAttachedNars( narArtifacts, remoteArtifactRepositories, artifactResolver,
+ (String) j.next() );
+ }
+ }
+ }
+}
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java
index bf5fc1b..e2cca51 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java
@@ -74,22 +74,23 @@ public class NarTestMojo
if ( test.shouldRun() )
{
// NOTE should we use layout here ?
- String extension = getOS().equals( OS.WINDOWS ) ? ".exe" : "";
- String name =
- getTestTargetDirectory().getPath() + File.separator + "bin" + File.separator + getAOL()
- + File.separator + test.getName() + extension;
- if ( !new File( name ).exists() )
+ String name = test.getName() + (getOS().equals( OS.WINDOWS ) ? ".exe" : "");
+ File path = new File( getTestTargetDirectory(), "bin" );
+ path = new File( path, getAOL().toString() );
+ path = new File( path, name );
+ if ( !path.exists() )
{
- getLog().warn( "Skipping non-existing test " + name );
+ getLog().warn( "Skipping non-existing test " + path );
return;
}
- getLog().info( "Running test " + name );
+
+ File workingDir = new File( getTestTargetDirectory(), "test-reports" );
+ workingDir.mkdirs();
+ getLog().info( "Running test " + name + " in " + workingDir );
- File workingDir = getMavenProject().getBasedir();
- getLog().info( " in " + workingDir );
List args = test.getArgs();
int result =
- NarUtil.runCommand( name, (String[]) args.toArray( new String[args.size()] ), workingDir,
+ NarUtil.runCommand( path.toString(), (String[]) args.toArray( new String[args.size()] ), workingDir,
generateEnvironment(), getLog() );
if ( result != 0 )
{
@@ -129,11 +130,6 @@ public class NarTestMojo
}
}
- protected final File getTestTargetDirectory()
- {
- return new File( getMavenProject().getBuild().getDirectory(), "test-nar" );
- }
-
private String[] generateEnvironment()
throws MojoExecutionException, MojoFailureException
{
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarTestUnpackMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarTestUnpackMojo.java
new file mode 100644
index 0000000..b74ece1
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugin/nar/NarTestUnpackMojo.java
@@ -0,0 +1,60 @@
+package org.apache.maven.plugin.nar;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
+
+/**
+ * Unpacks NAR files. Unpacking happens in the local repository, and also sets flags on binaries and corrects static
+ * libraries.
+ *
+ * @goal nar-testUnpack
+ * @phase process-test-sources
+ * @requiresProject
+ * @requiresDependencyResolution test
+ * @author Mark Donszelmann
+ */
+public class NarTestUnpackMojo
+ extends AbstractUnpackMojo
+{
+
+ public final void narExecute()
+ throws MojoExecutionException, MojoFailureException
+ {
+ NarManager mgr = getNarManager();
+ List narArtifacts = mgr.getNarDependencies( "test" );
+ if ( classifiers == null )
+ {
+ mgr.unpackAttachedNars( narArtifacts, archiverManager, null, getOS(), getLayout(), getTestUnpackDirectory() );
+ }
+ else
+ {
+ for ( Iterator j = classifiers.iterator(); j.hasNext(); )
+ {
+ mgr.unpackAttachedNars( narArtifacts, archiverManager, (String) j.next(), getOS(), getLayout(), getTestUnpackDirectory() );
+ }
+ }
+ }
+}
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java
index f94b49f..b3e2be7 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java
@@ -33,40 +33,17 @@ import org.codehaus.plexus.archiver.manager.ArchiverManager;
* @goal nar-unpack
* @phase process-sources
* @requiresProject
- * @requiresDependencyResolution test
+ * @requiresDependencyResolution
* @author Mark Donszelmann
*/
public class NarUnpackMojo
- extends AbstractCompileMojo
+ extends AbstractUnpackMojo
{
- /**
- * List of classifiers which you want unpack. Example ppc-MacOSX-g++, x86-Windows-msvc, i386-Linux-g++.
- *
- * @parameter expression=""
- */
- private List classifiers;
-
- /**
- * To look up Archiver/UnArchiver implementations
- *
- * @component role="org.codehaus.plexus.archiver.manager.ArchiverManager"
- * @required
- */
- private ArchiverManager archiverManager;
-
public final void narExecute()
throws MojoExecutionException, MojoFailureException
{
List narArtifacts = getNarManager().getNarDependencies( "compile" );
- unpackNars(narArtifacts);
- List testNarArtifacts = getNarManager().getNarDependencies( "test" );
- unpackNars(testNarArtifacts);
- }
-
- private void unpackNars(List narArtifacts)
- throws MojoExecutionException, MojoFailureException
- {
if ( classifiers == null )
{
getNarManager().unpackAttachedNars( narArtifacts, archiverManager, null, getOS(), getLayout(), getUnpackDirectory() );