summaryrefslogtreecommitdiff
path: root/src/main/java/org/apache/maven/plugin/nar/NarManager.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/NarManager.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/NarManager.java')
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarManager.java675
1 files changed, 365 insertions, 310 deletions
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarManager.java b/src/main/java/org/apache/maven/plugin/nar/NarManager.java
index 1e75117..087bdee 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarManager.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarManager.java
@@ -48,337 +48,392 @@ import org.codehaus.plexus.util.FileUtils;
/**
* @author Mark Donszelmann (Mark.Donszelmann@gmail.com)
*/
-public class NarManager {
+public class NarManager
+{
- private Log log;
+ private Log log;
- private MavenProject project;
+ private MavenProject project;
- private ArtifactRepository repository;
+ private ArtifactRepository repository;
- private AOL defaultAOL;
- private String linkerName;
-
- private String[] narTypes = { "noarch", Library.STATIC, Library.SHARED, Library.JNI, Library.PLUGIN };
+ private AOL defaultAOL;
- public NarManager(Log log, ArtifactRepository repository,
- MavenProject project, String architecture, String os, Linker linker)
- throws MojoFailureException {
- this.log = log;
- this.repository = repository;
- this.project = project;
- this.defaultAOL = NarUtil.getAOL(architecture, os, linker, null);
- this.linkerName = NarUtil.getLinkerName(architecture, os, linker);
- }
+ private String linkerName;
- /**
- * Returns dependencies which are dependent on NAR files (i.e. contain
- * NarInfo)
- */
- public List/* <NarArtifact> */getNarDependencies(String scope)
- throws MojoExecutionException {
- List narDependencies = new LinkedList();
- for (Iterator i = getDependencies(scope).iterator(); i.hasNext();) {
- Artifact dependency = (Artifact) i.next();
- log.debug("Examining artifact for NarInfo: "+dependency);
-
- NarInfo narInfo = getNarInfo(dependency);
- if (narInfo != null) {
- log.debug(" - added as NarDependency");
- narDependencies.add(new NarArtifact(dependency, narInfo));
- }
- }
- return narDependencies;
- }
+ private String[] narTypes = { "noarch", Library.STATIC, Library.SHARED, Library.JNI, Library.PLUGIN };
- /**
- * Returns all NAR dependencies by type: noarch, static, dynamic, jni,
- * plugin.
- *
- * @throws MojoFailureException
- */
- public Map/* <String, List<AttachedNarArtifact>> */getAttachedNarDependencyMap(
- String scope) throws MojoExecutionException, MojoFailureException {
- Map attachedNarDependencies = new HashMap();
- for (Iterator i = getNarDependencies(scope).iterator(); i.hasNext();) {
- Artifact dependency = (Artifact) i.next();
- for (int j = 0; j < narTypes.length; j++) {
- List artifactList = getAttachedNarDependencies(dependency,
- defaultAOL, narTypes[j]);
- if (artifactList != null)
- attachedNarDependencies.put(narTypes[j], artifactList);
- }
- }
- return attachedNarDependencies;
- }
+ public NarManager( Log log, ArtifactRepository repository, MavenProject project, String architecture, String os,
+ Linker linker )
+ throws MojoFailureException
+ {
+ this.log = log;
+ this.repository = repository;
+ this.project = project;
+ this.defaultAOL = NarUtil.getAOL( architecture, os, linker, null );
+ this.linkerName = NarUtil.getLinkerName( architecture, os, linker );
+ }
- public List/* <AttachedNarArtifact> */getAttachedNarDependencies(
- List/* <NarArtifacts> */narArtifacts)
- throws MojoExecutionException, MojoFailureException {
- return getAttachedNarDependencies(narArtifacts, null);
- }
+ /**
+ * Returns dependencies which are dependent on NAR files (i.e. contain NarInfo)
+ */
+ public List/* <NarArtifact> */getNarDependencies( String scope )
+ throws MojoExecutionException
+ {
+ List narDependencies = new LinkedList();
+ for ( Iterator i = getDependencies( scope ).iterator(); i.hasNext(); )
+ {
+ Artifact dependency = (Artifact) i.next();
+ log.debug( "Examining artifact for NarInfo: " + dependency );
- public List/* <AttachedNarArtifact> */getAttachedNarDependencies(
- List/* <NarArtifacts> */narArtifacts, String classifier)
- throws MojoExecutionException, MojoFailureException {
- AOL aol = null;
- String type = null;
- if (classifier != null) {
- int dash = classifier.lastIndexOf('-');
- if (dash < 0) {
- aol = new AOL(classifier);
- type = null;
- } else {
- aol = new AOL(classifier.substring(0, dash));
- type = classifier.substring(dash + 1);
- }
- }
- return getAttachedNarDependencies(narArtifacts, aol, type);
- }
+ NarInfo narInfo = getNarInfo( dependency );
+ if ( narInfo != null )
+ {
+ log.debug( " - added as NarDependency" );
+ narDependencies.add( new NarArtifact( dependency, narInfo ) );
+ }
+ }
+ return narDependencies;
+ }
- /**
- * Returns a list of all attached nar dependencies for a specific binding
- * and "noarch", but not where "local" is specified
- *
- * @param scope
- * compile, test, runtime, ....
- * @param aol
- * either a valid aol, noarch or null. In case of null both the
- * default getAOL() and noarch dependencies are returned.
- * @param type
- * noarch, static, shared, jni, or null. In case of null the
- * default binding found in narInfo is used.
- * @return
- * @throws MojoExecutionException
- * @throws MojoFailureException
- */
- public List/* <AttachedNarArtifact> */getAttachedNarDependencies(
- List/* <NarArtifacts> */narArtifacts, AOL aol, String type)
- throws MojoExecutionException, MojoFailureException {
- boolean noarch = false;
- if (aol == null) {
- noarch = true;
- aol = defaultAOL;
- }
+ /**
+ * Returns all NAR dependencies by type: noarch, static, dynamic, jni, plugin.
+ *
+ * @throws MojoFailureException
+ */
+ public Map/* <String, List<AttachedNarArtifact>> */getAttachedNarDependencyMap( String scope )
+ throws MojoExecutionException, MojoFailureException
+ {
+ Map attachedNarDependencies = new HashMap();
+ for ( Iterator i = getNarDependencies( scope ).iterator(); i.hasNext(); )
+ {
+ Artifact dependency = (Artifact) i.next();
+ for ( int j = 0; j < narTypes.length; j++ )
+ {
+ List artifactList = getAttachedNarDependencies( dependency, defaultAOL, narTypes[j] );
+ if ( artifactList != null )
+ attachedNarDependencies.put( narTypes[j], artifactList );
+ }
+ }
+ return attachedNarDependencies;
+ }
- List artifactList = new ArrayList();
- for (Iterator i = narArtifacts.iterator(); i.hasNext();) {
- Artifact dependency = (Artifact) i.next();
- NarInfo narInfo = getNarInfo(dependency);
- if (noarch) {
- artifactList.addAll(getAttachedNarDependencies(dependency,
- null, "noarch"));
- }
+ public List/* <AttachedNarArtifact> */getAttachedNarDependencies( List/* <NarArtifacts> */narArtifacts )
+ throws MojoExecutionException, MojoFailureException
+ {
+ return getAttachedNarDependencies( narArtifacts, null );
+ }
- // use preferred binding, unless non existing.
- String binding = narInfo.getBinding(aol, type != null ? type
- : "static");
+ public List/* <AttachedNarArtifact> */getAttachedNarDependencies( List/* <NarArtifacts> */narArtifacts,
+ String classifier )
+ throws MojoExecutionException, MojoFailureException
+ {
+ AOL aol = null;
+ String type = null;
+ if ( classifier != null )
+ {
+ int dash = classifier.lastIndexOf( '-' );
+ if ( dash < 0 )
+ {
+ aol = new AOL( classifier );
+ type = null;
+ }
+ else
+ {
+ aol = new AOL( classifier.substring( 0, dash ) );
+ type = classifier.substring( dash + 1 );
+ }
+ }
+ return getAttachedNarDependencies( narArtifacts, aol, type );
+ }
- // FIXME kludge, but does not work anymore since AOL is now a class
- if (aol.equals("noarch")) {
- // FIXME no handling of local
- artifactList.addAll(getAttachedNarDependencies(dependency,
- null, "noarch"));
- } else {
- artifactList.addAll(getAttachedNarDependencies(dependency, aol,
- binding));
- }
- }
- return artifactList;
- }
+ /**
+ * Returns a list of all attached nar dependencies for a specific binding and "noarch", but not where "local" is
+ * specified
+ *
+ * @param scope compile, test, runtime, ....
+ * @param aol either a valid aol, noarch or null. In case of null both the default getAOL() and noarch dependencies
+ * are returned.
+ * @param type noarch, static, shared, jni, or null. In case of null the default binding found in narInfo is used.
+ * @return
+ * @throws MojoExecutionException
+ * @throws MojoFailureException
+ */
+ public List/* <AttachedNarArtifact> */getAttachedNarDependencies( List/* <NarArtifacts> */narArtifacts, AOL aol,
+ String type )
+ throws MojoExecutionException, MojoFailureException
+ {
+ boolean noarch = false;
+ if ( aol == null )
+ {
+ noarch = true;
+ aol = defaultAOL;
+ }
- private List/* <AttachedNarArtifact> */getAttachedNarDependencies(
- Artifact dependency, AOL aol, String type)
- throws MojoExecutionException, MojoFailureException {
- log.debug("GetNarDependencies for " + dependency + ", aol: " + aol + ", type: " + type);
- List artifactList = new ArrayList();
- NarInfo narInfo = getNarInfo(dependency);
- String[] nars = narInfo.getAttachedNars(aol, type);
- // FIXME Move this to NarInfo....
- if (nars != null) {
- for (int j = 0; j < nars.length; j++) {
- log.debug(" Checking: " + nars[j]);
- if (nars[j].equals(""))
- continue;
- String[] nar = nars[j].split(":", 5);
- if (nar.length >= 4) {
- try {
- String groupId = nar[0].trim();
- String artifactId = nar[1].trim();
- String ext = nar[2].trim();
- String classifier = nar[3].trim();
- // translate for instance g++ to gcc...
- aol = narInfo.getAOL(aol);
- if (aol != null) {
- classifier = NarUtil.replace("${aol}", aol.toString(),
- classifier);
- }
- String version = nar.length >= 5 ? nar[4].trim()
- : dependency.getVersion();
- artifactList.add(new AttachedNarArtifact(groupId,
- artifactId, version, dependency.getScope(),
- ext, classifier, dependency.isOptional()));
- } catch (InvalidVersionSpecificationException e) {
- throw new MojoExecutionException(
- "Error while reading nar file for dependency "
- + dependency, e);
- }
- } else {
- log.warn("nars property in " + dependency.getArtifactId()
- + " contains invalid field: '" + nars[j]
- + "' for type: " + type);
- }
- }
- }
- return artifactList;
- }
+ List artifactList = new ArrayList();
+ for ( Iterator i = narArtifacts.iterator(); i.hasNext(); )
+ {
+ Artifact dependency = (Artifact) i.next();
+ NarInfo narInfo = getNarInfo( dependency );
+ if ( noarch )
+ {
+ artifactList.addAll( getAttachedNarDependencies( dependency, null, "noarch" ) );
+ }
- public NarInfo getNarInfo(Artifact dependency)
- throws MojoExecutionException {
- // FIXME reported to maven developer list, isSnapshot changes behaviour
- // of getBaseVersion, called in pathOf.
- if (dependency.isSnapshot())
- ;
+ // use preferred binding, unless non existing.
+ String binding = narInfo.getBinding( aol, type != null ? type : "static" );
- File file = new File(repository.getBasedir(), repository
- .pathOf(dependency));
- JarFile jar = null;
- try {
- jar = new JarFile(file);
- NarInfo info = new NarInfo(dependency.getGroupId(), dependency
- .getArtifactId(), dependency.getVersion(), log);
- if (!info.exists(jar))
- return null;
- info.read(jar);
- return info;
- } catch (IOException e) {
- throw new MojoExecutionException("Error while reading " + file, e);
- } finally {
- if (jar != null) {
- try {
- jar.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
- }
+ // FIXME kludge, but does not work anymore since AOL is now a class
+ if ( aol.equals( "noarch" ) )
+ {
+ // FIXME no handling of local
+ artifactList.addAll( getAttachedNarDependencies( dependency, null, "noarch" ) );
+ }
+ else
+ {
+ artifactList.addAll( getAttachedNarDependencies( dependency, aol, binding ) );
+ }
+ }
+ return artifactList;
+ }
- public File getNarFile(Artifact dependency) throws MojoFailureException {
- // FIXME reported to maven developer list, isSnapshot changes behaviour
- // of getBaseVersion, called in pathOf.
- if (dependency.isSnapshot())
- ;
- return new File(repository.getBasedir(), NarUtil.replace("${aol}",
- defaultAOL.toString(), repository.pathOf(dependency)));
- }
+ private List/* <AttachedNarArtifact> */getAttachedNarDependencies( Artifact dependency, AOL aol, String type )
+ throws MojoExecutionException, MojoFailureException
+ {
+ log.debug( "GetNarDependencies for " + dependency + ", aol: " + aol + ", type: " + type );
+ List artifactList = new ArrayList();
+ NarInfo narInfo = getNarInfo( dependency );
+ String[] nars = narInfo.getAttachedNars( aol, type );
+ // FIXME Move this to NarInfo....
+ if ( nars != null )
+ {
+ for ( int j = 0; j < nars.length; j++ )
+ {
+ log.debug( " Checking: " + nars[j] );
+ if ( nars[j].equals( "" ) )
+ continue;
+ String[] nar = nars[j].split( ":", 5 );
+ if ( nar.length >= 4 )
+ {
+ try
+ {
+ String groupId = nar[0].trim();
+ String artifactId = nar[1].trim();
+ String ext = nar[2].trim();
+ String classifier = nar[3].trim();
+ // translate for instance g++ to gcc...
+ aol = narInfo.getAOL( aol );
+ if ( aol != null )
+ {
+ classifier = NarUtil.replace( "${aol}", aol.toString(), classifier );
+ }
+ String version = nar.length >= 5 ? nar[4].trim() : dependency.getVersion();
+ artifactList.add( new AttachedNarArtifact( groupId, artifactId, version, dependency.getScope(),
+ ext, classifier, dependency.isOptional() ) );
+ }
+ catch ( InvalidVersionSpecificationException e )
+ {
+ throw new MojoExecutionException( "Error while reading nar file for dependency " + dependency,
+ e );
+ }
+ }
+ else
+ {
+ log.warn( "nars property in " + dependency.getArtifactId() + " contains invalid field: '" + nars[j]
+ + "' for type: " + type );
+ }
+ }
+ }
+ return artifactList;
+ }
- private List getDependencies(String scope) {
- if (scope.equals("test")) {
- return project.getTestArtifacts();
- } else if (scope.equals("runtime")) {
- return project.getRuntimeArtifacts();
- }
- return project.getCompileArtifacts();
- }
+ public NarInfo getNarInfo( Artifact dependency )
+ throws MojoExecutionException
+ {
+ // FIXME reported to maven developer list, isSnapshot changes behaviour
+ // of getBaseVersion, called in pathOf.
+ if ( dependency.isSnapshot() )
+ ;
- public void downloadAttachedNars(List/* <NarArtifacts> */narArtifacts,
- List remoteRepositories, ArtifactResolver resolver,
- String classifier) throws MojoExecutionException,
- MojoFailureException {
- // FIXME this may not be the right way to do this.... -U ignored and
- // also SNAPSHOT not used
- List dependencies = getAttachedNarDependencies(narArtifacts, classifier);
- for (Iterator i = dependencies.iterator(); i.hasNext();) {
- Artifact dependency = (Artifact) i.next();
- try {
- log.debug("Resolving " + dependency);
- resolver.resolve(dependency, remoteRepositories, repository);
- } catch (ArtifactNotFoundException e) {
- String message = "nar not found " + dependency.getId();
- throw new MojoExecutionException(message, e);
- } catch (ArtifactResolutionException e) {
- String message = "nar cannot resolve " + dependency.getId();
- throw new MojoExecutionException(message, e);
- }
- }
- }
+ File file = new File( repository.getBasedir(), repository.pathOf( dependency ) );
+ JarFile jar = null;
+ try
+ {
+ jar = new JarFile( file );
+ NarInfo info =
+ new NarInfo( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), log );
+ if ( !info.exists( jar ) )
+ return null;
+ info.read( jar );
+ return info;
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Error while reading " + file, e );
+ }
+ finally
+ {
+ if ( jar != null )
+ {
+ try
+ {
+ jar.close();
+ }
+ catch ( IOException e )
+ {
+ // ignore
+ }
+ }
+ }
+ }
- public void unpackAttachedNars(List/* <NarArtifacts> */narArtifacts,
- ArchiverManager manager, String classifier, String os)
- throws MojoExecutionException, MojoFailureException {
- log.debug("Unpack called for OS: "+os+", classifier: "+classifier+" for NarArtifacts {");
- for (Iterator i = narArtifacts.iterator(); i.hasNext(); ) {
- log.debug(" - "+((NarArtifact)i.next()));
- }
- log.debug("}");
- // FIXME, kludge to get to download the -noarch, based on classifier
- List dependencies = getAttachedNarDependencies(narArtifacts, classifier);
- for (Iterator i = dependencies.iterator(); i.hasNext();) {
- Artifact dependency = (Artifact) i.next();
- log.debug("Unpack " + dependency);
- File file = getNarFile(dependency);
- File narLocation = new File(file.getParentFile(), "nar");
- File flagFile = new File(narLocation, FileUtils.basename(file
- .getPath(), "." + AbstractNarMojo.NAR_EXTENSION)
- + ".flag");
+ public File getNarFile( Artifact dependency )
+ throws MojoFailureException
+ {
+ // FIXME reported to maven developer list, isSnapshot changes behaviour
+ // of getBaseVersion, called in pathOf.
+ if ( dependency.isSnapshot() )
+ ;
+ return new File( repository.getBasedir(), NarUtil.replace( "${aol}", defaultAOL.toString(),
+ repository.pathOf( dependency ) ) );
+ }
- boolean process = false;
- if (!narLocation.exists()) {
- narLocation.mkdirs();
- process = true;
- } else if (!flagFile.exists()) {
- process = true;
- } else if (file.lastModified() > flagFile.lastModified()) {
- process = true;
- }
+ private List getDependencies( String scope )
+ {
+ if ( scope.equals( "test" ) )
+ {
+ return project.getTestArtifacts();
+ }
+ else if ( scope.equals( "runtime" ) )
+ {
+ return project.getRuntimeArtifacts();
+ }
+ return project.getCompileArtifacts();
+ }
- if (process) {
- try {
- unpackNar(manager, file, narLocation);
- if (!NarUtil.getOS(os).equals("Windows")) {
- NarUtil.makeExecutable(new File(narLocation, "bin/"+defaultAOL),
- log);
- // FIXME clumsy
- if (defaultAOL.hasLinker("g++")) {
- NarUtil.makeExecutable(new File(narLocation, "bin/"+NarUtil.replace("g++", "gcc", defaultAOL.toString())),
- log);
- }
- }
- if (linkerName.equals("gcc") || linkerName.equals("g++")) {
- NarUtil.runRanlib(new File(narLocation, "lib/"+defaultAOL), log);
- // FIXME clumsy
- if (defaultAOL.hasLinker("g++")) {
- NarUtil.runRanlib(new File(narLocation, "lib/"+NarUtil.replace("g++", "gcc", defaultAOL.toString())),
- log);
- }
- }
- FileUtils.fileDelete(flagFile.getPath());
- FileUtils.fileWrite(flagFile.getPath(), "");
- } catch (IOException e) {
- log.warn("Cannot create flag file: " + flagFile.getPath());
- }
- }
- }
- }
+ public void downloadAttachedNars( List/* <NarArtifacts> */narArtifacts, List remoteRepositories,
+ ArtifactResolver resolver, String classifier )
+ throws MojoExecutionException, MojoFailureException
+ {
+ // FIXME this may not be the right way to do this.... -U ignored and
+ // also SNAPSHOT not used
+ List dependencies = getAttachedNarDependencies( narArtifacts, classifier );
+ for ( Iterator i = dependencies.iterator(); i.hasNext(); )
+ {
+ Artifact dependency = (Artifact) i.next();
+ try
+ {
+ log.debug( "Resolving " + dependency );
+ resolver.resolve( dependency, remoteRepositories, repository );
+ }
+ catch ( ArtifactNotFoundException e )
+ {
+ String message = "nar not found " + dependency.getId();
+ throw new MojoExecutionException( message, e );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ String message = "nar cannot resolve " + dependency.getId();
+ throw new MojoExecutionException( message, e );
+ }
+ }
+ }
- private void unpackNar(ArchiverManager manager, File file, File location)
- throws MojoExecutionException {
- try {
- UnArchiver unArchiver;
- unArchiver = manager.getUnArchiver(AbstractNarMojo.NAR_ROLE_HINT);
- unArchiver.setSourceFile(file);
- unArchiver.setDestDirectory(location);
- unArchiver.extract();
- } catch (IOException e) {
- throw new MojoExecutionException("Error unpacking file: " + file
- + " to: " + location, e);
- } catch (NoSuchArchiverException e) {
- throw new MojoExecutionException("Error unpacking file: " + file
- + " to: " + location, e);
- } catch (ArchiverException e) {
- throw new MojoExecutionException("Error unpacking file: " + file
- + " to: " + location, e);
- }
- }
+ public void unpackAttachedNars( List/* <NarArtifacts> */narArtifacts, ArchiverManager manager, String classifier,
+ String os )
+ throws MojoExecutionException, MojoFailureException
+ {
+ log.debug( "Unpack called for OS: " + os + ", classifier: " + classifier + " for NarArtifacts {" );
+ for ( Iterator i = narArtifacts.iterator(); i.hasNext(); )
+ {
+ log.debug( " - " + ( (NarArtifact) i.next() ) );
+ }
+ log.debug( "}" );
+ // FIXME, kludge to get to download the -noarch, based on classifier
+ List dependencies = getAttachedNarDependencies( narArtifacts, classifier );
+ for ( Iterator i = dependencies.iterator(); i.hasNext(); )
+ {
+ Artifact dependency = (Artifact) i.next();
+ log.debug( "Unpack " + dependency );
+ File file = getNarFile( dependency );
+ File narLocation = new File( file.getParentFile(), "nar" );
+ File flagFile =
+ new File( narLocation, FileUtils.basename( file.getPath(), "." + AbstractNarMojo.NAR_EXTENSION )
+ + ".flag" );
+
+ boolean process = false;
+ if ( !narLocation.exists() )
+ {
+ narLocation.mkdirs();
+ process = true;
+ }
+ else if ( !flagFile.exists() )
+ {
+ process = true;
+ }
+ else if ( file.lastModified() > flagFile.lastModified() )
+ {
+ process = true;
+ }
+
+ if ( process )
+ {
+ try
+ {
+ unpackNar( manager, file, narLocation );
+ if ( !NarUtil.getOS( os ).equals( "Windows" ) )
+ {
+ NarUtil.makeExecutable( new File( narLocation, "bin/" + defaultAOL ), log );
+ // FIXME clumsy
+ if ( defaultAOL.hasLinker( "g++" ) )
+ {
+ NarUtil.makeExecutable( new File( narLocation, "bin/"
+ + NarUtil.replace( "g++", "gcc", defaultAOL.toString() ) ), log );
+ }
+ }
+ if ( linkerName.equals( "gcc" ) || linkerName.equals( "g++" ) )
+ {
+ NarUtil.runRanlib( new File( narLocation, "lib/" + defaultAOL ), log );
+ // FIXME clumsy
+ if ( defaultAOL.hasLinker( "g++" ) )
+ {
+ NarUtil.runRanlib( new File( narLocation, "lib/"
+ + NarUtil.replace( "g++", "gcc", defaultAOL.toString() ) ), log );
+ }
+ }
+ FileUtils.fileDelete( flagFile.getPath() );
+ FileUtils.fileWrite( flagFile.getPath(), "" );
+ }
+ catch ( IOException e )
+ {
+ log.warn( "Cannot create flag file: " + flagFile.getPath() );
+ }
+ }
+ }
+ }
+
+ private void unpackNar( ArchiverManager manager, File file, File location )
+ throws MojoExecutionException
+ {
+ try
+ {
+ UnArchiver unArchiver;
+ unArchiver = manager.getUnArchiver( AbstractNarMojo.NAR_ROLE_HINT );
+ unArchiver.setSourceFile( file );
+ unArchiver.setDestDirectory( location );
+ unArchiver.extract();
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Error unpacking file: " + file + " to: " + location, e );
+ }
+ catch ( NoSuchArchiverException e )
+ {
+ throw new MojoExecutionException( "Error unpacking file: " + file + " to: " + location, e );
+ }
+ catch ( ArchiverException e )
+ {
+ throw new MojoExecutionException( "Error unpacking file: " + file + " to: " + location, e );
+ }
+ }
}