TAVERNA-899 package org.apache.taverna.mavenplugin

Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/commit/c660ed5c
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/tree/c660ed5c
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/diff/c660ed5c

Branch: refs/heads/master
Commit: c660ed5cd8370cfb403e7872b2912fef2d7b8139
Parents: 33defe4
Author: Stian Soiland-Reyes <[email protected]>
Authored: Wed Feb 17 10:36:40 2016 +0000
Committer: Stian Soiland-Reyes <[email protected]>
Committed: Wed Feb 17 10:36:40 2016 +0000

----------------------------------------------------------------------
 .../t2/maven/plugins/AbstractDeployMojo.java    |  52 ---
 .../t2/maven/plugins/AbstractWagonMojo.java     |  56 ---
 .../t2/maven/plugins/BundleArtifact.java        |  62 ---
 .../t2/maven/plugins/MavenOsgiUtils.java        | 411 -------------------
 .../sf/taverna/t2/maven/plugins/Package.java    |  42 --
 .../t2/maven/plugins/PackageVersion.java        |  73 ----
 .../plugins/TavernaPluginDeployFileMojo.java    | 230 -----------
 .../maven/plugins/TavernaPluginDeployMojo.java  | 215 ----------
 .../plugins/TavernaPluginGenerateMojo.java      | 137 -------
 .../TavernaPluginPrepareBundlesMojo.java        |  80 ----
 .../maven/plugins/TavernaProfileDeployMojo.java | 270 ------------
 .../plugins/TavernaProfileGenerateMojo.java     | 216 ----------
 .../net/sf/taverna/t2/maven/plugins/Utils.java  | 167 --------
 .../taverna/mavenplugin/AbstractDeployMojo.java |  52 +++
 .../taverna/mavenplugin/AbstractWagonMojo.java  |  56 +++
 .../taverna/mavenplugin/BundleArtifact.java     |  62 +++
 .../taverna/mavenplugin/MavenOsgiUtils.java     | 411 +++++++++++++++++++
 .../org/apache/taverna/mavenplugin/Package.java |  42 ++
 .../taverna/mavenplugin/PackageVersion.java     |  73 ++++
 .../TavernaPluginDeployFileMojo.java            | 230 +++++++++++
 .../mavenplugin/TavernaPluginDeployMojo.java    | 215 ++++++++++
 .../mavenplugin/TavernaPluginGenerateMojo.java  | 137 +++++++
 .../TavernaPluginPrepareBundlesMojo.java        |  80 ++++
 .../mavenplugin/TavernaProfileDeployMojo.java   | 270 ++++++++++++
 .../mavenplugin/TavernaProfileGenerateMojo.java | 216 ++++++++++
 .../org/apache/taverna/mavenplugin/Utils.java   | 167 ++++++++
 .../plugins/TavernaPluginGenerateMojoTest.java  |  76 ----
 .../sf/taverna/t2/maven/plugins/TestUtils.java  |  43 --
 .../TavernaPluginGenerateMojoTest.java          |  77 ++++
 .../apache/taverna/mavenplugin/TestUtils.java   |  44 ++
 30 files changed, 2132 insertions(+), 2130 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/c660ed5c/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/AbstractDeployMojo.java
----------------------------------------------------------------------
diff --git 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/AbstractDeployMojo.java
 
b/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/AbstractDeployMojo.java
deleted file mode 100644
index 7d24e82..0000000
--- 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/AbstractDeployMojo.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 net.sf.taverna.t2.maven.plugins;
-
-import java.io.File;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.project.MavenProject;
-
-/**
- * Abstract Mojo for deploying artifacts.
- *
- * @author David Withers
- */
-public abstract class AbstractDeployMojo extends AbstractWagonMojo {
-
-       @Component
-       protected MavenProject project;
-
-       /**
-        * Directory containing the generated Taverna plugin.
-        */
-       @Parameter(defaultValue = "${project.build.directory}", required = true)
-       protected File buildDirectory;
-
-       @Parameter(defaultValue = "${project.build.outputDirectory}", required 
= true)
-       protected File outputDirectory;
-
-       @Parameter(defaultValue = "${project.artifact}", required = true, 
readonly = true)
-       protected Artifact artifact;
-
-       @Parameter(defaultValue = 
"${project.distributionManagementArtifactRepository}", required = true, 
readonly = true)
-       protected ArtifactRepository deploymentRepository;
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/c660ed5c/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/AbstractWagonMojo.java
----------------------------------------------------------------------
diff --git 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/AbstractWagonMojo.java
 
b/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/AbstractWagonMojo.java
deleted file mode 100644
index 954d6f2..0000000
--- 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/AbstractWagonMojo.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 net.sf.taverna.t2.maven.plugins;
-
-import org.apache.maven.artifact.manager.WagonManager;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.observers.Debug;
-
-/**
- * Abstract Mojo for using the wagon.
- *
- * @author David Withers
- */
-public abstract class AbstractWagonMojo extends AbstractMojo {
-
-       @Component
-       protected WagonManager wagonManager;
-
-       /**
-        * Disconnect the wagon.
-        *
-        * @param wagon
-        *            the wagon to disconnect
-        * @param debug
-        */
-       protected void disconnectWagon(Wagon wagon, Debug debug) {
-               if (getLog().isDebugEnabled()) {
-                       wagon.removeTransferListener(debug);
-                       wagon.removeSessionListener(debug);
-               }
-               try {
-                       wagon.disconnect();
-               } catch (ConnectionException e) {
-                       getLog().error("Error disconnecting wagon - ignored", 
e);
-               }
-       }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/c660ed5c/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/BundleArtifact.java
----------------------------------------------------------------------
diff --git 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/BundleArtifact.java
 
b/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/BundleArtifact.java
deleted file mode 100644
index 9d04aec..0000000
--- 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/BundleArtifact.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 net.sf.taverna.t2.maven.plugins;
-
-import org.apache.maven.artifact.Artifact;
-
-/**
- *
- *
- * @author David Withers
- */
-public class BundleArtifact {
-
-       private Artifact artifact;
-       private String symbolicName;
-       private String version;
-
-       public BundleArtifact(Artifact artifact, String symbolicName, String 
version) {
-               this.artifact = artifact;
-               this.symbolicName = symbolicName;
-               this.version = version;
-       }
-
-       public Artifact getArtifact() {
-               return artifact;
-       }
-
-       public void setArtifact(Artifact artifact) {
-               this.artifact = artifact;
-       }
-
-       public String getSymbolicName() {
-               return symbolicName;
-       }
-
-       public void setSymbolicName(String symbolicName) {
-               this.symbolicName = symbolicName;
-       }
-
-       public String getVersion() {
-               return version;
-       }
-
-       public void setVersion(String version) {
-               this.version = version;
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/c660ed5c/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/MavenOsgiUtils.java
----------------------------------------------------------------------
diff --git 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/MavenOsgiUtils.java
 
b/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/MavenOsgiUtils.java
deleted file mode 100644
index 0baedb4..0000000
--- 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/MavenOsgiUtils.java
+++ /dev/null
@@ -1,411 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 net.sf.taverna.t2.maven.plugins;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-
-import org.apache.maven.RepositoryUtils;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.project.DefaultDependencyResolutionRequest;
-import org.apache.maven.project.DependencyResolutionException;
-import org.apache.maven.project.DependencyResolutionResult;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.ProjectDependenciesResolver;
-import org.apache.taverna.profile.xml.jaxb.BundleInfo;
-import org.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.graph.DependencyNode;
-import org.eclipse.aether.util.filter.ScopeDependencyFilter;
-
-import aQute.bnd.header.Attrs;
-import aQute.bnd.header.OSGiHeader;
-import aQute.bnd.header.Parameters;
-import aQute.bnd.osgi.Constants;
-import aQute.bnd.version.Version;
-import aQute.bnd.version.VersionRange;
-
-/**
- * @author David Withers
- */
-public class MavenOsgiUtils {
-
-       private final MavenProject project;
-       private final RepositorySystemSession repositorySystemSession;
-       private final ProjectDependenciesResolver projectDependenciesResolver;
-       private final Log log;
-
-       private Set<String> javaPackages;
-       private Set<String> systemPackages;
-
-       public MavenOsgiUtils(MavenProject project, RepositorySystemSession 
repositorySystemSession,
-                       ProjectDependenciesResolver 
projectDependenciesResolver, Log log) {
-               this(project, repositorySystemSession, 
projectDependenciesResolver, new HashSet<String>(),
-                               log);
-       }
-
-       public MavenOsgiUtils(MavenProject project, RepositorySystemSession 
repositorySystemSession,
-                       ProjectDependenciesResolver 
projectDependenciesResolver, Set<String> systemPackages,
-                       Log log) {
-               this.project = project;
-               this.repositorySystemSession = repositorySystemSession;
-               this.projectDependenciesResolver = projectDependenciesResolver;
-               this.systemPackages = systemPackages;
-               this.log = log;
-               javaPackages = Utils.getJavaPackages(log);
-       }
-
-       public Set<BundleArtifact> getBundleDependencies(String... scopes)
-                       throws MojoExecutionException {
-               ScopeDependencyFilter scopeFilter = new 
ScopeDependencyFilter(Arrays.asList(scopes), null);
-
-               DefaultDependencyResolutionRequest dependencyResolutionRequest 
= new DefaultDependencyResolutionRequest(
-                               project, repositorySystemSession);
-               dependencyResolutionRequest.setResolutionFilter(scopeFilter);
-
-               DependencyResolutionResult dependencyResolutionResult;
-               try {
-                       dependencyResolutionResult = projectDependenciesResolver
-                                       .resolve(dependencyResolutionRequest);
-               } catch (DependencyResolutionException ex) {
-                       throw new MojoExecutionException(ex.getMessage(), ex);
-               }
-
-               DependencyNode dependencyGraph = 
dependencyResolutionResult.getDependencyGraph();
-               if (dependencyGraph != null) {
-                       checkBundleDependencies(dependencyGraph.getChildren());
-                       return 
getBundleArtifacts(dependencyGraph.getChildren());
-               } else {
-                       return new HashSet<BundleArtifact>();
-               }
-       }
-
-       public Set<BundleArtifact> getBundleArtifacts(List<DependencyNode> 
nodes) {
-               Set<BundleArtifact> bundleArtifacts = new 
HashSet<BundleArtifact>();
-               for (DependencyNode node : nodes) {
-                       Artifact artifact = 
RepositoryUtils.toArtifact(node.getDependency().getArtifact());
-                       String symbolicName = getManifestAttribute(artifact, 
Constants.BUNDLE_SYMBOLICNAME);
-                       if (symbolicName != null) {
-                               String version = getManifestAttribute(artifact, 
Constants.BUNDLE_VERSION);
-                               bundleArtifacts.add(new 
BundleArtifact(artifact, symbolicName, version));
-                               
bundleArtifacts.addAll(getBundleArtifacts(node.getChildren()));
-                       } else {
-                               log.warn("Not an OSGi bundle : " + 
artifact.getId());
-                       }
-               }
-               return bundleArtifacts;
-       }
-
-       public Set<Artifact> getAllArtifacts(List<DependencyNode> nodes) {
-               Set<Artifact> artifacts = new HashSet<Artifact>();
-               for (DependencyNode node : nodes) {
-                       Artifact artifact = 
RepositoryUtils.toArtifact(node.getDependency().getArtifact());
-                       if (isBundle(artifact)) {
-                               artifacts.add(artifact);
-                               
artifacts.addAll(getAllArtifacts(node.getChildren()));
-                       }
-               }
-               return artifacts;
-       }
-
-       public Set<Artifact> getArtifacts(List<DependencyNode> nodes) {
-               Set<Artifact> artifacts = new HashSet<Artifact>();
-               for (DependencyNode node : nodes) {
-                       Artifact artifact = 
RepositoryUtils.toArtifact(node.getDependency().getArtifact());
-                       if (isBundle(artifact)) {
-                               artifacts.add(artifact);
-                       }
-               }
-               return artifacts;
-       }
-
-       public List<BundleInfo> getBundles(Set<BundleArtifact> 
bundleDependencies)
-                       throws MojoExecutionException {
-               List<BundleInfo> bundles = new ArrayList<BundleInfo>();
-               for (BundleArtifact bundleArtifact : bundleDependencies) {
-                       Artifact artifact = bundleArtifact.getArtifact();
-                       BundleInfo bundle = new BundleInfo();
-                       
bundle.setSymbolicName(bundleArtifact.getSymbolicName());
-                       bundle.setVersion(bundleArtifact.getVersion());
-                       bundle.setFileName(new File(artifact.getGroupId(), 
artifact.getFile().getName())
-                                       .getPath());
-                       bundles.add(bundle);
-               }
-               Collections.sort(bundles, new BundleComparator());
-               return bundles;
-       }
-
-       public Map<String, Set<PackageVersion>> 
getPackageDependencies(List<DependencyNode> nodes) {
-               Map<String, Set<PackageVersion>> exportVersions = 
calculatePackageVersions(
-                               getAllArtifacts(nodes), true, false);
-               return getPackageDependencies(getArtifacts(nodes), 
exportVersions);
-       }
-
-       public Map<String, Set<PackageVersion>> 
getPackageDependencies(Set<Artifact> requiredArtifacts,
-                       Map<String, Set<PackageVersion>> exportVersions) {
-               Map<String, Set<PackageVersion>> importVersions = 
calculatePackageVersions(
-                               requiredArtifacts, false, true);
-               Set<Artifact> newRequiredArtifacts = new HashSet<Artifact>();
-               for (Entry<String, Set<PackageVersion>> entry : 
importVersions.entrySet()) {
-                       if (!javaPackages.contains(entry.getKey())) {
-                               String packageName = entry.getKey();
-                               Set<PackageVersion> importsVersions = 
entry.getValue();
-                               Set<PackageVersion> exportsVersions = 
exportVersions.get(packageName);
-                               if (exportVersions.containsKey(entry.getKey())) 
{
-                                       for (Artifact artifact : 
getRequiredArtifacts(importsVersions, exportsVersions)) {
-                                               if 
(!requiredArtifacts.contains(artifact)) {
-                                                       
newRequiredArtifacts.add(artifact);
-                                               }
-                                       }
-                               }
-                       }
-               }
-               if (!newRequiredArtifacts.isEmpty()) {
-                       newRequiredArtifacts.addAll(requiredArtifacts);
-                       return getPackageDependencies(newRequiredArtifacts, 
exportVersions);
-               }
-               return importVersions;
-       }
-
-       /**
-        * Returns the minimum set of artifacts required to satisfy the range 
of importVersions.
-        *
-        * @param importsVersions
-        *            the version ranges required for the package
-        * @param exportVersions
-        *            the available versions for the package
-        * @return the minimum set of artifacts required to satisfy the range 
of importVersions
-        */
-       private Set<Artifact> getRequiredArtifacts(Set<PackageVersion> 
importsVersions,
-                       Set<PackageVersion> exportVersions) {
-               Set<Artifact> requiredArtifacts = new HashSet<Artifact>();
-               List<Set<PackageVersion>> exportsSubsets = 
Utils.getSubsets(exportVersions);
-               for (Set<PackageVersion> exportsSubset : exportsSubsets) {
-                       if (satisfiesImports(importsVersions, exportsSubset)) {
-                               for (PackageVersion exportVersion : 
exportsSubset) {
-                                       
requiredArtifacts.add(exportVersion.getArtifact());
-                               }
-                               break;
-                       }
-               }
-               return requiredArtifacts;
-       }
-
-       private boolean satisfiesImports(Set<PackageVersion> imports, 
Set<PackageVersion> exports) {
-               for (PackageVersion importVersion : imports) {
-                       if (!satisfiesImport(importVersion, exports)) {
-                               return false;
-                       }
-               }
-               return true;
-       }
-
-       private boolean satisfiesImport(PackageVersion importVersion, 
Set<PackageVersion> exports) {
-               for (PackageVersion exportVersion : exports) {
-                       if 
(importVersion.getVersionRange().includes(exportVersion.getVersionRange().getLow()))
 {
-                               return true;
-                       }
-               }
-               return false;
-       }
-
-       public void checkBundleDependencies(List<DependencyNode> nodes) {
-               Map<Artifact, Set<Package>> unresolvedArtifacts = new 
HashMap<Artifact, Set<Package>>();
-               Set<Artifact> artifacts = getAllArtifacts(nodes);
-               Map<String, Set<PackageVersion>> exports = 
calculatePackageVersions(artifacts, true, false);
-               for (Artifact artifact : artifacts) {
-                       if (isBundle(artifact)) {
-                               Parameters imports = 
getManifestAttributeParameters(artifact,
-                                               Constants.IMPORT_PACKAGE);
-                               if (imports != null) {
-                                       for (String packageName : 
imports.keySet()) {
-                                               boolean exportMissing = true;
-                                               VersionRange importRange = null;
-                                               Attrs attrs = 
imports.get(packageName);
-                                               if (isOptional(attrs)) {
-                                                       exportMissing = false;
-                                               } else if 
(javaPackages.contains(packageName)
-                                                               || 
systemPackages.contains(packageName)
-                                                               || 
packageName.startsWith("org.osgi.")) {
-                                                       exportMissing = false;
-                                               } else if (attrs == null || 
attrs.get(Constants.VERSION_ATTRIBUTE) == null) {
-                                                       if 
(exports.containsKey(packageName)) {
-                                                               exportMissing = 
false;
-                                                       }
-                                               } else {
-                                                       importRange = 
getVersionRange(attrs);
-                                                       if 
(exports.containsKey(packageName)) {
-                                                               for 
(PackageVersion exportVersion : exports.get(packageName)) {
-                                                                       if 
(importRange.includes(exportVersion.getVersionRange()
-                                                                               
        .getLow())) {
-                                                                               
exportMissing = false;
-                                                                               
break;
-                                                                       }
-                                                               }
-                                                       }
-                                               }
-                                               if (exportMissing) {
-                                                       if 
(!unresolvedArtifacts.containsKey(artifact)) {
-                                                               
unresolvedArtifacts.put(artifact, new HashSet<Package>());
-                                                       }
-                                                       
unresolvedArtifacts.get(artifact).add(
-                                                                       new 
Package(packageName, importRange));
-                                               }
-                                       }
-                               }
-                       }
-               }
-               for (Entry<Artifact, Set<Package>> unresolvedArtifact : 
unresolvedArtifacts.entrySet()) {
-                       log.warn("Bundle : " + 
unresolvedArtifact.getKey().getId()
-                                       + " has unresolved package 
dependencies:");
-                       for (Package unresolvedPackage : 
unresolvedArtifact.getValue()) {
-                               log.warn("    " + unresolvedPackage);
-                       }
-               }
-       }
-
-       public Map<String, Set<PackageVersion>> 
calculatePackageVersions(Set<Artifact> artifacts,
-                       boolean export, boolean unique) {
-               Map<String, Set<PackageVersion>> packageVersions = new 
HashMap<String, Set<PackageVersion>>();
-               for (Artifact artifact : artifacts) {
-                       if (isBundle(artifact)) {
-                               Parameters packages = 
getManifestAttributeParameters(artifact,
-                                               export ? 
Constants.EXPORT_PACKAGE : Constants.IMPORT_PACKAGE);
-                               if (packages != null) {
-                                       for (String packageName : 
packages.keySet()) {
-                                               if 
(!packageVersions.containsKey(packageName)) {
-                                                       
packageVersions.put(packageName, new HashSet<PackageVersion>());
-                                               }
-                                               Set<PackageVersion> versions = 
packageVersions.get(packageName);
-                                               VersionRange versionRange = 
getVersionRange(packages.get(packageName));
-                                               boolean optional = 
isOptional(packages.get(packageName));
-                                               if (unique) {
-                                                       // check if this 
version range is unique
-                                                       boolean uniqueVersion = 
true;
-                                                       for (PackageVersion 
version : versions) {
-                                                               if 
(equals(versionRange, version.getVersionRange())) {
-                                                                       
uniqueVersion = false;
-                                                                       break;
-                                                               }
-                                                       }
-                                                       if (uniqueVersion) {
-                                                               
versions.add(new PackageVersion(versionRange, artifact, optional));
-                                                       }
-                                               } else {
-                                                       versions.add(new 
PackageVersion(versionRange, artifact, optional));
-                                               }
-                                       }
-                               }
-                       }
-               }
-               return packageVersions;
-       }
-
-       public Version getVersion(Attrs attrs) {
-               if (attrs == null) {
-                       return Version.LOWEST;
-               }
-               return 
Version.parseVersion(attrs.get(Constants.VERSION_ATTRIBUTE));
-       }
-
-       public VersionRange getVersionRange(Attrs attrs) {
-               if (attrs == null) {
-                       return new VersionRange("0");
-               }
-               String version = attrs.get(Constants.VERSION_ATTRIBUTE);
-               if (version == null) {
-                       return new VersionRange("0");
-               }
-               return new VersionRange(version);
-       }
-
-       public boolean isBundle(Artifact artifact) {
-               return getManifestAttribute(artifact, 
Constants.BUNDLE_SYMBOLICNAME) != null;
-       }
-
-       public boolean isOptional(Attrs attrs) {
-               return attrs != null && 
"optional".equals(attrs.get(Constants.RESOLUTION_DIRECTIVE));
-       }
-
-       public boolean equals(VersionRange v1, VersionRange v2) {
-               return v1 == v2 || v1.toString().equals(v2.toString());
-       }
-
-       public Parameters getManifestAttributeParameters(Artifact artifact, 
String attributeName) {
-               String attributeValue = getManifestAttribute(artifact, 
attributeName);
-               if (attributeValue != null) {
-                       return OSGiHeader.parseHeader(attributeValue);
-               }
-               return null;
-       }
-
-       public String getManifestAttribute(Artifact artifact, String 
attributeName) {
-               Manifest manifest = getManifest(artifact);
-               if (manifest != null) {
-                       Attributes mainAttributes = 
manifest.getMainAttributes();
-                       return mainAttributes.getValue(attributeName);
-               }
-               return null;
-       }
-
-       public Manifest getManifest(Artifact artifact) {
-               if (artifact != null) {
-                       File file = artifact.getFile();
-                       if (file != null) {
-                               try {
-                                       JarFile jarFile = new 
JarFile(artifact.getFile());
-                                       return jarFile.getManifest();
-                               } catch (IOException e) {
-                                       return null;
-                               }
-                       }
-               }
-               return null;
-       }
-
-       private final class BundleComparator implements Comparator<BundleInfo> {
-
-               @Override
-               public int compare(BundleInfo bundle1, BundleInfo bundle2) {
-                       return 
bundle1.getSymbolicName().compareTo(bundle2.getSymbolicName());
-               }
-
-       }
-
-       // public static void main(String[] args) throws Exception {
-       // MavenOsgiUtils mavenOsgiUtils = new MavenOsgiUtils();
-       // Parameters exports = mavenOsgiUtils.getImports(new
-       // 
File("/Users/david/Documents/workspace-trunk/taverna-plugin-impl/target/taverna-plugin-impl-0.1.0-SNAPSHOT.jar"));
-       // for (String key : exports.keySet()) {
-       // System.out.println(key + " " + 
mavenOsgiUtils.getVersionRange(exports.get(key)));
-       // }
-       // }
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/c660ed5c/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/Package.java
----------------------------------------------------------------------
diff --git 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/Package.java
 
b/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/Package.java
deleted file mode 100644
index 5b06032..0000000
--- 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/Package.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 net.sf.taverna.t2.maven.plugins;
-
-import aQute.bnd.version.VersionRange;
-
-/**
- * @author David Withers
- */
-public class Package {
-
-       private String name;
-       private VersionRange versionRange;
-
-       public Package(String name, VersionRange versionRange) {
-               this.name = name;
-               this.versionRange = versionRange;
-       }
-
-       @Override
-       public String toString() {
-               if (versionRange == null) {
-                       return name;
-               } else {
-                       return name + ";version=\"" + versionRange + "\"";
-               }
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/c660ed5c/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/PackageVersion.java
----------------------------------------------------------------------
diff --git 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/PackageVersion.java
 
b/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/PackageVersion.java
deleted file mode 100644
index bac7c41..0000000
--- 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/PackageVersion.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 net.sf.taverna.t2.maven.plugins;
-
-import org.apache.maven.artifact.Artifact;
-
-import aQute.bnd.version.VersionRange;
-
-/**
- *
- *
- * @author David Withers
- */
-public class PackageVersion {
-
-       private VersionRange versionRange;
-       private Artifact artifact;
-       private boolean optional;
-
-       public PackageVersion(VersionRange versionRange, Artifact artifact) {
-               this(versionRange, artifact, false);
-       }
-
-       public PackageVersion(VersionRange versionRange, Artifact artifact, 
boolean optional) {
-               this.versionRange = versionRange;
-               this.artifact = artifact;
-               this.optional = optional;
-       }
-
-       @Override
-       public String toString() {
-               return versionRange + (optional ? "" : "") + "(from " + 
artifact.getId() + ")";
-       }
-
-       public VersionRange getVersionRange() {
-               return versionRange;
-       }
-
-       public void setVersionRange(VersionRange versionRange) {
-               this.versionRange = versionRange;
-       }
-
-       public Artifact getArtifact() {
-               return artifact;
-       }
-
-       public void setArtifact(Artifact artifact) {
-               this.artifact = artifact;
-       }
-
-       public boolean isOptional() {
-               return optional;
-       }
-
-       public void setOptional(boolean optional) {
-               this.optional = optional;
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/c660ed5c/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginDeployFileMojo.java
----------------------------------------------------------------------
diff --git 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginDeployFileMojo.java
 
b/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginDeployFileMojo.java
deleted file mode 100644
index 8e97a32..0000000
--- 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginDeployFileMojo.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 net.sf.taverna.t2.maven.plugins;
-
-import static 
net.sf.taverna.t2.maven.plugins.TavernaPluginGenerateMojo.META_INF_TAVERNA;
-import static 
net.sf.taverna.t2.maven.plugins.TavernaPluginGenerateMojo.PLUGIN_FILE;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.jar.JarFile;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipException;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.UnsupportedProtocolException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.observers.Debug;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.taverna.plugin.xml.jaxb.PluginInfo;
-import org.apache.taverna.plugin.xml.jaxb.PluginVersions;
-import org.apache.taverna.plugin.xml.jaxb.Plugins;
-import org.apache.taverna.versions.xml.jaxb.Version;
-
-/**
- * Deploys the Taverna plugin using <code>scp</code> or <code>file</code> 
protocol to the site URL
- * specified.
- *
- * @author David Withers
- */
-@Mojo(name = "plugin-deploy-file", requiresProject=false, 
requiresDirectInvocation = true)
-public class TavernaPluginDeployFileMojo extends AbstractWagonMojo {
-
-       private static final String PLUGIN_FILE_ENTRY = META_INF_TAVERNA + "/" 
+ PLUGIN_FILE;
-
-       private static final String PLUGINS_FILE = "plugins.xml";
-
-       @Parameter(defaultValue = 
"http://updates.taverna.org.uk/workbench/3.0/dev/";, required = true)
-       protected String site;
-
-       @Parameter(property = "file", required = true)
-       protected File file;
-
-       @Parameter(property = "url", required = true)
-       protected String url;
-
-       @Parameter(property = "serverId", required = true)
-       protected String serverId;
-
-       public void execute() throws MojoExecutionException {
-               if (!file.exists()) {
-                       throw new MojoExecutionException("The Taverna Plugin 
file " + file
-                                       + " does not exist");
-               }
-
-               JarFile pluginJarFile;
-               try {
-                       pluginJarFile = new JarFile(file);
-               } catch (ZipException e) {
-                       throw new MojoExecutionException(file + " is not a 
valid Taverna Plugin file", e);
-               } catch (IOException e) {
-                       throw new MojoExecutionException("Error opening Taverna 
Plugin file: " + file, e);
-               }
-
-               ZipEntry pluginFileEntry = 
pluginJarFile.getJarEntry(PLUGIN_FILE_ENTRY);
-               if (pluginFileEntry == null) {
-                       throw new MojoExecutionException(file
-                                       + " is not a valid Taverna Plugin file, 
missing " + PLUGIN_FILE_ENTRY);
-               }
-
-               JAXBContext jaxbContext;
-               try {
-                       jaxbContext = JAXBContext.newInstance(PluginInfo.class, 
Plugins.class);
-               } catch (JAXBException e) {
-                       throw new MojoExecutionException("Error setting up JAXB 
context ", e);
-               }
-
-               PluginInfo plugin;
-               try {
-                       InputStream inputStream = 
pluginJarFile.getInputStream(pluginFileEntry);
-                       Unmarshaller unmarshaller = 
jaxbContext.createUnmarshaller();
-                       plugin = (PluginInfo) 
unmarshaller.unmarshal(inputStream);
-                       inputStream.close();
-               } catch (IOException e) {
-                       throw new MojoExecutionException("Error reading " + 
file, e);
-               } catch (JAXBException e) {
-                       throw new MojoExecutionException("Error reading " + 
file, e);
-               }
-
-               getLog().debug("The Taverna plugin will be deployed to '" + url 
+ "'");
-
-               Repository repository = new Repository(serverId, url);
-
-               // create the wagon
-               Wagon wagon;
-               try {
-                       wagon = wagonManager.getWagon(repository.getProtocol());
-               } catch (UnsupportedProtocolException e) {
-                       throw new MojoExecutionException("Unsupported protocol: 
'" + repository.getProtocol()
-                                       + "'", e);
-               }
-
-               Debug debug = new Debug();
-               if (getLog().isDebugEnabled()) {
-                       wagon.addSessionListener(debug);
-                       wagon.addTransferListener(debug);
-               }
-
-               // connect to the plugin site
-               try {
-                       wagon.connect(repository, 
wagonManager.getAuthenticationInfo(serverId),
-                                       
wagonManager.getProxy(repository.getProtocol()));
-               } catch (ConnectionException e) {
-                       throw new MojoExecutionException("Error connecting to 
plugin site at " + url, e);
-               } catch (AuthenticationException e) {
-                       throw new MojoExecutionException("Authentication error 
connecting to plugin site at "
-                                       + url, e);
-               }
-
-               try {
-                       File pluginsFile = File.createTempFile("taverna", null);
-
-                       // fetch the plugins file
-                       Plugins plugins;
-                       try {
-                               Utils.downloadFile(PLUGINS_FILE, pluginsFile, 
wagon, getLog());
-                               try {
-                                       Unmarshaller unmarshaller = 
jaxbContext.createUnmarshaller();
-                                       plugins = (Plugins) 
unmarshaller.unmarshal(pluginsFile);
-                               } catch (JAXBException e) {
-                                       throw new MojoExecutionException("Error 
reading " + pluginsFile, e);
-                               }
-                       } catch (ResourceDoesNotExistException e) {
-                               getLog().info("Creating new plugins file");
-                               plugins = new Plugins();
-                       }
-
-                       String deployedPluginFile = plugin.getId() + "-" + 
plugin.getVersion() + ".jar";
-
-                       if (addPlugin(plugins, plugin, deployedPluginFile)) {
-                               // write the new plugin site file
-                               try {
-                                       Marshaller marshaller = 
jaxbContext.createMarshaller();
-                                       
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-                                       
marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,
-                                                       
TavernaPluginGenerateMojo.SCHEMA_LOCATION);
-                                       marshaller.marshal(plugins, 
pluginsFile);
-                               } catch (JAXBException e) {
-                                       throw new MojoExecutionException("Error 
writing " + PLUGINS_FILE, e);
-                               }
-
-                               // upload the plugin to the update site
-                               Utils.uploadFile(file, deployedPluginFile, 
wagon, getLog());
-                               // upload the plugin site file
-                               Utils.uploadFile(pluginsFile, PLUGINS_FILE, 
wagon, getLog());
-                       }
-               } catch (IOException e) {
-                       throw new MojoExecutionException("Error writing " + 
PLUGINS_FILE, e);
-               } finally {
-                       disconnectWagon(wagon, debug);
-               }
-       }
-
-       private boolean addPlugin(Plugins plugins, PluginInfo pluginInfo, 
String pluginURL) {
-               PluginVersions plugin = getPlugin(plugins, pluginInfo);
-               Version latestVersion = plugin.getLatestVersion();
-               if (latestVersion != null && 
latestVersion.getVersion().equals(pluginInfo.getVersion())) {
-                       getLog().error(
-                                       String.format("%1$s version %2$s has 
already been deployed",
-                                                       pluginInfo.getName(), 
pluginInfo.getVersion()));
-                       return false;
-               }
-               Version newPluginVersion = new Version();
-               newPluginVersion.setVersion(pluginInfo.getVersion());
-               newPluginVersion.setFile(pluginURL);
-
-               getLog().info(
-                               String.format("Adding %1$s version %2$s", 
pluginInfo.getName(),
-                                               pluginInfo.getVersion()));
-               if (plugin.getLatestVersion() != null) {
-                       
plugin.getPreviousVersion().add(plugin.getLatestVersion());
-               }
-               plugin.setLatestVersion(newPluginVersion);
-               return true;
-       }
-
-       private PluginVersions getPlugin(Plugins plugins, PluginInfo 
pluginInfo) {
-               PluginVersions pluginVersions = null;
-               for (PluginVersions existingPlugin : plugins.getPlugin()) {
-                       if (existingPlugin.getId().equals(pluginInfo.getId())) {
-                               pluginVersions = existingPlugin;
-                               break;
-                       }
-               }
-               if (pluginVersions == null) {
-                       pluginVersions = new PluginVersions();
-                       pluginVersions.setId(pluginInfo.getId());
-                       plugins.getPlugin().add(pluginVersions);
-               }
-               pluginVersions.setName(pluginInfo.getName());
-               pluginVersions.setDescription(pluginInfo.getDescription());
-               pluginVersions.setOrganization(pluginInfo.getOrganization());
-               return pluginVersions;
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/c660ed5c/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginDeployMojo.java
----------------------------------------------------------------------
diff --git 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginDeployMojo.java
 
b/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginDeployMojo.java
deleted file mode 100644
index 0141d71..0000000
--- 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginDeployMojo.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 net.sf.taverna.t2.maven.plugins;
-
-import java.io.File;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.UnsupportedProtocolException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.observers.Debug;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.taverna.plugin.xml.jaxb.PluginInfo;
-import org.apache.taverna.plugin.xml.jaxb.PluginVersions;
-import org.apache.taverna.plugin.xml.jaxb.Plugins;
-import org.apache.taverna.versions.xml.jaxb.Version;
-
-/**
- * Deploys the Taverna plugin using <code>scp</code> or <code>file</code> 
protocol to the site URL
- * specified in the <code>&lt;distributionManagement&gt;</code> section of the 
POM.
- *
- * @author David Withers
- */
-@Mojo(name = "plugin-deploy", defaultPhase = LifecyclePhase.DEPLOY)
-public class TavernaPluginDeployMojo extends AbstractDeployMojo {
-
-       private static final String PLUGINS_FILE = "plugins.xml";
-
-       private File tempDirectory;
-
-       public void execute() throws MojoExecutionException {
-               tempDirectory = new File(buildDirectory, 
TavernaProfileGenerateMojo.TAVERNA_TMP);
-               tempDirectory.mkdirs();
-               if (artifact == null) {
-                       throw new MojoExecutionException(
-                                       "The Taverna Plugin does not exist, 
please run taverna:plugin-generate first");
-               }
-
-               File artifactFile = artifact.getFile();
-               if (artifactFile == null) {
-                       throw new MojoExecutionException(
-                                       "The Taverna Plugin does not exist, 
please run taverna:plugin-generate first");
-               }
-
-               File pluginDirectory = new File(outputDirectory, 
TavernaPluginGenerateMojo.META_INF_TAVERNA);
-               File pluginFile = new File(pluginDirectory, 
TavernaPluginGenerateMojo.PLUGIN_FILE);
-               if (!pluginFile.exists()) {
-                       throw new MojoExecutionException(
-                                       "The Taverna Plugin does not exist, 
please run taverna:plugin-generate first");
-               }
-
-               JAXBContext jaxbContext;
-               try {
-                       jaxbContext = JAXBContext.newInstance(PluginInfo.class, 
Plugins.class);
-               } catch (JAXBException e) {
-                       throw new MojoExecutionException("Error setting up JAXB 
context ", e);
-               }
-
-               PluginInfo plugin;
-               try {
-                       Unmarshaller unmarshaller = 
jaxbContext.createUnmarshaller();
-                       plugin = (PluginInfo) 
unmarshaller.unmarshal(pluginFile);
-               } catch (JAXBException e) {
-                       throw new MojoExecutionException("Error reading " + 
pluginFile, e);
-               }
-
-               if (deploymentRepository == null) {
-                       throw new MojoExecutionException(
-                                       "Missing repository information in the 
distribution management element in the project.");
-               }
-
-               String url = deploymentRepository.getUrl();
-               String id = deploymentRepository.getId();
-
-               if (url == null) {
-                       throw new MojoExecutionException(
-                                       "The URL to the Taverna plugin site is 
missing in the project descriptor.");
-               }
-               getLog().debug("The Taverna plugin will be deployed to '" + url 
+ "'");
-
-               Repository repository = new Repository(id, url);
-
-               // create the wagon
-               Wagon wagon;
-               try {
-                       wagon = wagonManager.getWagon(repository.getProtocol());
-               } catch (UnsupportedProtocolException e) {
-                       throw new MojoExecutionException("Unsupported protocol: 
'" + repository.getProtocol()
-                                       + "'", e);
-               }
-
-               Debug debug = new Debug();
-               if (getLog().isDebugEnabled()) {
-                       wagon.addSessionListener(debug);
-                       wagon.addTransferListener(debug);
-               }
-
-               // connect to the plugin site
-               try {
-                       wagon.connect(repository, 
wagonManager.getAuthenticationInfo(id),
-                                       
wagonManager.getProxy(repository.getProtocol()));
-               } catch (ConnectionException e) {
-                       throw new MojoExecutionException("Error connecting to 
plugin site at " + url, e);
-               } catch (AuthenticationException e) {
-                       throw new MojoExecutionException("Authentication error 
connecting to plugin site at "
-                                       + url, e);
-               }
-
-               try {
-                       String deployedPluginFile = project.getGroupId() + "." 
+ project.getArtifactId() + "-"
-                                       + plugin.getVersion() + ".jar";
-
-                       // fetch the plugins file
-                       Plugins plugins;
-                       File pluginsFile = new File(tempDirectory, 
PLUGINS_FILE);
-                       try {
-                               Utils.downloadFile(PLUGINS_FILE, pluginsFile, 
wagon, getLog());
-                               try {
-                                       Unmarshaller unmarshaller = 
jaxbContext.createUnmarshaller();
-                                       plugins = (Plugins) 
unmarshaller.unmarshal(pluginsFile);
-                               } catch (JAXBException e) {
-                                       throw new MojoExecutionException("Error 
reading " + pluginsFile, e);
-                               }
-                       } catch (ResourceDoesNotExistException e) {
-                               getLog().info("Creating new plugins file");
-                               plugins = new Plugins();
-                       }
-
-                       if (addPlugin(plugins, plugin, deployedPluginFile)) {
-                               // write the new plugin site file
-                               try {
-                                       Marshaller marshaller = 
jaxbContext.createMarshaller();
-                                       
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-                                       
marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,
-                                                       
TavernaPluginGenerateMojo.SCHEMA_LOCATION);
-                                       marshaller.marshal(plugins, 
pluginsFile);
-                               } catch (JAXBException e) {
-                                       throw new MojoExecutionException("Error 
writing " + PLUGINS_FILE, e);
-                               }
-
-                               // upload the plugin to the update site
-                               Utils.uploadFile(artifactFile, 
deployedPluginFile, wagon, getLog());
-                               // upload the plugin site file
-                               Utils.uploadFile(pluginsFile, PLUGINS_FILE, 
wagon, getLog());
-                       }
-               } finally {
-                       disconnectWagon(wagon, debug);
-               }
-       }
-
-       private boolean addPlugin(Plugins plugins, PluginInfo pluginInfo, 
String pluginURL) {
-               PluginVersions plugin = getPlugin(plugins, pluginInfo);
-               Version latestVersion = plugin.getLatestVersion();
-               if (latestVersion != null && 
latestVersion.getVersion().equals(pluginInfo.getVersion())) {
-                       getLog().error(
-                                       String.format("%1$s version %2$s has 
already been deployed", pluginInfo.getName(),
-                                                       
pluginInfo.getVersion()));
-                       return false;
-               }
-               Version newPluginVersion = new Version();
-               newPluginVersion.setVersion(pluginInfo.getVersion());
-               newPluginVersion.setFile(pluginURL);
-
-               getLog().info(
-                               String.format("Adding %1$s version %2$s", 
pluginInfo.getName(), pluginInfo.getVersion()));
-               if (plugin.getLatestVersion() != null) {
-                       
plugin.getPreviousVersion().add(plugin.getLatestVersion());
-               }
-               plugin.setLatestVersion(newPluginVersion);
-               return true;
-       }
-
-       private PluginVersions getPlugin(Plugins plugins, PluginInfo 
pluginInfo) {
-               PluginVersions pluginVersions = null;
-               for (PluginVersions existingPlugin : plugins.getPlugin()) {
-                       if (existingPlugin.getId().equals(pluginInfo.getId())) {
-                               pluginVersions = existingPlugin;
-                               break;
-                       }
-               }
-               if (pluginVersions == null) {
-                       pluginVersions = new PluginVersions();
-                       pluginVersions.setId(pluginInfo.getId());
-                       plugins.getPlugin().add(pluginVersions);
-               }
-               pluginVersions.setName(pluginInfo.getName());
-               pluginVersions.setDescription(pluginInfo.getDescription());
-               pluginVersions.setOrganization(pluginInfo.getOrganization());
-               return pluginVersions;
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/c660ed5c/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginGenerateMojo.java
----------------------------------------------------------------------
diff --git 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginGenerateMojo.java
 
b/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginGenerateMojo.java
deleted file mode 100644
index d2162fe..0000000
--- 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginGenerateMojo.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 net.sf.taverna.t2.maven.plugins;
-
-import java.io.File;
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.model.Organization;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.ProjectDependenciesResolver;
-import org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter;
-import org.apache.maven.shared.osgi.Maven2OsgiConverter;
-import org.apache.taverna.plugin.xml.jaxb.PluginInfo;
-import org.apache.taverna.profile.xml.jaxb.BundleInfo;
-import org.eclipse.aether.RepositorySystemSession;
-
-/**
- * Generates a Taverna plugin definition file.
- *
- * @author David Withers
- */
-@Mojo(name = "plugin-generate", defaultPhase = 
LifecyclePhase.GENERATE_RESOURCES, requiresDependencyResolution = 
ResolutionScope.RUNTIME)
-public class TavernaPluginGenerateMojo extends AbstractMojo {
-
-       public static final String PLUGIN_FILE = "plugin.xml";
-
-       public static final String META_INF_TAVERNA = "META-INF/taverna";
-
-       public static final String SCHEMA_LOCATION = 
"http://ns.taverna.org.uk/2013/application/plugin 
http://localhost/2013/application/plugin/ApplicationPlugin.xsd";;
-
-       @Component
-       private MavenProject project;
-
-       @Component
-       private ProjectDependenciesResolver projectDependenciesResolver;
-
-    @Parameter(defaultValue = "${repositorySystemSession}", readonly = true)
-       private RepositorySystemSession repositorySystemSession;
-
-       @Parameter(defaultValue = "${project.build.outputDirectory}", required 
= true)
-       protected File outputDirectory;
-
-       @Parameter(defaultValue = "${project.description}", required = true)
-       protected String description;
-
-       @Parameter(defaultValue = "${project.organization}", required = true)
-       protected Organization organization;
-
-       private MavenOsgiUtils osgiUtils;
-
-       private Maven2OsgiConverter maven2OsgiConverter = new 
DefaultMaven2OsgiConverter();
-
-       public void execute() throws MojoExecutionException, 
MojoFailureException {
-               try {
-                       osgiUtils = new MavenOsgiUtils(project, 
repositorySystemSession,
-                                       projectDependenciesResolver, getLog());
-                       createPluginDefinition();
-               } catch (JAXBException e) {
-                       throw new MojoExecutionException("Error generating 
Taverna plugin", e);
-               }
-       }
-
-       /**
-        * Generates the Taverna plugin definition file.
-        *
-        * @return the <code>File</code> that the Taverna plugin definition has 
been written to
-        * @throws JAXBException
-        * @throws MojoExecutionException
-        */
-       private File createPluginDefinition() throws JAXBException, 
MojoExecutionException {
-               String groupId = project.getGroupId();
-               String artifactId = project.getArtifactId();
-               String version = 
maven2OsgiConverter.getVersion(project.getVersion());
-               if (version.endsWith("SNAPSHOT")) {
-                       version = version.substring(0, 
version.indexOf("SNAPSHOT")) + Utils.timestamp();
-               }
-
-               File pluginDirectory = new File(outputDirectory, 
META_INF_TAVERNA);
-               pluginDirectory.mkdirs();
-               File pluginFile = new File(pluginDirectory, PLUGIN_FILE);
-
-               PluginInfo pluginInfo = new PluginInfo();
-               pluginInfo.setId(groupId + "." + artifactId);
-               pluginInfo.setName(project.getName());
-               pluginInfo.setVersion(version);
-               pluginInfo.setDescription(description);
-               pluginInfo.setOrganization(organization.getName());
-
-               Set<BundleArtifact> bundleDependencies = 
osgiUtils.getBundleDependencies(
-                               Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME);
-
-               List<BundleInfo> runtimeBundles = 
osgiUtils.getBundles(bundleDependencies);
-               if (!runtimeBundles.isEmpty()) {
-                       List<BundleInfo> bundles = pluginInfo.getBundle();
-                       for (BundleInfo bundle : runtimeBundles) {
-                               bundles.add(bundle);
-                       }
-               }
-
-               JAXBContext jaxbContext = 
JAXBContext.newInstance(PluginInfo.class);
-               Marshaller marshaller = jaxbContext.createMarshaller();
-               marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, 
Boolean.TRUE);
-               marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, 
SCHEMA_LOCATION);
-               marshaller.marshal(pluginInfo, pluginFile);
-
-               return pluginFile;
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/c660ed5c/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginPrepareBundlesMojo.java
----------------------------------------------------------------------
diff --git 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginPrepareBundlesMojo.java
 
b/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginPrepareBundlesMojo.java
deleted file mode 100644
index 66f08ad..0000000
--- 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginPrepareBundlesMojo.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 net.sf.taverna.t2.maven.plugins;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Set;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.ProjectDependenciesResolver;
-import org.eclipse.aether.RepositorySystemSession;
-
-/**
- * Prepares the plugin OSGi bundles.
- *
- * @author David Withers
- */
-@Mojo(name = "plugin-prepare-bundles", defaultPhase = 
LifecyclePhase.PREPARE_PACKAGE, requiresDependencyResolution = 
ResolutionScope.RUNTIME)
-public class TavernaPluginPrepareBundlesMojo extends AbstractMojo {
-
-       @Component
-       private MavenProject project;
-
-       @Component
-       private ProjectDependenciesResolver projectDependenciesResolver;
-
-       @Parameter(defaultValue = "${repositorySystemSession}", readonly = true)
-       private RepositorySystemSession repositorySystemSession;
-
-       /**
-        * The directory where the plugin OSGi bundles file will be put.
-        */
-       @Parameter(defaultValue = "${project.build.outputDirectory}", required 
= true)
-       protected File outputDirectory;
-
-       private MavenOsgiUtils osgiUtils;
-
-       public void execute() throws MojoExecutionException, 
MojoFailureException {
-               osgiUtils = new MavenOsgiUtils(project, repositorySystemSession,
-                               projectDependenciesResolver, getLog());
-               outputDirectory.mkdirs();
-
-               Set<BundleArtifact> bundleDependencies = 
osgiUtils.getBundleDependencies(
-                               Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME);
-               try {
-                       for (BundleArtifact bundleArtifact : 
bundleDependencies) {
-                               Artifact artifact = 
bundleArtifact.getArtifact();
-                               
FileUtils.copyFileToDirectory(bundleArtifact.getArtifact().getFile(), new File(
-                                               outputDirectory, 
artifact.getGroupId()));
-                       }
-               } catch (IOException e) {
-                       throw new MojoExecutionException("Error copying 
dependecies to archive directory", e);
-               }
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/c660ed5c/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaProfileDeployMojo.java
----------------------------------------------------------------------
diff --git 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaProfileDeployMojo.java
 
b/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaProfileDeployMojo.java
deleted file mode 100644
index d2f9d75..0000000
--- 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaProfileDeployMojo.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 net.sf.taverna.t2.maven.plugins;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.UnsupportedProtocolException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.observers.Debug;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.taverna.profile.xml.jaxb.ApplicationProfile;
-import org.apache.taverna.profile.xml.jaxb.BundleInfo;
-import org.apache.taverna.profile.xml.jaxb.UpdateSite;
-import org.apache.taverna.versions.xml.jaxb.Version;
-import org.apache.taverna.versions.xml.jaxb.Versions;
-
-/**
- * Deploys the application profile using <code>scp</code> or <code>file</code> 
protocol to the site
- * URL specified in the <code>&lt;distributionManagement&gt;</code> section of 
the POM.
- *
- * @author David Withers
- */
-@Mojo(name = "profile-deploy", defaultPhase = LifecyclePhase.DEPLOY)
-public class TavernaProfileDeployMojo extends AbstractDeployMojo {
-
-       private static final String UPDATES_FILE = "updates.xml";
-
-       private File tempDirectory;
-
-       public void execute() throws MojoExecutionException {
-               tempDirectory = new File(buildDirectory, 
TavernaProfileGenerateMojo.TAVERNA_TMP);
-               tempDirectory.mkdirs();
-               if (artifact == null) {
-                       throw new MojoExecutionException(
-                                       "The application profile does not 
exist, please run taverna:profile-generate first");
-               }
-
-               File artifactFile = artifact.getFile();
-               if (artifactFile == null) {
-                       throw new MojoExecutionException(
-                                       "The application profile does not 
exist, please run taverna:profile-generate first");
-               }
-
-               JAXBContext jaxbContext;
-               try {
-                       jaxbContext = 
JAXBContext.newInstance(ApplicationProfile.class, UpdateSite.class);
-               } catch (JAXBException e) {
-                       throw new MojoExecutionException("Error setting up JAXB 
context ", e);
-               }
-
-               ApplicationProfile applicationProfile;
-               try {
-                       Unmarshaller unmarshaller = 
jaxbContext.createUnmarshaller();
-                       applicationProfile = (ApplicationProfile) 
unmarshaller.unmarshal(artifactFile);
-               } catch (JAXBException e) {
-                       throw new MojoExecutionException("Error reading " + 
artifactFile, e);
-               }
-
-               if (deploymentRepository == null) {
-                       throw new MojoExecutionException(
-                                       "Missing repository information in the 
distribution management element in the project.");
-               }
-
-               String url = deploymentRepository.getUrl();
-               String id = deploymentRepository.getId();
-
-               if (url == null) {
-                       throw new MojoExecutionException(
-                                       "The URL to the update site is missing 
in the project descriptor.");
-               }
-               getLog().debug("The Taverna application will be deployed to '" 
+ url + "'");
-
-               Repository repository = new Repository(id, url);
-
-               // create the wagon
-               Wagon wagon;
-               try {
-                       wagon = wagonManager.getWagon(repository.getProtocol());
-               } catch (UnsupportedProtocolException e) {
-                       throw new MojoExecutionException("Unsupported protocol: 
'" + repository.getProtocol()
-                                       + "'", e);
-               }
-
-               Debug debug = new Debug();
-               if (getLog().isDebugEnabled()) {
-                       wagon.addSessionListener(debug);
-                       wagon.addTransferListener(debug);
-               }
-
-               // connect to the update site
-               try {
-                       wagon.connect(repository, 
wagonManager.getAuthenticationInfo(id),
-                                       
wagonManager.getProxy(repository.getProtocol()));
-               } catch (ConnectionException e) {
-                       throw new MojoExecutionException("Error connecting to " 
+ url, e);
-               } catch (AuthenticationException e) {
-                       throw new MojoExecutionException("Authentication error 
connecting to " + url, e);
-               }
-
-               try {
-                       // upload the application profile to the update site
-                       String deployedProfileFile = "ApplicationProfile" + "-" 
+ applicationProfile.getVersion()
-                                       + ".xml";
-                       Utils.uploadFile(artifactFile, deployedProfileFile, 
wagon, getLog());
-
-                       // fetch the applications file
-                       UpdateSite updateSite;
-                       File updatesFile = new File(tempDirectory, 
UPDATES_FILE);
-                       try {
-                               Utils.downloadFile(UPDATES_FILE, updatesFile, 
wagon, getLog());
-                               try {
-                                       Unmarshaller unmarshaller = 
jaxbContext.createUnmarshaller();
-                                       updateSite = (UpdateSite) unmarshaller
-                                                       .unmarshal(updatesFile);
-                               } catch (JAXBException e) {
-                                       throw new MojoExecutionException("Error 
reading " + updatesFile, e);
-                               }
-                       } catch(ResourceDoesNotExistException e) {
-                               getLog().info("Creating new application 
versions file");
-                               updateSite = new UpdateSite();
-                               Versions versions = new Versions();
-                               versions.setId(applicationProfile.getId());
-                               versions.setName(applicationProfile.getName());
-                               updateSite.setVersions(versions);
-                       }
-
-                       Version latestVersion = 
updateSite.getVersions().getLatestVersion();
-                       if (latestVersion != null) {
-                               File latestProfileFile = new 
File(tempDirectory, "ApplicationProfile-" + latestVersion.getVersion()
-                                               + ".xml");
-                               try {
-                                       
Utils.downloadFile(latestVersion.getFile(), latestProfileFile, wagon, getLog());
-                               } catch (ResourceDoesNotExistException e) {
-                                       throw new 
MojoExecutionException(latestVersion.getFile() + " does not exist", e);
-                               }
-                               ApplicationProfile latestProfile;
-                               try {
-                                       Unmarshaller unmarshaller = 
jaxbContext.createUnmarshaller();
-                                       latestProfile = (ApplicationProfile) 
unmarshaller.unmarshal(latestProfileFile);
-                               } catch (JAXBException e) {
-                                       throw new MojoExecutionException("Error 
reading " + latestProfileFile, e);
-                               }
-                               Set<BundleInfo> requiredBundles = 
getRequiredBundles(latestProfile, applicationProfile);
-                               if (requiredBundles.isEmpty()) {
-                                       getLog().warn("No new bundles to 
upload");
-                               } else {
-                                       // upload new bundles to the update site
-                                       uploadBundles(requiredBundles, wagon);
-                               }
-                       }
-
-                       if (addApplicationVersion(updateSite.getVersions(), 
applicationProfile,
-                                       deployedProfileFile)) {
-                               // write the new application versions list
-                               try {
-                                       Marshaller marshaller = 
jaxbContext.createMarshaller();
-                                       
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-                                       
marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, 
TavernaProfileGenerateMojo.SCHEMA_LOCATION);
-                                       marshaller.marshal(updateSite, 
updatesFile);
-                               } catch (JAXBException e) {
-                                       throw new MojoExecutionException("Error 
writing " + UPDATES_FILE, e);
-                               }
-
-                               // upload the new application versions list to 
the update site
-                               Utils.uploadFile(updatesFile, UPDATES_FILE, 
wagon, getLog());
-                       }
-               }
-               finally {
-                       disconnectWagon(wagon, debug);
-               }
-       }
-
-       /**
-        * Adds an new application version to the application versions if the 
version doesn't already
-        * exist.
-        *
-        * @param applicationVersions
-        *            the ApplicationVersions document
-        * @param applicationProfile
-        *            the applicationProfile
-        * @param profileURL
-        * @return true if a new version was added to the ApplicationVersions 
document; false if the
-        *         version already exits
-        */
-       private boolean addApplicationVersion(Versions applicationVersions,
-                       ApplicationProfile applicationProfile, String 
profileURL) {
-               Version latestVersion = applicationVersions.getLatestVersion();
-               if (latestVersion != null
-                               && 
latestVersion.getVersion().equals(applicationProfile.getVersion())) {
-                       getLog().error(
-                                       String.format("%1$s version %2$s has 
already been deployed",
-                                                       
applicationProfile.getName(), applicationProfile.getVersion()));
-                       return false;
-               }
-
-               Version newApplicationVersion = new Version();
-               
newApplicationVersion.setVersion(applicationProfile.getVersion());
-               newApplicationVersion.setFile(profileURL);
-
-               getLog().info(
-                               String.format("Adding %1$s version %2$s", 
applicationProfile.getName(),
-                                               
applicationProfile.getVersion()));
-               if (applicationVersions.getLatestVersion() != null) {
-                       
applicationVersions.getPreviousVersion().add(applicationVersions.getLatestVersion());
-               }
-               applicationVersions.setLatestVersion(newApplicationVersion);
-               return true;
-       }
-
-       /**
-        * @param requiredBundles
-        * @throws MojoExecutionException
-        */
-       private void uploadBundles(Set<BundleInfo> requiredBundles, Wagon 
wagon) throws MojoExecutionException {
-               File libDirectory = new File(tempDirectory, "lib");
-               for (BundleInfo bundle : requiredBundles) {
-                       Utils.uploadFile(new File(libDirectory, 
bundle.getFileName()), "lib/" + bundle.getFileName(), wagon, getLog());
-               }
-       }
-
-       private Set<BundleInfo> getRequiredBundles(ApplicationProfile 
currentProfile,
-                       ApplicationProfile newProfile) {
-               Set<BundleInfo> requiredBundles = new HashSet<BundleInfo>();
-               Map<String, BundleInfo> currentBundles = new HashMap<String, 
BundleInfo>();
-               for (BundleInfo bundle : currentProfile.getBundle()) {
-                       currentBundles.put(bundle.getSymbolicName(), bundle);
-               }
-               for (BundleInfo bundle : newProfile.getBundle()) {
-                       if 
(currentBundles.containsKey(bundle.getSymbolicName())) {
-                               BundleInfo currentBundle = 
currentBundles.get(bundle.getSymbolicName());
-                               if 
(!bundle.getVersion().equals(currentBundle.getVersion())) {
-                                       requiredBundles.add(bundle);
-                               }
-                       } else {
-                               requiredBundles.add(bundle);
-                       }
-               }
-               return requiredBundles;
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/c660ed5c/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaProfileGenerateMojo.java
----------------------------------------------------------------------
diff --git 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaProfileGenerateMojo.java
 
b/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaProfileGenerateMojo.java
deleted file mode 100644
index 879885e..0000000
--- 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaProfileGenerateMojo.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 net.sf.taverna.t2.maven.plugins;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.Component;
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.ProjectDependenciesResolver;
-import org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter;
-import org.apache.maven.shared.osgi.Maven2OsgiConverter;
-import org.apache.taverna.profile.xml.jaxb.ApplicationProfile;
-import org.apache.taverna.profile.xml.jaxb.BundleInfo;
-import org.apache.taverna.profile.xml.jaxb.FrameworkConfiguration;
-import org.apache.taverna.profile.xml.jaxb.Updates;
-import org.eclipse.aether.RepositorySystemSession;
-
-/**
- * Generates an application profile file.
- *
- * @author David Withers
- */
-@Mojo(name = "profile-generate", defaultPhase = 
LifecyclePhase.GENERATE_RESOURCES, requiresDependencyResolution = 
ResolutionScope.RUNTIME)
-public class TavernaProfileGenerateMojo extends AbstractMojo {
-
-       public static final String SYSTEM_PACKAGES = 
"org.osgi.framework.system.packages.extra";
-
-       public static final String SCHEMA_LOCATION = 
"http://ns.taverna.org.uk/2013/application/profile 
http://localhost/2013/application/profile/ApplicationProfile.xsd";;
-
-       public static final String TAVERNA_TMP = "taverna-tmp";
-
-       public static final String APPLICATION_PROFILE_FILE = 
"ApplicationProfile.xml";
-
-       @Component
-       private MavenProject project;
-
-       @Component
-       private ProjectDependenciesResolver projectDependenciesResolver;
-
-       @Parameter(defaultValue = "${repositorySystemSession}", readonly = true)
-       private RepositorySystemSession repositorySystemSession;
-
-       /**
-        * The directory where the generated 
<code>ApplicationProfile.xml</code> file will be put.
-        */
-       @Parameter(defaultValue = "${project.build.directory}", required = true)
-       protected File outputDirectory;
-
-       @Parameter(defaultValue = "SNAPSHOT")
-       private String buildNumber;
-
-       @Parameter
-       private List<FrameworkConfiguration> frameworkConfigurations;
-
-       @Parameter(required = true)
-       private String updateSite;
-
-       @Parameter(defaultValue = "updates.xml")
-       private String updatesFile;
-
-       @Parameter(defaultValue = "lib")
-       private String libDirectory;
-
-       @Parameter(required = true)
-       private String pluginSite;
-
-       @Parameter(defaultValue = "plugins.xml")
-       private String pluginsFile;
-
-       private Maven2OsgiConverter maven2OsgiConverter = new 
DefaultMaven2OsgiConverter();
-
-       private MavenOsgiUtils osgiUtils;
-
-       private File tempDirectory;
-
-       public void execute() throws MojoExecutionException, 
MojoFailureException {
-               try {
-                       osgiUtils = new MavenOsgiUtils(project, 
repositorySystemSession,
-                                       projectDependenciesResolver, 
getSystemPackages(), getLog());
-                       tempDirectory = new File(outputDirectory, TAVERNA_TMP);
-
-                       File profileFile = createApplicationProfile();
-                       project.getArtifact().setFile(profileFile);
-
-                       copyDependencies();
-
-               } catch (JAXBException e) {
-                       throw new MojoExecutionException("Error generating 
application profile", e);
-               }
-       }
-
-       private void copyDependencies() throws MojoExecutionException {
-               File libDirectory = new File(tempDirectory, "lib");
-               libDirectory.mkdirs();
-
-               try {
-                       for (Artifact artifact : project.getArtifacts()) {
-                               
FileUtils.copyFileToDirectory(artifact.getFile(),
-                                               new File(libDirectory, 
artifact.getGroupId()));
-                       }
-               } catch (IOException e) {
-                       throw new MojoExecutionException("Error copying 
dependecies to lib directory", e);
-               }
-
-       }
-
-       /**
-        * Generates the application profile file.
-        *
-        * @return the <code>File</code> that the application profile has been 
written to
-        * @throws JAXBException
-        *             if the application profile cannot be created
-        * @throws MojoExecutionException
-        */
-       private File createApplicationProfile() throws JAXBException, 
MojoExecutionException {
-               String groupId = project.getGroupId();
-               String artifactId = project.getArtifactId();
-               String version = 
maven2OsgiConverter.getVersion(project.getVersion());
-               if (version.endsWith("SNAPSHOT")) {
-                       version = version.substring(0, 
version.indexOf("SNAPSHOT")) + buildNumber;
-               }
-
-               tempDirectory.mkdirs();
-               File applicationProfileFile = new File(tempDirectory, 
APPLICATION_PROFILE_FILE);
-
-               ApplicationProfile applicationProfile = new 
ApplicationProfile();
-               applicationProfile.setId(groupId + "." + artifactId);
-               applicationProfile.setName(project.getName());
-               applicationProfile.setVersion(version);
-
-               Updates updates = new Updates();
-               updates.setUpdateSite(updateSite);
-               updates.setUpdatesFile(updatesFile);
-               updates.setLibDirectory(libDirectory);
-               updates.setPluginSite(pluginSite);
-               updates.setPluginsFile(pluginsFile);
-               applicationProfile.setUpdates(updates);
-
-               List<FrameworkConfiguration> frameworkConfiguration = 
applicationProfile
-                               .getFrameworkConfiguration();
-               for (FrameworkConfiguration configuration : 
frameworkConfigurations) {
-                       frameworkConfiguration.add(configuration);
-               }
-
-               Set<BundleArtifact> bundleDependencies = 
osgiUtils.getBundleDependencies(
-                               Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME);
-               List<BundleInfo> runtimeBundles = 
osgiUtils.getBundles(bundleDependencies);
-               if (!runtimeBundles.isEmpty()) {
-                       List<BundleInfo> bundles = 
applicationProfile.getBundle();
-                       for (BundleInfo bundle : runtimeBundles) {
-                               bundles.add(bundle);
-                       }
-               }
-
-               JAXBContext jaxbContext = 
JAXBContext.newInstance(ApplicationProfile.class);
-               Marshaller marshaller = jaxbContext.createMarshaller();
-               marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, 
Boolean.TRUE);
-               marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, 
SCHEMA_LOCATION);
-               marshaller.marshal(applicationProfile, applicationProfileFile);
-
-               return applicationProfileFile;
-       }
-
-       private Set<String> getSystemPackages() {
-               Set<String> systemPackages = new HashSet<String>();
-               if (frameworkConfigurations != null) {
-                       for (FrameworkConfiguration configuration : 
frameworkConfigurations) {
-                               if 
(SYSTEM_PACKAGES.equals(configuration.getName())) {
-                                       String packagesString = 
configuration.getValue();
-                                       if (packagesString != null) {
-                                               String[] packages = 
packagesString.split(",");
-                                               for (String packageString : 
packages) {
-                                                       String[] 
packageProperties = packageString.split(";");
-                                                       if 
(packageProperties.length > 0) {
-                                                               
systemPackages.add(packageProperties[0]);
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               }
-               return systemPackages;
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/c660ed5c/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/Utils.java
----------------------------------------------------------------------
diff --git 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/Utils.java 
b/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/Utils.java
deleted file mode 100644
index a1c8395..0000000
--- 
a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/Utils.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 net.sf.taverna.t2.maven.plugins;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URLEncoder;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.io.FileUtils;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-
-/**
- * @author David Withers
- */
-public class Utils {
-
-       public static String uploadFile(File file, String resourceName, Wagon 
wagon, Log log)
-                       throws MojoExecutionException {
-               String resourceUrl = getResourceUrl(wagon, resourceName);
-               File digestFile = new File(file.getPath() + ".md5");
-               try {
-                       String digestString = DigestUtils.md5Hex(new 
FileInputStream(file));
-                       FileUtils.writeStringToFile(digestFile, digestString);
-               } catch (IOException e) {
-                       throw new MojoExecutionException(
-                                       String.format("Error generating digest 
for %1$s", file), e);
-               }
-               try {
-                       log.info(String.format("Uploading %1$s to %2$s", file, 
resourceUrl));
-                       wagon.put(file, resourceName);
-                       wagon.put(digestFile, resourceName + ".md5");
-               } catch (TransferFailedException e) {
-                       throw new MojoExecutionException(String.format("Error 
transferring %1$s to %2$s", file,
-                                       resourceUrl), e);
-               } catch (ResourceDoesNotExistException e) {
-                       throw new MojoExecutionException(String.format("%1$s 
does not exist", resourceUrl), e);
-               } catch (AuthorizationException e) {
-                       throw new MojoExecutionException(String.format(
-                                       "Authentication error transferring %1$s 
to %2$s", file, resourceUrl), e);
-               }
-               return resourceUrl;
-       }
-
-       public static void downloadFile(String resourceName, File file, Wagon 
wagon, Log log)
-                       throws MojoExecutionException, 
ResourceDoesNotExistException {
-               String resourceUrl = getResourceUrl(wagon, resourceName);
-               File digestFile = new File(file.getPath() + ".md5");
-               try {
-                       log.info(String.format("Downloading %1$s to %2$s", 
resourceUrl, file));
-                       wagon.get(resourceName, file);
-                       wagon.get(resourceName + ".md5", digestFile);
-               } catch (TransferFailedException e) {
-                       throw new MojoExecutionException(String.format("Error 
transferring %1$s to %2$s",
-                                       resourceUrl, file), e);
-               } catch (AuthorizationException e) {
-                       throw new MojoExecutionException(String.format(
-                                       "Authentication error transferring %1$s 
to %2$s", resourceUrl, file), e);
-               }
-               try {
-                       String digestString1 = DigestUtils.md5Hex(new 
FileInputStream(file));
-                       String digestString2 = 
FileUtils.readFileToString(digestFile);
-                       if (!digestString1.equals(digestString2)) {
-                               throw new MojoExecutionException(String.format(
-                                               "Error downloading file: 
digsests not equal. (%1$s != %2$s)",
-                                               digestString1, digestString2));
-                       }
-               } catch (IOException e) {
-                       throw new MojoExecutionException(String.format("Error 
checking digest for %1$s", file),
-                                       e);
-               }
-       }
-
-       public static String getResourceUrl(Wagon wagon, String resourceName) {
-               StringBuilder urlBuilder = new 
StringBuilder(wagon.getRepository().getUrl());
-               for (String part : resourceName.split("/")) {
-                       urlBuilder.append('/');
-                       urlBuilder.append(URLEncoder.encode(part));
-               }
-               return urlBuilder.toString();
-       }
-
-       public static String timestamp() {
-               SimpleDateFormat dateFormat = new 
SimpleDateFormat("yyyyMMdd'T'HHmm");
-               return dateFormat.format(new Date());
-       }
-
-       public static Set<String> getJavaPackages(Log log) {
-               Set<String> javaPackages = new HashSet<String>();
-               InputStream resource = 
Utils.class.getClassLoader().getResourceAsStream("java7-packages");
-               if (resource != null) {
-                       BufferedReader reader = new BufferedReader(new 
InputStreamReader(resource));
-                       try {
-                               String line = reader.readLine();
-                               while (line != null) {
-                                       if (!line.isEmpty() && ! 
line.startsWith("#")) {
-                                               javaPackages.add(line.trim());
-                                       }
-                                       line = reader.readLine();
-                               }
-                       } catch (IOException e) {
-                               log.warn(
-                                               "Problem while reading to 
readinf java package list from resource file java7-packages",
-                                               e);
-                       }
-               } else {
-                       log.warn("Unable to read java package list from 
resource file java7-packages");
-               }
-               return javaPackages;
-       }
-
-       public static <T> List<Set<T>> getSubsets(Set<T> set) {
-               List<Set<T>> subsets = new ArrayList<Set<T>>();
-        List<T> list = new ArrayList<T>(set);
-               int numOfSubsets = 1 << set.size();
-               for (int i = 0; i < numOfSubsets; i++){
-                       Set<T> subset = new HashSet<T>();
-                   for (int j = 0; j < numOfSubsets; j++){
-                       if (((i>>j) & 1) == 1) {
-                           subset.add(list.get(j));
-                       }
-                   }
-                   if (!subset.isEmpty()) {
-                       subsets.add(subset);
-                   }
-               }
-               Collections.sort(subsets, new Comparator<Set<T>>() {
-                       @Override
-                       public int compare(Set<T> o1, Set<T> o2) {
-                               return o1.size() - o2.size();
-                       }
-               });
-               return subsets;
-       }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/c660ed5c/taverna-maven-plugin/src/main/java/org/apache/taverna/mavenplugin/AbstractDeployMojo.java
----------------------------------------------------------------------
diff --git 
a/taverna-maven-plugin/src/main/java/org/apache/taverna/mavenplugin/AbstractDeployMojo.java
 
b/taverna-maven-plugin/src/main/java/org/apache/taverna/mavenplugin/AbstractDeployMojo.java
new file mode 100644
index 0000000..c9feec1
--- /dev/null
+++ 
b/taverna-maven-plugin/src/main/java/org/apache/taverna/mavenplugin/AbstractDeployMojo.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.taverna.mavenplugin;
+
+import java.io.File;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Abstract Mojo for deploying artifacts.
+ *
+ * @author David Withers
+ */
+public abstract class AbstractDeployMojo extends AbstractWagonMojo {
+
+       @Component
+       protected MavenProject project;
+
+       /**
+        * Directory containing the generated Taverna plugin.
+        */
+       @Parameter(defaultValue = "${project.build.directory}", required = true)
+       protected File buildDirectory;
+
+       @Parameter(defaultValue = "${project.build.outputDirectory}", required 
= true)
+       protected File outputDirectory;
+
+       @Parameter(defaultValue = "${project.artifact}", required = true, 
readonly = true)
+       protected Artifact artifact;
+
+       @Parameter(defaultValue = 
"${project.distributionManagementArtifactRepository}", required = true, 
readonly = true)
+       protected ArtifactRepository deploymentRepository;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/c660ed5c/taverna-maven-plugin/src/main/java/org/apache/taverna/mavenplugin/AbstractWagonMojo.java
----------------------------------------------------------------------
diff --git 
a/taverna-maven-plugin/src/main/java/org/apache/taverna/mavenplugin/AbstractWagonMojo.java
 
b/taverna-maven-plugin/src/main/java/org/apache/taverna/mavenplugin/AbstractWagonMojo.java
new file mode 100644
index 0000000..7844a2a
--- /dev/null
+++ 
b/taverna-maven-plugin/src/main/java/org/apache/taverna/mavenplugin/AbstractWagonMojo.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.taverna.mavenplugin;
+
+import org.apache.maven.artifact.manager.WagonManager;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.observers.Debug;
+
+/**
+ * Abstract Mojo for using the wagon.
+ *
+ * @author David Withers
+ */
+public abstract class AbstractWagonMojo extends AbstractMojo {
+
+       @Component
+       protected WagonManager wagonManager;
+
+       /**
+        * Disconnect the wagon.
+        *
+        * @param wagon
+        *            the wagon to disconnect
+        * @param debug
+        */
+       protected void disconnectWagon(Wagon wagon, Debug debug) {
+               if (getLog().isDebugEnabled()) {
+                       wagon.removeTransferListener(debug);
+                       wagon.removeSessionListener(debug);
+               }
+               try {
+                       wagon.disconnect();
+               } catch (ConnectionException e) {
+                       getLog().error("Error disconnecting wagon - ignored", 
e);
+               }
+       }
+
+
+}


Reply via email to