servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r398922 - /incubator/servicemix/trunk/tooling/maven2-jbi-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateInstallerMojo.java
Date Tue, 02 May 2006 12:05:15 GMT
Author: gnodet
Date: Tue May  2 05:04:37 2006
New Revision: 398922

URL: http://svn.apache.org/viewcvs?rev=398922&view=rev
Log:
Remove scm files from jbi installer.
Move the main artifact jar to the lib directory.

Modified:
    incubator/servicemix/trunk/tooling/maven2-jbi-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateInstallerMojo.java

Modified: incubator/servicemix/trunk/tooling/maven2-jbi-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateInstallerMojo.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/tooling/maven2-jbi-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateInstallerMojo.java?rev=398922&r1=398921&r2=398922&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/maven2-jbi-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateInstallerMojo.java
(original)
+++ incubator/servicemix/trunk/tooling/maven2-jbi-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateInstallerMojo.java
Tue May  2 05:04:37 2006
@@ -30,11 +30,12 @@
 import org.codehaus.plexus.archiver.ArchiverException;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
 import org.codehaus.plexus.archiver.jar.ManifestException;
+import org.codehaus.plexus.util.DirectoryScanner;
 import org.codehaus.plexus.util.FileUtils;
 
 /**
  * A Mojo used to build the jbi component installer file.
- *
+ * 
  * @author <a href="gnodet@apache.org">Guillaume Nodet</a>
  * @version $Id: GenerateApplicationXmlMojo.java 314956 2005-10-12 16:27:15Z brett $
  * @goal jbi-component
@@ -46,7 +47,7 @@
 
     /**
      * The directory for the generated JBI component.
-     *
+     * 
      * @parameter expression="${project.build.directory}"
      * @required
      */
@@ -54,15 +55,15 @@
 
     /**
      * The name of the generated war.
-     *
+     * 
      * @parameter expression="${project.artifactId}-${project.version}-installer.zip"
      * @required
      */
     private String installerName;
-    
+
     /**
      * The Zip archiver.
-     *
+     * 
      * @parameter expression="${component.org.codehaus.plexus.archiver.Archiver#jar}"
      * @required
      */
@@ -70,7 +71,7 @@
 
     /**
      * Single directory for extra files to include in the JBI component.
-     *
+     * 
      * @parameter expression="${basedir}/src/main/jbi"
      * @required
      */
@@ -78,97 +79,91 @@
 
     /**
      * The maven archive configuration to use.
-     *
+     * 
      * @parameter
      */
     private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
 
+    public void execute() throws MojoExecutionException, MojoFailureException {
+
+        getLog().debug(" ======= GenerateInstallerMojo settings =======");
+        getLog().debug("workDirectory[" + workDirectory + "]");
+        getLog().debug("installerName[" + installerName + "]");
+        getLog().debug("jbiSourceDirectory[" + jbiSourceDirectory + "]");
 
-	public void execute() throws MojoExecutionException, MojoFailureException {
-		
-        getLog().debug( " ======= GenerateInstallerMojo settings =======" );
-        getLog().debug( "workDirectory[" + workDirectory + "]" );
-        getLog().debug( "installerName[" + installerName + "]" );
-        getLog().debug( "jbiSourceDirectory[" + jbiSourceDirectory + "]" );
-        
         try {
-        	
-			createUnpackedInstaller();
-			
-			File installerFile = new File(outputDirectory, installerName);
-			createArchive(installerFile);
-			
-			projectHelper.attachArtifact(project, "zip", "installer", new File(outputDirectory, installerName));
-			
-		} catch (JbiPluginException e) {
-            throw new MojoExecutionException( "Failed to create installer", e );
-		}
-	}
-
-	private void createArchive(File installerFile) throws JbiPluginException {
-		try {
-			
-	        //generate war file
-	        getLog().info( "Generating installer " + installerFile.getAbsolutePath() );
-	        MavenArchiver archiver = new MavenArchiver();
-	        archiver.setArchiver( jarArchiver );
-	        archiver.setOutputFile( installerFile );
-			jarArchiver.addDirectory( workDirectory );
-			if (jbiSourceDirectory.isDirectory()) {
-			jarArchiver.addDirectory( jbiSourceDirectory );
-      }
-			// create archive
-			archiver.createArchive( getProject(), archive );
-			
-		} catch (ArchiverException e) {
-			throw new JbiPluginException("Error creating assembly: " + e.getMessage(), e);
-		} catch (ManifestException e) {
-			throw new JbiPluginException("Error creating assembly: " + e.getMessage(), e);
-		} catch (IOException e) {
-			throw new JbiPluginException("Error creating assembly: " + e.getMessage(), e);
-		} catch (DependencyResolutionRequiredException e) {
-			throw new JbiPluginException("Error creating assembly: " + e.getMessage(), e);
-		}
-
-	}
-
-	private void createUnpackedInstaller() throws JbiPluginException {
-
-		if (!workDirectory.isDirectory()) {
-			if (!workDirectory.mkdirs()) {
-				throw new JbiPluginException("Unable to create work directory: " + workDirectory);
-			}
-		}
+
+            createUnpackedInstaller();
+
+            File installerFile = new File(outputDirectory, installerName);
+            createArchive(installerFile);
+
+            projectHelper.attachArtifact(project, "zip", "installer", new File(outputDirectory,
installerName));
+
+        } catch (JbiPluginException e) {
+            throw new MojoExecutionException("Failed to create installer", e);
+        }
+    }
+
+    private void createArchive(File installerFile) throws JbiPluginException {
+        try {
+
+            // generate war file
+            getLog().info("Generating installer " + installerFile.getAbsolutePath());
+            MavenArchiver archiver = new MavenArchiver();
+            archiver.setArchiver(jarArchiver);
+            archiver.setOutputFile(installerFile);
+            jarArchiver.addDirectory(workDirectory);
+            if (jbiSourceDirectory.isDirectory()) {
+                jarArchiver.addDirectory(jbiSourceDirectory, null, DirectoryScanner.DEFAULTEXCLUDES);
+            }
+            // create archive
+            archiver.createArchive(getProject(), archive);
+
+        } catch (ArchiverException e) {
+            throw new JbiPluginException("Error creating assembly: " + e.getMessage(), e);
+        } catch (ManifestException e) {
+            throw new JbiPluginException("Error creating assembly: " + e.getMessage(), e);
+        } catch (IOException e) {
+            throw new JbiPluginException("Error creating assembly: " + e.getMessage(), e);
+        } catch (DependencyResolutionRequiredException e) {
+            throw new JbiPluginException("Error creating assembly: " + e.getMessage(), e);
+        }
+
+    }
+
+    private void createUnpackedInstaller() throws JbiPluginException {
+
+        if (!workDirectory.isDirectory()) {
+            if (!workDirectory.mkdirs()) {
+                throw new JbiPluginException("Unable to create work directory: " + workDirectory);
+            }
+        }
 
         File projectArtifact = new File(outputDirectory, project.getArtifactId() + "-" +
project.getVersion() + ".jar");
-    	try {
-        	FileUtils.copyFileToDirectory( projectArtifact,
-        								   workDirectory);
-    	} catch (IOException e) {
-    		throw new JbiPluginException("Unable to copy file " + projectArtifact, e);
-    	}
-		
+        try {
+            FileUtils.copyFileToDirectory(projectArtifact, new File(workDirectory, LIB_DIRECTORY));
+        } catch (IOException e) {
+            throw new JbiPluginException("Unable to copy file " + projectArtifact, e);
+        }
+
         Set artifacts = project.getArtifacts();
-        for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
-        {
+        for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
             Artifact artifact = (Artifact) iter.next();
 
             // TODO: utilise appropriate methods from project builder
-            ScopeArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME
);
-            if ( !artifact.isOptional() && filter.include( artifact ) )
-            {
+            ScopeArtifactFilter filter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
+            if (!artifact.isOptional() && filter.include(artifact)) {
                 String type = artifact.getType();
-                if ( "jar".equals( type ) )
-                {
-                	try {
-	                	FileUtils.copyFileToDirectory( artifact.getFile(),
-	                								   new File(workDirectory, LIB_DIRECTORY));
-                	} catch (IOException e) {
-                		throw new JbiPluginException("Unable to copy file " + artifact.getFile(),
e);
-                	}
+                if ("jar".equals(type)) {
+                    try {
+                        FileUtils.copyFileToDirectory(artifact.getFile(), new File(workDirectory,
LIB_DIRECTORY));
+                    } catch (IOException e) {
+                        throw new JbiPluginException("Unable to copy file " + artifact.getFile(),
e);
+                    }
                 }
             }
         }
-	}
+    }
 
 }



Mime
View raw message