summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorMark Donszelmann <Mark.Donszelmann@gmail.com>2009-12-10 09:32:49 +0100
committerMark Donszelmann <Mark.Donszelmann@gmail.com>2009-12-10 09:32:49 +0100
commit8c046e79b56e71bd0a9f3787712963bc2523d8f1 (patch)
treea112eb574ceb04ec65999eb356843c47a019fa4a /src/main
parent8c1687f37f78a768668d7cd0a9caf4e151d0494a (diff)
downloadmaven-nar-plugin-8c046e79b56e71bd0a9f3787712963bc2523d8f1.tar.gz
maven-nar-plugin-8c046e79b56e71bd0a9f3787712963bc2523d8f1.tar.bz2
maven-nar-plugin-8c046e79b56e71bd0a9f3787712963bc2523d8f1.tar.xz
maven-nar-plugin-8c046e79b56e71bd0a9f3787712963bc2523d8f1.zip
Progress on NAR-21
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java48
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java1
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarValidateMojo.java42
3 files changed, 73 insertions, 18 deletions
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 47f6dd4..fe5f7cc 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java
@@ -38,8 +38,11 @@ import net.sf.antcontrib.cpptasks.types.LibrarySet;
import net.sf.antcontrib.cpptasks.types.LinkerArgument;
import net.sf.antcontrib.cpptasks.types.SystemLibrarySet;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.codehaus.plexus.util.FileUtils;
@@ -50,15 +53,60 @@ import org.codehaus.plexus.util.StringUtils;
*
* @goal nar-compile
* @phase compile
+ * @requiresSession
+ * @requiresProject
* @requiresDependencyResolution compile
* @author Mark Donszelmann
*/
public class NarCompileMojo
extends AbstractCompileMojo
{
+ /**
+ * The current build session instance.
+ *
+ * @parameter expression="${session}"
+ * @required
+ * @readonly
+ */
+ private MavenSession session;
+
public final void narExecute()
throws MojoExecutionException, MojoFailureException
{
+ for ( Iterator i = session.getSortedProjects().iterator(); i.hasNext(); )
+ {
+ MavenProject project = (MavenProject) i.next();
+ if ( !project.getPackaging().equals( NarConstants.NAR ) )
+ {
+ continue;
+ }
+ if ( project.isExecutionRoot() )
+ {
+ continue;
+ }
+
+ // is this me ? bail out, the list was sorted
+ MavenProject me = getMavenProject();
+ if ( project.getArtifact().equals( me.getArtifact() ) )
+ {
+ break;
+ }
+
+ // search the dependency list
+ for ( Iterator it = me.getArtifacts().iterator(); it.hasNext(); )
+ {
+ Artifact dependency = (Artifact) it.next();
+ // equals will not work here as the project type is "nar" while the dependencies type is "jar"
+ //
+ if ( dependency.getArtifactId().equals( project.getArtifactId() )
+ && dependency.getGroupId().equals( project.getGroupId() )
+ && dependency.getVersion().equals( project.getVersion() ) && dependency.getType().equals( "jar" ) )
+ {
+ getLog().info( "Added intermodule dependency to " + project.getArtifact()+" in "+project.getBuild().getDirectory() );
+ }
+ }
+ }
+
// make sure destination is there
getTargetDirectory().mkdirs();
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java
index 9edc963..14d69df 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java
@@ -30,6 +30,7 @@ import org.apache.maven.toolchain.ToolchainManager;
*
* @goal nar-javah
* @phase compile
+ * @requiresSession
* @author Mark Donszelmann
*/
public class NarJavahMojo
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarValidateMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarValidateMojo.java
index e299dfb..b303b38 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarValidateMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarValidateMojo.java
@@ -27,7 +27,6 @@ import org.apache.maven.plugin.MojoFailureException;
*
* @goal nar-validate
* @phase validate
- * @requiresProject
* @author Mark Donszelmann
*/
public class NarValidateMojo
@@ -35,45 +34,52 @@ public class NarValidateMojo
{
public final void narExecute()
throws MojoExecutionException, MojoFailureException
- {
+ {
// check aol
- AOL aol = getAOL();
+ AOL aol = getAOL();
getLog().info( "Using AOL: " + aol );
-
+
// check linker exists in retrieving the version number
- Linker linker = getLinker();
- getLog().debug( "Using linker version: "+linker.getVersion());
-
+ Linker linker = getLinker();
+ getLog().debug( "Using linker version: " + linker.getVersion() );
+
// check compilers
int noOfCompilers = 0;
Compiler cpp = getCpp();
- if (cpp.getName() != null) {
+ if ( cpp.getName() != null )
+ {
noOfCompilers++;
// need includes
- if (cpp.getIncludes( Compiler.MAIN ).isEmpty()) {
- throw new MojoExecutionException( "No includes defined for compiler "+cpp.getName() );
+ if ( cpp.getIncludes( Compiler.MAIN ).isEmpty() )
+ {
+ throw new MojoExecutionException( "No includes defined for compiler " + cpp.getName() );
}
}
Compiler c = getC();
- if (c.getName() != null) {
+ if ( c.getName() != null )
+ {
noOfCompilers++;
// need includes
- if (c.getIncludes( Compiler.MAIN ).isEmpty()) {
- throw new MojoExecutionException( "No includes defined for compiler "+c.getName() );
+ if ( c.getIncludes( Compiler.MAIN ).isEmpty() )
+ {
+ throw new MojoExecutionException( "No includes defined for compiler " + c.getName() );
}
}
Compiler fortran = getCpp();
- if (fortran.getName() != null) {
+ if ( fortran.getName() != null )
+ {
noOfCompilers++;
// need includes
- if (fortran.getIncludes( Compiler.MAIN ).isEmpty()) {
- throw new MojoExecutionException( "No includes defined for compiler "+fortran.getName() );
+ if ( fortran.getIncludes( Compiler.MAIN ).isEmpty() )
+ {
+ throw new MojoExecutionException( "No includes defined for compiler " + fortran.getName() );
}
}
// at least one compiler has to be defined
- if (noOfCompilers == 0) {
- throw new MojoExecutionException( "No compilers defined for linker "+linker.getName() );
+ if ( noOfCompilers == 0 )
+ {
+ throw new MojoExecutionException( "No compilers defined for linker " + linker.getName() );
}
}
}