servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1159082 - in /servicemix/maven-plugins/trunk/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi: AbstractJbiMojo.java GenerateServiceAssemblyDescriptorMojo.java GenerateServiceAssemblyMojo.java
Date Thu, 18 Aug 2011 08:27:54 GMT
Author: ffang
Date: Thu Aug 18 08:27:54 2011
New Revision: 1159082

URL: http://svn.apache.org/viewvc?rev=1159082&view=rev
Log:
[SM-2102]GenerateServiceAssemblyMojo should be able to pacakge SA according to serviceUnitName
specified for the SU

Modified:
    servicemix/maven-plugins/trunk/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/AbstractJbiMojo.java
    servicemix/maven-plugins/trunk/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyDescriptorMojo.java
    servicemix/maven-plugins/trunk/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyMojo.java

Modified: servicemix/maven-plugins/trunk/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/AbstractJbiMojo.java
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/trunk/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/AbstractJbiMojo.java?rev=1159082&r1=1159081&r2=1159082&view=diff
==============================================================================
--- servicemix/maven-plugins/trunk/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/AbstractJbiMojo.java
(original)
+++ servicemix/maven-plugins/trunk/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/AbstractJbiMojo.java
Thu Aug 18 08:27:54 2011
@@ -42,6 +42,7 @@ import org.apache.maven.artifact.version
 import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.DependencyManagement;
+import org.apache.maven.model.Plugin;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
@@ -51,6 +52,7 @@ import org.apache.maven.project.ProjectB
 import org.apache.servicemix.maven.plugin.jbi.JbiResolutionListener.Node;
 import org.codehaus.plexus.archiver.jar.Manifest;
 import org.codehaus.plexus.archiver.jar.ManifestException;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
 
 public abstract class AbstractJbiMojo extends AbstractMojo {
 
@@ -349,5 +351,26 @@ public abstract class AbstractJbiMojo ex
         sb.append(version.substring(matcher.end(), version.length()));
         return sb.toString();
     }
+    
+    protected String getServiceUnitName(MavenProject project) {
+		for (Object elem : project.getBuildPlugins()) {
+			if (elem instanceof Plugin) {
+				Plugin plugin = (Plugin)elem;
+				if (plugin.getGroupId().equals("org.apache.servicemix.tooling")
+						&& plugin.getArtifactId().equals("jbi-maven-plugin")) {
+					Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
+					if (configuration != null) {
+						Xpp3Dom serviceUnitName = configuration.getChild("serviceUnitName");
+						if (serviceUnitName != null) {
+							return serviceUnitName.getValue();
+						}
+					}
+					break;
+				}
+			}
+		}
+		return null;
+	}
+
 
 }

Modified: servicemix/maven-plugins/trunk/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyDescriptorMojo.java
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/trunk/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyDescriptorMojo.java?rev=1159082&r1=1159081&r2=1159082&view=diff
==============================================================================
--- servicemix/maven-plugins/trunk/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyDescriptorMojo.java
(original)
+++ servicemix/maven-plugins/trunk/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyDescriptorMojo.java
Thu Aug 18 08:27:54 2011
@@ -220,7 +220,12 @@ public class GenerateServiceAssemblyDesc
                     if (fileName.equals("classes")) {
                     	fileName = artifact.getArtifactId() + "-" + artifact.getVersion() +
".jar";
                     }
-                    fileName = fileName.substring(0, fileName.lastIndexOf('.')) + ".zip";
+                    String suName = getServiceUnitName(project);
+                    if (suName != null && suName.length() > 0) {
+                    	fileName = suName;
+                    } else {
+                    	fileName = fileName.substring(0, fileName.lastIndexOf('.')) + ".zip";
+                    }
                     info.setFilename(fileName);
                     info.setComponent(getComponentName(project, artifacts, artifact));
                     info.setDescription(project.getDescription());

Modified: servicemix/maven-plugins/trunk/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyMojo.java
URL: http://svn.apache.org/viewvc/servicemix/maven-plugins/trunk/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyMojo.java?rev=1159082&r1=1159081&r2=1159082&view=diff
==============================================================================
--- servicemix/maven-plugins/trunk/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyMojo.java
(original)
+++ servicemix/maven-plugins/trunk/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyMojo.java
Thu Aug 18 08:27:54 2011
@@ -22,6 +22,7 @@ import org.apache.maven.artifact.Artifac
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.model.Plugin;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
@@ -30,6 +31,7 @@ import org.codehaus.plexus.archiver.jar.
 import org.codehaus.plexus.archiver.jar.Manifest;
 import org.codehaus.plexus.util.DirectoryScanner;
 import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
 
 import java.io.File;
 import java.io.IOException;
@@ -133,9 +135,14 @@ public class GenerateServiceAssemblyMojo
                 }
                 if (project != null && project.getPackaging().equals("jbi-service-unit"))
{
                     try {
-                        String path = artifact.getFile().getAbsolutePath();
-                        path = path.substring(0, path.lastIndexOf('.')) + ".zip";
-                        FileUtils.copyFileToDirectory(new File(path), workDirectory);
+                    	String suName = getServiceUnitName(project);
+                    	String path = artifact.getFile().getAbsolutePath();
+                    	if (suName != null && suName.length() > 0) {
+                    		path = path.substring(0, path.lastIndexOf(File.separator)) + File.separator
+ suName;
+                    	} else {
+                    		path = path.substring(0, path.lastIndexOf('.')) + ".zip";
+                    	}
+                    	FileUtils.copyFileToDirectory(new File(path), workDirectory);
                     } catch (IOException e) {
                         throw new JbiPluginException(e);
                     }
@@ -143,5 +150,4 @@ public class GenerateServiceAssemblyMojo
             }
         }
     }
-
 }



Mime
View raw message