You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2015/02/17 21:50:55 UTC
[3/5] incubator-taverna-osgi git commit: temporarily empty repository
http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/2f5a0e94/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 6901119..0000000
--- a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/MavenOsgiUtils.java
+++ /dev/null
@@ -1,415 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-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.eclipse.aether.RepositorySystemSession;
-import org.eclipse.aether.graph.DependencyNode;
-import org.eclipse.aether.util.filter.ScopeDependencyFilter;
-
-import uk.org.taverna.commons.profile.xml.jaxb.BundleInfo;
-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/2f5a0e94/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 5e4a5e5..0000000
--- a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/Package.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-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/2f5a0e94/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 14e0dee..0000000
--- a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/PackageVersion.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-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/2f5a0e94/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 cf2034b..0000000
--- a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginDeployFileMojo.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-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 uk.org.taverna.commons.plugin.xml.jaxb.PluginInfo;
-import uk.org.taverna.commons.plugin.xml.jaxb.PluginVersions;
-import uk.org.taverna.commons.plugin.xml.jaxb.Plugins;
-import uk.org.taverna.commons.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/2f5a0e94/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 8ba1f3d..0000000
--- a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginDeployMojo.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-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 uk.org.taverna.commons.plugin.xml.jaxb.PluginInfo;
-import uk.org.taverna.commons.plugin.xml.jaxb.PluginVersions;
-import uk.org.taverna.commons.plugin.xml.jaxb.Plugins;
-import uk.org.taverna.commons.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><distributionManagement></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/2f5a0e94/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 0ec94f4..0000000
--- a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginGenerateMojo.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-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.eclipse.aether.RepositorySystemSession;
-
-import uk.org.taverna.commons.plugin.xml.jaxb.PluginInfo;
-import uk.org.taverna.commons.profile.xml.jaxb.BundleInfo;
-
-/**
- * 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/2f5a0e94/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 497151f..0000000
--- a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaPluginPrepareBundlesMojo.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-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/2f5a0e94/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 fce4ded..0000000
--- a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaProfileDeployMojo.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-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 uk.org.taverna.commons.profile.xml.jaxb.ApplicationProfile;
-import uk.org.taverna.commons.profile.xml.jaxb.BundleInfo;
-import uk.org.taverna.commons.profile.xml.jaxb.UpdateSite;
-import uk.org.taverna.commons.versions.xml.jaxb.Version;
-import uk.org.taverna.commons.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><distributionManagement></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/2f5a0e94/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 1a0e9a0..0000000
--- a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/TavernaProfileGenerateMojo.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-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.eclipse.aether.RepositorySystemSession;
-
-import uk.org.taverna.commons.profile.xml.jaxb.ApplicationProfile;
-import uk.org.taverna.commons.profile.xml.jaxb.BundleInfo;
-import uk.org.taverna.commons.profile.xml.jaxb.FrameworkConfiguration;
-import uk.org.taverna.commons.profile.xml.jaxb.Updates;
-
-/**
- * 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/2f5a0e94/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 82f5fee..0000000
--- a/taverna-maven-plugin/src/main/java/net/sf/taverna/t2/maven/plugins/Utils.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2013 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-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()) {
- 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/2f5a0e94/taverna-maven-plugin/src/main/resources/META-INF/plexus/components.xml
----------------------------------------------------------------------
diff --git a/taverna-maven-plugin/src/main/resources/META-INF/plexus/components.xml b/taverna-maven-plugin/src/main/resources/META-INF/plexus/components.xml
deleted file mode 100644
index d458176..0000000
--- a/taverna-maven-plugin/src/main/resources/META-INF/plexus/components.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<component-set>
- <components>
- <component>
- <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
- <role-hint>taverna-plugin</role-hint>
- <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping
- </implementation>
- <configuration>
- <phases>
- <generate-resources>org.apache.taverna.osgi:taverna-maven-plugin:plugin-generate</generate-resources>
- <prepare-package>org.apache.taverna.osgi:taverna-maven-plugin:plugin-prepare-bundles</prepare-package>
- <package>org.apache.maven.plugins:maven-jar-plugin:jar</package>
- <deploy>org.apache.taverna.osgi:taverna-maven-plugin:plugin-deploy</deploy>
- </phases>
- </configuration>
- </component>
- <component>
- <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
- <role-hint>taverna-application</role-hint>
- <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping
- </implementation>
- <configuration>
- <phases>
- <generate-resources>org.apache.taverna.osgi:taverna-maven-plugin:profile-generate</generate-resources>
- <deploy>org.apache.taverna.osgi:taverna-maven-plugin:profile-deploy</deploy>
- </phases>
- </configuration>
- </component>
- </components>
-</component-set>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/2f5a0e94/taverna-maven-plugin/src/main/resources/java7-packages
----------------------------------------------------------------------
diff --git a/taverna-maven-plugin/src/main/resources/java7-packages b/taverna-maven-plugin/src/main/resources/java7-packages
deleted file mode 100644
index 032c7dd..0000000
--- a/taverna-maven-plugin/src/main/resources/java7-packages
+++ /dev/null
@@ -1,209 +0,0 @@
-java.applet
-java.awt
-java.awt.color
-java.awt.datatransfer
-java.awt.dnd
-java.awt.event
-java.awt.font
-java.awt.geom
-java.awt.im
-java.awt.im.spi
-java.awt.image
-java.awt.image.renderable
-java.awt.print
-java.beans
-java.beans.beancontext
-java.io
-java.lang
-java.lang.annotation
-java.lang.instrument
-java.lang.invoke
-java.lang.management
-java.lang.ref
-java.lang.reflect
-java.math
-java.net
-java.nio
-java.nio.channels
-java.nio.channels.spi
-java.nio.charset
-java.nio.charset.spi
-java.nio.file
-java.nio.file.attribute
-java.nio.file.spi
-java.rmi
-java.rmi.activation
-java.rmi.dgc
-java.rmi.registry
-java.rmi.server
-java.security
-java.security.acl
-java.security.cert
-java.security.interfaces
-java.security.spec
-java.sql
-java.text
-java.text.spi
-java.util
-java.util.concurrent
-java.util.concurrent.atomic
-java.util.concurrent.locks
-java.util.jar
-java.util.logging
-java.util.prefs
-java.util.regex
-java.util.spi
-java.util.zip
-javax.accessibility
-javax.activation
-javax.activity
-javax.annotation
-javax.annotation.processing
-javax.crypto
-javax.crypto.interfaces
-javax.crypto.spec
-javax.imageio
-javax.imageio.event
-javax.imageio.metadata
-javax.imageio.plugins.bmp
-javax.imageio.plugins.jpeg
-javax.imageio.spi
-javax.imageio.stream
-javax.jws
-javax.jws.soap
-javax.lang.model
-javax.lang.model.element
-javax.lang.model.type
-javax.lang.model.util
-javax.management
-javax.management.loading
-javax.management.modelmbean
-javax.management.monitor
-javax.management.openmbean
-javax.management.relation
-javax.management.remote
-javax.management.remote.rmi
-javax.management.timer
-javax.naming
-javax.naming.directory
-javax.naming.event
-javax.naming.ldap
-javax.naming.spi
-javax.net
-javax.net.ssl
-javax.print
-javax.print.attribute
-javax.print.attribute.standard
-javax.print.event
-javax.rmi
-javax.rmi.CORBA
-javax.rmi.ssl
-javax.script
-javax.security.auth
-javax.security.auth.callback
-javax.security.auth.kerberos
-javax.security.auth.login
-javax.security.auth.spi
-javax.security.auth.x500
-javax.security.cert
-javax.security.sasl
-javax.sound.midi
-javax.sound.midi.spi
-javax.sound.sampled
-javax.sound.sampled.spi
-javax.sql
-javax.sql.rowset
-javax.sql.rowset.serial
-javax.sql.rowset.spi
-javax.swing
-javax.swing.border
-javax.swing.colorchooser
-javax.swing.event
-javax.swing.filechooser
-javax.swing.plaf
-javax.swing.plaf.basic
-javax.swing.plaf.metal
-javax.swing.plaf.multi
-javax.swing.plaf.nimbus
-javax.swing.plaf.synth
-javax.swing.table
-javax.swing.text
-javax.swing.text.html
-javax.swing.text.html.parser
-javax.swing.text.rtf
-javax.swing.tree
-javax.swing.undo
-javax.tools
-javax.transaction
-javax.transaction.xa
-javax.xml
-javax.xml.bind
-javax.xml.bind.annotation
-javax.xml.bind.annotation.adapters
-javax.xml.bind.attachment
-javax.xml.bind.helpers
-javax.xml.bind.util
-javax.xml.crypto
-javax.xml.crypto.dom
-javax.xml.crypto.dsig
-javax.xml.crypto.dsig.dom
-javax.xml.crypto.dsig.keyinfo
-javax.xml.crypto.dsig.spec
-javax.xml.datatype
-javax.xml.namespace
-javax.xml.parsers
-javax.xml.soap
-javax.xml.stream
-javax.xml.stream.events
-javax.xml.stream.util
-javax.xml.transform
-javax.xml.transform.dom
-javax.xml.transform.sax
-javax.xml.transform.stax
-javax.xml.transform.stream
-javax.xml.validation
-javax.xml.ws
-javax.xml.ws.handler
-javax.xml.ws.handler.soap
-javax.xml.ws.http
-javax.xml.ws.soap
-javax.xml.ws.spi
-javax.xml.ws.spi.http
-javax.xml.ws.wsaddressing
-javax.xml.xpath
-org.ietf.jgss
-org.omg.CORBA
-org.omg.CORBA_2_3
-org.omg.CORBA_2_3.portable
-org.omg.CORBA.DynAnyPackage
-org.omg.CORBA.ORBPackage
-org.omg.CORBA.portable
-org.omg.CORBA.TypeCodePackage
-org.omg.CosNaming
-org.omg.CosNaming.NamingContextExtPackage
-org.omg.CosNaming.NamingContextPackage
-org.omg.Dynamic
-org.omg.DynamicAny
-org.omg.DynamicAny.DynAnyFactoryPackage
-org.omg.DynamicAny.DynAnyPackage
-org.omg.IOP
-org.omg.IOP.CodecFactoryPackage
-org.omg.IOP.CodecPackage
-org.omg.Messaging
-org.omg.PortableInterceptor
-org.omg.PortableInterceptor.ORBInitInfoPackage
-org.omg.PortableServer
-org.omg.PortableServer.CurrentPackage
-org.omg.PortableServer.POAManagerPackage
-org.omg.PortableServer.POAPackage
-org.omg.PortableServer.portable
-org.omg.PortableServer.ServantLocatorPackage
-org.omg.SendingContext
-org.omg.stub.java.rmi
-org.w3c.dom
-org.w3c.dom.bootstrap
-org.w3c.dom.events
-org.w3c.dom.ls
-org.xml.sax
-org.xml.sax.ext
-org.xml.sax.helpers
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/2f5a0e94/taverna-maven-plugin/src/test/java/net/sf/taverna/t2/maven/plugins/TavernaPluginGenerateMojoTest.java
----------------------------------------------------------------------
diff --git a/taverna-maven-plugin/src/test/java/net/sf/taverna/t2/maven/plugins/TavernaPluginGenerateMojoTest.java b/taverna-maven-plugin/src/test/java/net/sf/taverna/t2/maven/plugins/TavernaPluginGenerateMojoTest.java
deleted file mode 100644
index 6f21fb1..0000000
--- a/taverna-maven-plugin/src/test/java/net/sf/taverna/t2/maven/plugins/TavernaPluginGenerateMojoTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2009 The University of Manchester
- *
- * Modifications to the initial code base are copyright of their
- * respective authors, or their employers as appropriate.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- ******************************************************************************/
-package net.sf.taverna.t2.maven.plugins;
-
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * Unit tests for TavernaPluginGenerateMojo.
- *
- * @author David Withers
- */
-public class TavernaPluginGenerateMojoTest extends AbstractMojoTestCase {
-
- private TavernaPluginGenerateMojo tavernaPluginGenerateMojo;
-
- /**
- * @throws java.lang.Exception
- */
- @Ignore
- public void setUp() throws Exception {
-// super.setUp();
-//
-// File pluginXml = new File( getBasedir(), "src/test/resources/unit/plugin-config.xml" );
-// tavernaPluginGenerateMojo = (TavernaPluginGenerateMojo) lookupMojo( "plugin-generate", pluginXml );
-//
-// MavenProject mavenProject = (MavenProject) getVariableValueFromObject(tavernaPluginGenerateMojo, "project");
-//
-// Artifact artifact = new DefaultArtifact("net.sf.taverna.t2", "example-plugin", VersionRange
-// .createFromVersion("0.1.0"), "compile", "jar", "", null);
-// artifact.setRepository(new DefaultArtifactRepository("id1",
-// "http://www.mygrid.org.uk/maven/repository", new DefaultRepositoryLayout()));
-// mavenProject.setArtifact(artifact);
-//
-//
-// Artifact dependency = new DefaultArtifact("com.example.test", "test-artifact", VersionRange
-// .createFromVersion("1.3.5"), "compile", "jar", "", null);
-// dependency.setGroupId("com.example.test");
-// dependency.setArtifactId("test-artifact");
-// dependency.setVersion("1.3.5");
-// dependency.setRepository(new DefaultArtifactRepository("id2",
-// "http://www.example.com/maven/repository", new DefaultRepositoryLayout()));
-// mavenProject.setDependencyArtifacts(Collections.singleton(dependency));
-//
-// MavenSession session = new MavenSession(getContainer(), (RepositorySystemSession) null, (MavenExecutionRequest) null, (MavenExecutionResult) null);
-// setVariableValueToObject(tavernaPluginGenerateMojo, "session", session);
- }
-
- /**
- * Test method for
- * {@link net.sf.taverna.t2.maven.plugins.TavernaPluginGenerateMojo#execute()}
- *
- * @throws Exception
- */
- @Test
- @Ignore
- public void testExecute() throws Exception {
-// tavernaPluginGenerateMojo.execute();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-osgi/blob/2f5a0e94/taverna-maven-plugin/src/test/resources/unit/plugin-config.xml
----------------------------------------------------------------------
diff --git a/taverna-maven-plugin/src/test/resources/unit/plugin-config.xml b/taverna-maven-plugin/src/test/resources/unit/plugin-config.xml
deleted file mode 100644
index 0d23438..0000000
--- a/taverna-maven-plugin/src/test/resources/unit/plugin-config.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<project>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.taverna.osgi</groupId>
- <artifactId>taverna-maven-plugin</artifactId>
- <configuration>
- <buildDirectory>${basedir}/target/test/unit</buildDirectory>
- <project>
- <groupId>com.example</groupId>
- <artifactId>example-plugin</artifactId>
- <version>0.1.0</version>
- <name>Example Plugin</name>
- </project>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>