You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by pd...@apache.org on 2006/06/30 14:28:56 UTC

svn commit: r418244 - in /incubator/servicemix/trunk/tooling/jbi-maven-plugin: ./ src/main/java/org/apache/servicemix/maven/plugin/jbi/ src/main/resources/ src/main/resources/META-INF/plexus/

Author: pdodds
Date: Fri Jun 30 05:28:55 2006
New Revision: 418244

URL: http://svn.apache.org/viewvc?rev=418244&view=rev
Log:
Updated the JBI plugins to better enable the deployment of projects,  including new goals for the automatic deployment of a project and all its dependencies as well as a goal that starts a servicemix under the build directory and then deploys the current project (and dependencies).  Might need to move this functionality out of the JBI plugin and into a ServiceMix plugin later?

Added:
    incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/AbstractDeployableMojo.java
    incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/JbiProjectDeployerMojo.java
    incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixMojo.java
    incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/resources/log4j.properties
Modified:
    incubator/servicemix/trunk/tooling/jbi-maven-plugin/pom.xml
    incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateComponentMojo.java
    incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyDescriptorMojo.java
    incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyMojo.java
    incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateSharedLibraryMojo.java
    incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/resources/META-INF/plexus/components.xml

Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/pom.xml?rev=418244&r1=418243&r2=418244&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/pom.xml (original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/pom.xml Fri Jun 30 05:28:55 2006
@@ -69,6 +69,11 @@
             <artifactId>maven-script-ant</artifactId>
             <version>2.0.1</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix</groupId>
+            <artifactId>servicemix-core</artifactId>
+            <version>3.0-incubating-SNAPSHOT</version>
+        </dependency>
     </dependencies>
 
     <build>

Added: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/AbstractDeployableMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/AbstractDeployableMojo.java?rev=418244&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/AbstractDeployableMojo.java (added)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/AbstractDeployableMojo.java Fri Jun 30 05:28:55 2006
@@ -0,0 +1,68 @@
+package org.apache.servicemix.maven.plugin.jbi;
+
+import org.apache.servicemix.jbi.management.task.JbiTask;
+import org.apache.tools.ant.Project;
+
+public abstract class AbstractDeployableMojo extends AbstractJbiMojo {
+
+	/**
+	 * @parameter default-value="rmi"
+	 */
+	private String serverProtocol;
+
+	/**
+	 * @parameter default-value="localhost"
+	 */
+	private String host;
+
+	/**
+	 * @parameter default-value="ServiceMix"
+	 */
+	private String containerName;
+
+	/**
+	 * @parameter default-value="org.apache.servicemix"
+	 */
+	private String jmxDomainName;
+
+	/**
+	 * @parameter default-value="1099"
+	 */
+	protected String port;
+
+	/**
+	 * @parameter default-value="/jmxrmi"
+	 */
+	private String jndiPath;
+
+	/**
+	 * @parameter default-value=""
+	 */
+	private String username;
+
+	/**
+	 * @parameter default-value=""
+	 */
+	private String password;
+
+	protected JbiTask initializeJbiTask(JbiTask task) {
+		
+		Project antProject = new Project();
+		antProject.init();		
+		task.setProject(antProject);
+		
+		task.setContainerName(containerName);
+		task.setHost(host);
+		task.setServerProtocol(serverProtocol);
+		task.setJmxDomainName(jmxDomainName);
+		task.setPort(Integer.parseInt(port));
+		task.setJndiPath(jndiPath);
+		task.setUsername(username);
+		task.setPassword(password);		
+		
+		task.setTaskName("JBITask");		
+		task.setTaskType("JBITask");
+		return task;
+	}
+
+}

Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateComponentMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateComponentMojo.java?rev=418244&r1=418243&r2=418244&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateComponentMojo.java (original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateComponentMojo.java Fri Jun 30 05:28:55 2006
@@ -101,7 +101,7 @@
             File installerFile = new File(outputDirectory, installerName);
             createArchive(installerFile);
 
-            projectHelper.attachArtifact(project, "zip", "installer", new File(outputDirectory, installerName));
+            projectHelper.attachArtifact(project, project.getPackaging(), "installer", new File(outputDirectory, installerName));
 
         } catch (JbiPluginException e) {
             throw new MojoExecutionException("Failed to create installer", e);

Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyDescriptorMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyDescriptorMojo.java?rev=418244&r1=418243&r2=418244&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyDescriptorMojo.java (original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyDescriptorMojo.java Fri Jun 30 05:28:55 2006
@@ -135,8 +135,11 @@
 
 	/**
 	 * Generates the deployment descriptor if necessary.
+	 * 
+	 * @throws MojoExecutionException
 	 */
-	protected void generateJbiDescriptor() throws JbiPluginException {
+	protected void generateJbiDescriptor() throws JbiPluginException,
+			MojoExecutionException {
 		File outputDir = new File(generatedDescriptorLocation);
 		if (!outputDir.exists()) {
 			outputDir.mkdirs();
@@ -153,7 +156,8 @@
 			// TODO: utilise appropriate methods from project builder
 			ScopeArtifactFilter filter = new ScopeArtifactFilter(
 					Artifact.SCOPE_RUNTIME);
-			if (!artifact.isOptional() && filter.include(artifact)) {
+			if (!artifact.isOptional() && filter.include(artifact)
+					&& (artifact.getDependencyTrail().size() == 2)) {
 				MavenProject project = null;
 				try {
 					project = pb.buildFromRepository(artifact, remoteRepos,
@@ -164,13 +168,13 @@
 									+ artifact.getArtifactId()
 									+ " assuming jar");
 				}
-				if (project != null
-						&& project.getPackaging().equals("jbi-service-unit")) {
+				if ((project != null)
+						&& (project.getPackaging().equals("jbi-service-unit"))) {
 					DependencyInformation info = new DependencyInformation();
 					info.setName(artifact.getArtifactId());
 					info.setFilename(artifact.getFile().getName());
-					info.setComponent(project.getProperties().getProperty(
-							"jbiComponentName"));
+					info.setComponent(getComponentName(project, artifacts,
+							artifact));
 					info.setDescription(project.getDescription());
 					serviceUnits.add(info);
 				}
@@ -181,5 +185,60 @@
 		JbiServiceAssemblyDescriptorWriter writer = new JbiServiceAssemblyDescriptorWriter(
 				encoding);
 		writer.write(descriptor, name, description, serviceUnits);
+	}
+
+	private String getComponentName(MavenProject project, Set artifacts,
+			Artifact suArtifact) throws MojoExecutionException {
+
+		getLog().info(
+				"Determining component name for service unit "
+						+ project.getArtifactId());
+		if (project.getProperties().getProperty("componentName") != null) {
+			return project.getProperties().getProperty("componentName");
+		}
+
+		String currentArtifact = suArtifact.getGroupId() + ":"
+				+ suArtifact.getArtifactId() + ":" + suArtifact.getType() + ":"
+				+ suArtifact.getVersion();
+
+		// Find artifacts directly under this project
+		for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
+			Artifact artifact = (Artifact) iter.next();
+			if ((artifact.getDependencyTrail().size() == 3)) {
+				String parent = getDependencyParent(artifact
+						.getDependencyTrail());
+				getLog().info(
+						"Parent is " + parent + " while current is "
+								+ currentArtifact);
+				if (parent.equals(currentArtifact)) {
+					getLog().info("Yay!");
+					MavenProject artifactProject = null;
+					try {
+						artifactProject = pb.buildFromRepository(artifact,
+								remoteRepos, localRepo);
+					} catch (ProjectBuildingException e) {
+						getLog().warn(
+								"Unable to determine packaging for dependency : "
+										+ artifact.getArtifactId()
+										+ " assuming jar");
+					}
+					getLog().info("Project "+artifactProject+" packaged "+artifactProject.getPackaging());
+					if ((artifactProject != null)
+							&& (artifactProject.getPackaging()
+									.equals("jbi-component"))) {
+						return artifact.getArtifactId();
+					}
+				}
+			}
+		}
+
+		throw new MojoExecutionException(
+				"The service unit "
+						+ project.getArtifactId()
+						+ " does not have a dependency which is packaged as a jbi-component or a project property 'componentName'");
+	}
+
+	private String getDependencyParent(List dependencyTrail) {
+		return (String) dependencyTrail.get(dependencyTrail.size() - 2);
 	}
 }

Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyMojo.java?rev=418244&r1=418243&r2=418244&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyMojo.java (original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateServiceAssemblyMojo.java Fri Jun 30 05:28:55 2006
@@ -21,9 +21,14 @@
 import java.util.Set;
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+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.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuildingException;
 import org.codehaus.plexus.util.FileUtils;
 
 /**
@@ -40,6 +45,11 @@
 public class GenerateServiceAssemblyMojo extends AbstractJbiMojo {
 
 	/**
+	 * @component
+	 */
+	private ArtifactFactory af;
+
+	/**
 	 * Directory where the application.xml file will be auto-generated.
 	 * 
 	 * @parameter expression="${project.build.directory}/classes"
@@ -50,35 +60,39 @@
 	public void execute() throws MojoExecutionException, MojoFailureException {
 		try {
 			injectDependentServiceUnits();
-		} catch (JbiPluginException e) {
+		} catch (Exception e) {
 			throw new MojoExecutionException("Failed to inject dependencies", e);
 		}
 	}
 
-	private void injectDependentServiceUnits() throws JbiPluginException {
+	private void injectDependentServiceUnits() throws JbiPluginException,
+			ArtifactResolutionException, ArtifactNotFoundException {
 		Set artifacts = project.getArtifacts();
 		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)) {
-				String type = artifact.getType();
-				if ("jbi-service-unit".equals(type)) {
-					try {								
-						getLog()
-								.info(
-										"Copying service unit "
-												+ artifact.getFile()
-														.getAbsolutePath()
-												+ " into working directory for packaging");
+					Artifact.SCOPE_RUNTIME);			
+			if (!artifact.isOptional() && filter.include(artifact)
+					&& (artifact.getDependencyTrail().size() == 2)) {
+				MavenProject project = null;
+				try {
+					project = projectBuilder.buildFromRepository(artifact,
+							remoteRepos, localRepo);
+				} catch (ProjectBuildingException e) {
+					getLog().warn(
+							"Unable to determine packaging for dependency : "
+									+ artifact.getArtifactId()
+									+ " assuming jar");
+				}
+				if ((project != null)
+						&& (project.getPackaging().equals("jbi-service-unit"))) {
+					try {
 						FileUtils.copyFileToDirectory(artifact.getFile(),
 								workDirectory);
 					} catch (IOException e) {
-						throw new JbiPluginException(
-								"Unable to find service unit "
-										+ artifact.getFile(), e);
+						throw new JbiPluginException(e);
 					}
 				}
 			}

Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateSharedLibraryMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateSharedLibraryMojo.java?rev=418244&r1=418243&r2=418244&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateSharedLibraryMojo.java (original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/GenerateSharedLibraryMojo.java Fri Jun 30 05:28:55 2006
@@ -96,7 +96,7 @@
 			File installerFile = new File(outputDirectory, sharedLibraryName);
 			createArchive(installerFile);
 
-			projectHelper.attachArtifact(project, "zip", "", new File(
+			projectHelper.attachArtifact(project, project.getPackaging(), "installer", new File(
 					outputDirectory, sharedLibraryName));
 
 		} catch (JbiPluginException e) {

Added: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/JbiProjectDeployerMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/JbiProjectDeployerMojo.java?rev=418244&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/JbiProjectDeployerMojo.java (added)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/JbiProjectDeployerMojo.java Fri Jun 30 05:28:55 2006
@@ -0,0 +1,275 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.maven.plugin.jbi;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Stack;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuildingException;
+import org.apache.servicemix.jbi.management.task.DeployServiceAssemblyTask;
+import org.apache.servicemix.jbi.management.task.InstallComponentTask;
+import org.apache.servicemix.jbi.management.task.InstallSharedLibraryTask;
+import org.apache.servicemix.jbi.management.task.StartComponentTask;
+
+/**
+ * A Mojo that can take any project and determine its JBI dependencies and then
+ * install it and its dependencies using the JBI deployment tasks
+ * 
+ * @author <a href="pdodds@apache.org">Philip Dodds</a>
+ * @version $Id: GenerateComponentDescriptorMojo 314956 2005-10-12 16:27:15Z
+ *          brett $
+ * @goal projectDeploy
+ * @requiresDependencyResolution runtime
+ * @description Starts a ServiceMix instance and installs the project (and all
+ *              dependencies) to it
+ */
+public class JbiProjectDeployerMojo extends AbstractDeployableMojo {
+
+	private List deploymentTypes;
+
+	/**
+	 * @parameter default-value="${project}"
+	 */
+	private MavenProject project;
+
+	/**
+	 * @component
+	 */
+	private MavenProjectBuilder pb;
+
+	/**
+	 * @component
+	 */
+	private ArtifactFactory af;
+
+	/**
+	 * @parameter default-value="${localRepository}"
+	 */
+	private ArtifactRepository localRepo;
+
+	/**
+	 * @parameter default-value="${project.remoteArtifactRepositories}"
+	 */
+	private List remoteRepos;
+
+	public void execute() throws MojoExecutionException, MojoFailureException {
+		deployProject();
+	}
+
+	protected void deployProject() throws MojoExecutionException {
+		if (!getDeployablePackagingTypes().contains(project.getPackaging())) {
+			throw new MojoExecutionException(
+					"Project must be of packaging type ["
+							+ getDeployablePackagingTypes() + "]");
+		}
+
+		try {
+			Stack dependencies = new Stack();
+			dependencies.add(resolveDeploymentPackage(project, project
+					.getArtifact()));
+			ArrayList artifactList = new ArrayList();
+			artifactList.addAll(project.getArtifacts());
+			Collections.sort(artifactList, new ArtifactDepthComparator());
+			for (Iterator iter = artifactList.iterator(); iter.hasNext();) {
+				Artifact artifact = (Artifact) iter.next();
+				getLog().info(
+						"For Project " + project.getArtifactId()
+								+ " -> Resolve artifact " + artifact);
+				resolveArtifact(artifact, dependencies);
+			}
+
+			getLog()
+					.info(
+							"------------------ Deployment Analysis --------------------");
+			getLog().info(
+					project.getName() + " has " + (dependencies.size() - 1)
+							+ " child dependencies");
+
+			for (Iterator iterator = dependencies.iterator(); iterator
+					.hasNext();) {
+				getLog().info(" - " + iterator.next());
+			}
+
+			getLog()
+					.info(
+							"-----------------------------------------------------------");
+			while (!dependencies.empty()) {
+				deployDependency((JbiDeployableArtifact) dependencies.pop());
+			}
+		} catch (Exception e) {
+			throw new MojoExecutionException("Unable to deploy project, "
+					+ e.getMessage(), e);
+		}
+
+	}
+
+	private void deployDependency(JbiDeployableArtifact jbiDeployable) {
+
+		getLog().info(
+				"Deploying " + jbiDeployable.getType() + " from "
+						+ jbiDeployable.getFile());
+		if ("jbi-shared-library".equals(jbiDeployable.getType())) {
+			InstallSharedLibraryTask componentTask = new InstallSharedLibraryTask();
+			initializeJbiTask(componentTask);
+			componentTask.setFile(jbiDeployable.getFile());
+			componentTask.execute();
+		} else if ("jbi-service-assembly".equals(jbiDeployable.getType())) {
+			DeployServiceAssemblyTask componentTask = new DeployServiceAssemblyTask();
+			initializeJbiTask(componentTask);
+			componentTask.setFile(jbiDeployable.getFile());
+			componentTask.execute();
+		}
+		if ("jbi-component".equals(jbiDeployable.getType())) {
+			InstallComponentTask componentTask = new InstallComponentTask();
+			initializeJbiTask(componentTask);
+			componentTask.setFile(jbiDeployable.getFile());
+			componentTask.execute();
+
+			StartComponentTask startTask = new StartComponentTask();
+			initializeJbiTask(startTask);
+			startTask.setName(jbiDeployable.getName());
+			startTask.execute();
+		}
+
+	}
+
+	private List getDeployablePackagingTypes() {
+		if (deploymentTypes == null) {
+			deploymentTypes = new ArrayList();
+			deploymentTypes.add("jbi-shared-library");
+			deploymentTypes.add("jbi-service-assembly");
+			deploymentTypes.add("jbi-component");
+		}
+		return deploymentTypes;
+	}
+
+	private Collection resolveArtifact(Artifact artifact, Stack dependencies)
+			throws ArtifactResolutionException, ArtifactNotFoundException {
+		MavenProject project = null;
+		try {
+			project = pb.buildFromRepository(artifact, remoteRepos, localRepo,
+					true);
+		} catch (ProjectBuildingException e) {
+			getLog().warn(
+					"Unable to determine packaging for dependency : "
+							+ artifact.getArtifactId() + " assuming jar");
+		}
+
+		if (project != null) {
+			getLog().debug(
+					"Resolved artifact to project " + project.getArtifactId());
+			if (getDeployablePackagingTypes().contains(project.getPackaging())) {
+				getLog().debug(
+						"Checking for dependency from project "
+								+ project.getArtifactId());
+				JbiDeployableArtifact deployableArtifact = resolveDeploymentPackage(
+						project, artifact);
+				if (!dependencies.contains(deployableArtifact)) {
+					getLog().debug(
+							"Adding dependency from project "
+									+ project.getArtifactId());
+					dependencies.push(deployableArtifact);
+				}
+			}
+		}
+		return dependencies;
+	}
+
+	private JbiDeployableArtifact resolveDeploymentPackage(
+			MavenProject project, Artifact artifact)
+			throws ArtifactResolutionException, ArtifactNotFoundException {
+		Artifact jbiArtifact = af.createArtifactWithClassifier(artifact
+				.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
+				project.getPackaging(), getExtension(project));
+		resolver.resolve(jbiArtifact, remoteRepos, localRepo);
+		return new JbiDeployableArtifact(project.getArtifactId(), project
+				.getPackaging(), jbiArtifact.getFile().getAbsolutePath());
+	}
+
+	private String getExtension(MavenProject project2) {
+		if (project2.getPackaging().equals("jbi-service-assembly"))
+			return "";
+		else
+			return "installer";
+	}
+
+	private class ArtifactDepthComparator implements Comparator {
+
+		public int compare(Object arg0, Object arg1) {
+			int size1 = ((Artifact) arg0).getDependencyTrail().size();
+			int size2 = ((Artifact) arg1).getDependencyTrail().size();
+			if (size1 == size2)
+				return 0;
+			if (size1 > size2)
+				return 1;
+			else
+				return -1;
+		}
+
+	}
+
+	private class JbiDeployableArtifact {
+		private String file;
+
+		private String type;
+
+		private String name;
+
+		public String getName() {
+			return name;
+		}
+
+		public JbiDeployableArtifact(String name, String type, String file) {
+			this.name = name;
+			this.file = file;
+			this.type = type;
+		}
+
+		public String getFile() {
+			return file;
+		}
+
+		public String getType() {
+			return type;
+		}
+
+		public String toString() {
+			return type + " : " + file;
+		}
+
+		public boolean equals(Object obj) {
+			if (obj instanceof JbiDeployableArtifact)
+				return ((JbiDeployableArtifact) obj).toString().equals(
+						this.toString());
+			else
+				return false;
+		}
+	}
+}

Added: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixMojo.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixMojo.java?rev=418244&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixMojo.java (added)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/java/org/apache/servicemix/maven/plugin/jbi/ServiceMixMojo.java Fri Jun 30 05:28:55 2006
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.maven.plugin.jbi;
+
+import javax.jbi.JBIException;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.servicemix.jbi.container.JBIContainer;
+
+/**
+ * Starts a ServiceMix JBI container and them uses the deploy project MOJO to
+ * push the current project and dependencies to it
+ * 
+ * @author <a href="pdodds@apache.org">Philip Dodds</a>
+ * @version $Id: GenerateComponentDescriptorMojo 314956 2005-10-12 16:27:15Z
+ *          brett $
+ * @goal servicemix
+ * @requiresDependencyResolution runtime
+ * @description installs the project (and all dependencies) to a local
+ *              ServiceMix instance
+ */
+public class ServiceMixMojo extends JbiProjectDeployerMojo {
+
+	private JBIContainer jbiContainer;
+
+	/**
+	 * @parameter default-value="${project.build.directory}/servicemix/install"
+	 */
+	private String installDirectory;
+
+	/**
+	 * @parameter default-value="${project.build.directory}/servicemix/deploy"
+	 */
+	private String deploymentDirectory;
+
+	/**
+	 * @parameter default-value="${project.build.directory}/servicemix/rootDir"
+	 */
+	private String rootDirectory;
+
+	public void execute() throws MojoExecutionException, MojoFailureException {
+
+		try {
+			startServiceMix();
+			deployProject();
+
+			getLog().info("Project deployed");
+			while (true)
+				;
+		} catch (Exception e) {
+			stopServiceMix();
+			throw new MojoExecutionException(
+					"Apache ServiceMix was able to deploy project", e);
+		}
+
+	}
+
+	private void stopServiceMix() {
+		getLog().info("Shutting down Apache ServiceMix");
+		if (jbiContainer != null)
+			try {
+				jbiContainer.shutDown();
+			} catch (JBIException e) {
+				getLog().warn(e);
+			}
+	}
+
+	private void startServiceMix() throws MojoExecutionException {
+		try {
+			getLog().info("Starting Apache ServiceMix");
+			jbiContainer = new JBIContainer();
+			jbiContainer.setRmiPort(Integer.parseInt(port));
+			jbiContainer.setCreateMBeanServer(true);
+			jbiContainer.setInstallationDirPath(installDirectory);
+			jbiContainer.setDeploymentDirPath(deploymentDirectory);
+			jbiContainer.setRootDir(rootDirectory);
+			jbiContainer.init();
+			jbiContainer.start();
+		} catch (JBIException e) {
+			throw new MojoExecutionException(
+					"Unable to start the JBI container", e);
+		}
+	}
+}

Modified: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/resources/META-INF/plexus/components.xml?rev=418244&r1=418243&r2=418244&view=diff
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/resources/META-INF/plexus/components.xml (original)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/resources/META-INF/plexus/components.xml Fri Jun 30 05:28:55 2006
@@ -43,7 +43,7 @@
       <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
       <configuration>
         <type>jbi-service-unit</type>
-        <extension>jar</extension>
+        <extension>zip</extension>
         <language>java</language>
       </configuration>
     </component>
@@ -72,7 +72,7 @@
       <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
       <configuration>
         <type>jbi-service-assembly</type>
-        <extension>jar</extension>
+        <extension>zip</extension>
         <language>java</language>
       </configuration>
     </component>

Added: incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/resources/log4j.properties?rev=418244&view=auto
==============================================================================
--- incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/resources/log4j.properties (added)
+++ incubator/servicemix/trunk/tooling/jbi-maven-plugin/src/main/resources/log4j.properties Fri Jun 30 05:28:55 2006
@@ -0,0 +1,22 @@
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, stdout
+
+log4j.logger.javax.jbi=INFO
+log4j.logger.org.apache.activemq=INFO
+log4j.logger.org.apache.activemq.spring=WARN
+log4j.logger.org.apache.activemq.store.journal=INFO
+log4j.logger.org.activeio.journal=INFO
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/servicemix.log
+log4j.appender.out.append=true
\ No newline at end of file