summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorMark Donszelmann <Mark.Donszelmann@gmail.com>2009-11-09 12:03:32 +0100
committerMark Donszelmann <Mark.Donszelmann@gmail.com>2009-11-09 12:03:32 +0100
commite8aea7ca9dc041ef30c3ad44bf4cc040b830f8f0 (patch)
treec550be5f4415b3bac366b469fcc9747f6e950e97 /src/main
parent774b54b45b3d7c5d6246150053d4b176c72f169c (diff)
downloadmaven-nar-plugin-e8aea7ca9dc041ef30c3ad44bf4cc040b830f8f0.tar.gz
maven-nar-plugin-e8aea7ca9dc041ef30c3ad44bf4cc040b830f8f0.tar.bz2
maven-nar-plugin-e8aea7ca9dc041ef30c3ad44bf4cc040b830f8f0.tar.xz
maven-nar-plugin-e8aea7ca9dc041ef30c3ad44bf4cc040b830f8f0.zip
Updated doc; Fixed problem with executable ending up in wrong dorectory, NAR-90
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java6
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java10
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarLayout.java10
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarLayout20.java6
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarLayout21.java69
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java4
6 files changed, 66 insertions, 39 deletions
diff --git a/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java b/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java
index 9e23d42..b41714c 100644
--- a/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java
@@ -73,7 +73,7 @@ public abstract class AbstractResourcesMojo
private ArchiverManager archiverManager;
protected int copyIncludes( File srcDir )
- throws IOException, MojoExecutionException
+ throws IOException, MojoExecutionException, MojoFailureException
{
int copied = 0;
@@ -90,7 +90,7 @@ public abstract class AbstractResourcesMojo
}
protected int copyBinaries( File srcDir, String aol )
- throws IOException, MojoExecutionException
+ throws IOException, MojoExecutionException, MojoFailureException
{
int copied = 0;
@@ -98,7 +98,7 @@ public abstract class AbstractResourcesMojo
File binDir = new File( srcDir, resourceBinDir );
if ( binDir.exists() )
{
- File binDstDir = getLayout().getLibDirectory( getTargetDirectory(), aol, Library.EXECUTABLE );
+ File binDstDir = getLayout().getBinDirectory( getTargetDirectory(), aol );
getLog().debug( "Copying binaries from " + binDir + " to " + binDstDir );
copied += NarUtil.copyDirectoryStructure( binDir, binDstDir, null, NarUtil.DEFAULT_EXCLUDES );
}
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 88f7267..8664d96 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java
@@ -138,7 +138,15 @@ public class NarCompileMojo
task.setLinkFortran( library.linkFortran() );
// outDir
- File outDir = getLayout().getLibDirectory( getTargetDirectory(), getAOL().toString(), type );
+ File outDir;
+ if ( type.equals( Library.EXECUTABLE ) )
+ {
+ outDir = getLayout().getBinDirectory( getTargetDirectory(), getAOL().toString() );
+ }
+ else
+ {
+ outDir = getLayout().getLibDirectory( getTargetDirectory(), getAOL().toString(), type );
+ }
outDir.mkdirs();
// outFile
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarLayout.java b/src/main/java/org/apache/maven/plugin/nar/NarLayout.java
index a264ea2..56ad6f5 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarLayout.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout.java
@@ -3,6 +3,7 @@ package org.apache.maven.plugin.nar;
import java.io.File;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
@@ -38,27 +39,28 @@ public interface NarLayout
* Specifies where libraries are stored
*
* @return
+ * @throws MojoExecutionException, MojoFailureException
*/
- public File getLibDirectory( File baseDir, String aol, String type );
+ public File getLibDirectory( File baseDir, String aol, String type ) throws MojoExecutionException, MojoFailureException;
/**
* Specifies where includes are stored
*
* @return
*/
- public File getIncludeDirectory( File targetDirectory );
+ public File getIncludeDirectory( File targetDirectory ) throws MojoExecutionException, MojoFailureException;
/**
* Specifies where binaries are stored
*
* @return
*/
- public File getBinDirectory( File baseDir, String aol );
+ public File getBinDirectory( File baseDir, String aol ) throws MojoExecutionException, MojoFailureException;
/**
* Called to attach nars to main jar file. This method needs to produce all the attached nar files and set NarInfo
* accordingly.
*/
public void attachNars( File baseDir, MavenProjectHelper projectHelper, MavenProject project, NarInfo narInfo )
- throws MojoExecutionException;
+ throws MojoExecutionException, MojoFailureException;
}
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java b/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java
index c49ac2c..79e3e20 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java
@@ -102,6 +102,7 @@ public class NarLayout20
+ "/**" );
narInfo.setNar( null, Library.EXECUTABLE, project.getGroupId() + ":" + project.getArtifactId() + ":"
+ NarConstants.NAR_TYPE + ":" + "${aol}" + "-" + Library.EXECUTABLE );
+ narInfo.setBinding( new AOL(binAOL[i]), Library.EXECUTABLE );
}
File libDir = new File( baseDir, "lib" );
@@ -124,9 +125,10 @@ public class NarLayout20
}
}
- if ( narInfo.getBinding( null, null ) == null )
+ AOL aol = new AOL(libAOL[i]);
+ if ( narInfo.getBinding( aol, null ) == null )
{
- narInfo.setBinding( null, bindingType != null ? bindingType : Library.NONE );
+ narInfo.setBinding( aol, bindingType != null ? bindingType : Library.NONE );
}
}
}
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java b/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java
index 61c3a19..34bcd06 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java
@@ -71,11 +71,12 @@ public class NarLayout21
* java.lang.String)
*/
public File getLibDirectory( File baseDir, String aol, String type )
+ throws MojoExecutionException
{
if ( type.equals( Library.EXECUTABLE ) )
{
- System.err.println( "WARNING, Replace call to getLibDirectory with getBinDirectory" );
- Thread.dumpStack();
+ throw new MojoExecutionException(
+ "NAR: for type EXECUTABLE call getBinDirectory instead of getLibDirectory" );
}
File dir = getAolDirectory( baseDir, aol, type );
@@ -106,13 +107,13 @@ public class NarLayout21
public void attachNars( File baseDir, MavenProjectHelper projectHelper, MavenProject project, NarInfo narInfo )
throws MojoExecutionException
{
- if (getNoarchDirectory( baseDir ).exists()) {
- attachNar( projectHelper, project, "noarch", getNoarchDirectory( baseDir ), "*/**" );
- narInfo.setNar( null, "noarch", project.getGroupId() + ":" + project.getArtifactId() + ":"
- + NarConstants.NAR_TYPE + ":" + "noarch" );
+ if ( getNoarchDirectory( baseDir ).exists() )
+ {
+ attachNar( projectHelper, project, "noarch", getNoarchDirectory( baseDir ), "*/**" );
+ narInfo.setNar( null, "noarch", project.getGroupId() + ":" + project.getArtifactId() + ":"
+ + NarConstants.NAR_TYPE + ":" + "noarch" );
}
-
- String bindingType = null;
+
File classifierDir = getAolDirectory( baseDir );
String[] classifier = classifierDir.list();
for ( int i = 0; ( classifier != null ) && ( i < classifier.length ); i++ )
@@ -120,37 +121,51 @@ public class NarLayout21
File dir = new File( classifierDir, classifier[i] );
attachNar( projectHelper, project, classifier[i], dir, "*/**" );
- // look for type in aol/lib/<aol>/type
- String type = Library.EXECUTABLE;
- File libDir = new File( dir, "lib" );
- String[] aolDir = libDir.list();
+ String type = null;
+ AOL aol = null;
+
+ File binDir = new File( dir, "bin" );
+ String[] aolDir = binDir.list();
if ( ( aolDir != null ) && aolDir.length > 0 )
{
- String[] typeDir = new File( libDir, aolDir[0] ).list();
- if ( ( typeDir != null ) && ( typeDir.length > 0 ) )
+ type = Library.EXECUTABLE;
+ aol = new AOL(aolDir[0]);
+
+ if ( narInfo.getBinding( aol, null ) == null )
{
- type = typeDir[0];
+ narInfo.setBinding( aol, Library.EXECUTABLE );
}
}
-
- narInfo.setNar( null, type, project.getGroupId() + ":" + project.getArtifactId() + ":"
- + NarConstants.NAR_TYPE + ":" + "${aol}" + "-" + type );
-
- // set if not Executable
- if ( !type.equals( Library.EXECUTABLE ) )
+ else
{
+ // look for type in aol/<aol-type>/lib/<aol>/<type>
+ File libDir = new File( dir, "lib" );
+ aolDir = libDir.list();
+ if ( ( aolDir != null ) && aolDir.length > 0 )
+ {
+ aol = new AOL(aolDir[0]);
+ String[] typeDir = new File( libDir, aol.toString() ).list();
+ if ( ( typeDir != null ) && ( typeDir.length > 0 ) )
+ {
+ type = typeDir[0];
+ }
+ }
+
+ assert(aol != null);
+ assert(type != null);
+
// and not set or override if SHARED
- if ( ( bindingType == null ) || type.equals( Library.SHARED ) )
+ if (( narInfo.getBinding( aol, null ) == null ) || type.equals( Library.SHARED ) )
{
- bindingType = type;
+ narInfo.setBinding( aol, type );
}
}
+
+ assert(type != null);
+ narInfo.setNar( null, type, project.getGroupId() + ":" + project.getArtifactId() + ":"
+ + NarConstants.NAR_TYPE + ":" + "${aol}" + "-" + type );
}
- if ( narInfo.getBinding( null, null ) == null )
- {
- narInfo.setBinding( null, bindingType != null ? bindingType : Library.NONE );
- }
}
}
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 215771d..79c7a24 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java
@@ -100,8 +100,8 @@ public class NarTestMojo
MavenProject project = getMavenProject();
// FIXME NAR-90, we could make dure we get the final name from layout
File executable =
- new File( getLayout().getLibDirectory( super.getTargetDirectory(), getAOL().toString(),
- library.getType() ), project.getArtifactId() );
+ new File( getLayout().getBinDirectory( super.getTargetDirectory(), getAOL().toString() ),
+ project.getArtifactId() );
getLog().info( "Running executable " + executable );
List args = library.getArgs();
int result =