You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by pt...@apache.org on 2008/09/17 13:36:10 UTC
svn commit: r696256 -
/jakarta/cactus/trunk/integration/maven2/src/main/java/org/apache/cactus/maven2/mojos/CactifyEarMojo.java
Author: ptahchiev
Date: Wed Sep 17 04:36:09 2008
New Revision: 696256
URL: http://svn.apache.org/viewvc?rev=696256&view=rev
Log:
Changes made on the CactifyEarMojo.java
Modified:
jakarta/cactus/trunk/integration/maven2/src/main/java/org/apache/cactus/maven2/mojos/CactifyEarMojo.java
Modified: jakarta/cactus/trunk/integration/maven2/src/main/java/org/apache/cactus/maven2/mojos/CactifyEarMojo.java
URL: http://svn.apache.org/viewvc/jakarta/cactus/trunk/integration/maven2/src/main/java/org/apache/cactus/maven2/mojos/CactifyEarMojo.java?rev=696256&r1=696255&r2=696256&view=diff
==============================================================================
--- jakarta/cactus/trunk/integration/maven2/src/main/java/org/apache/cactus/maven2/mojos/CactifyEarMojo.java (original)
+++ jakarta/cactus/trunk/integration/maven2/src/main/java/org/apache/cactus/maven2/mojos/CactifyEarMojo.java Wed Sep 17 04:36:09 2008
@@ -32,6 +32,8 @@
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.assembly.archive.ArchiveExpansionException;
+import org.apache.maven.plugin.assembly.utils.AssemblyFileUtils;
import org.apache.maven.project.MavenProject;
import org.codehaus.cargo.module.application.ApplicationXml;
import org.codehaus.cargo.module.application.ApplicationXmlIo;
@@ -45,6 +47,8 @@
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.ear.EarArchiver;
import org.codehaus.plexus.archiver.jar.ManifestException;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
+import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
import org.codehaus.plexus.archiver.war.WarArchiver;
import org.codehaus.plexus.util.FileUtils;
import org.jdom.JDOMException;
@@ -115,6 +119,12 @@
private MavenProject project;
/**
+ * The archive manager.
+ * @component
+ */
+ private ArchiverManager archiverManager;
+
+ /**
* The "main" method of the mojo.
* @throws MojoExecutionException in case an error occurs.
* @throws MojoFailureException in case a failure occurs.
@@ -125,7 +135,6 @@
{
cactusWar = createCactusWarConfig();
}
-
MavenArchiver archiver = new MavenArchiver();
archiver.setArchiver(earArchiver);
@@ -137,10 +146,35 @@
tempLocation.mkdirs();
tempLocation.deleteOnExit();
- //ZipFileSet currentFiles = new ZipFileSet();
- //currentFiles.setSrc(this.srcFile);
- //currentFiles.createExclude().setName("META-INF/application.xml");
- //addZipfileset(currentFiles);
+ try
+ {
+ if(this.srcFile != null)
+ {
+ AssemblyFileUtils.unpack(this.srcFile, tempLocation,
+ archiverManager);
+ }
+ }
+ catch (ArchiveExpansionException e)
+ {
+ throw new MojoExecutionException("Error extracting the"
+ + " archive.", e);
+ }
+ catch (NoSuchArchiverException e)
+ {
+ throw new MojoExecutionException("Problem reading the "
+ + "source archive.", e);
+ }
+
+ try
+ {
+ earArchiver.addDirectory(tempLocation);
+ }
+ catch (ArchiverException e1)
+ {
+ // Cannot add the temp location for some reason.
+ throw new MojoExecutionException("Problem adding the source " +
+ "files to the dest. archive ", e1);
+ }
// cactify the application.xml
ApplicationXml appXml = null;
@@ -162,12 +196,12 @@
earArchiver.setAppxml(tmpAppXml);
archiver.setOutputFile(getDestFile());
- archiver.createArchive(getProject(), getArchive());
-
// create the cactus war
File cactusWarFile = createCactusWar();
addFileToEar(cactusWarFile, cactusWar.getFileName());
+
+ archiver.createArchive(getProject(), getArchive());
}
catch(ArchiverException aex)
{
@@ -189,8 +223,21 @@
throw new MojoExecutionException("Problem with resolving the"
+ " dependencies of the project. ", de);
}
-
- //super.execute();
+ finally
+ {
+ try
+ {
+ if (tempLocation != null)
+ {
+ FileUtils.deleteDirectory(tempLocation);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new MojoExecutionException("Error deleting temporary "
+ + "folder", e);
+ }
+ }
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org