diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-05 08:32:50 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-05 08:32:50 +0000 |
commit | 364538d446bb11993ba6a692e9a8070f4ac569e5 (patch) | |
tree | aa19ec4c4830c24fe5b87124f4c274479f376a67 /maven-plugins/tags/maven-bundle-plugin-1.0.1/src/main/java/org/apache/tuscany/maven/bundle/plugin/ThirdPartyBundleBuildMojo.java | |
parent | 83bdc2f661b2cf88d55337b7f57b421253693003 (diff) |
Delete old tag
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@750384 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | maven-plugins/tags/maven-bundle-plugin-1.0.1/src/main/java/org/apache/tuscany/maven/bundle/plugin/ThirdPartyBundleBuildMojo.java | 152 |
1 files changed, 0 insertions, 152 deletions
diff --git a/maven-plugins/tags/maven-bundle-plugin-1.0.1/src/main/java/org/apache/tuscany/maven/bundle/plugin/ThirdPartyBundleBuildMojo.java b/maven-plugins/tags/maven-bundle-plugin-1.0.1/src/main/java/org/apache/tuscany/maven/bundle/plugin/ThirdPartyBundleBuildMojo.java deleted file mode 100644 index 880f1379e0..0000000000 --- a/maven-plugins/tags/maven-bundle-plugin-1.0.1/src/main/java/org/apache/tuscany/maven/bundle/plugin/ThirdPartyBundleBuildMojo.java +++ /dev/null @@ -1,152 +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 org.apache.tuscany.maven.bundle.plugin; - -import static org.apache.tuscany.maven.bundle.plugin.BundleUtil.write; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.HashSet; -import java.util.Set; -import java.util.jar.Manifest; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.project.MavenProject; - -/** - * A Maven plugin that builds an OSGi bundle for the project's third-party dependencies. - * - * @version $Rev$ $Date$ - * @goal assemble-thirdparty-bundle - * @phase generate-resources - * @requiresDependencyResolution test - * @description Build an OSGi bundle for the project's third party dependencies - */ -public class ThirdPartyBundleBuildMojo extends AbstractMojo { - - /** - * The project to build the bundle for. - * - * @parameter expression="${project}" - * @required - * @readonly - */ - private MavenProject project; - - /** - * The bundle symbolic name - * - * @parameter - */ - private String symbolicName; - - public void execute() throws MojoExecutionException { - Log log = getLog(); - - String projectGroupId = project.getGroupId(); - Set<File> jarFiles = new HashSet<File>(); - for (Object o : project.getArtifacts()) { - Artifact artifact = (Artifact)o; - - if (!(Artifact.SCOPE_COMPILE.equals(artifact.getScope()) || Artifact.SCOPE_RUNTIME.equals(artifact - .getScope()))) { - if (log.isDebugEnabled()) { - log.debug("Skipping artifact: " + artifact); - } - continue; - } - if (!"jar".equals(artifact.getType())) { - continue; - } - if (projectGroupId.equals(artifact.getGroupId())) { - continue; - } - - if (log.isDebugEnabled()) { - log.debug("Artifact: " + artifact); - } - String bundleName = null; - try { - bundleName = BundleUtil.getBundleSymbolicName(artifact.getFile()); - } catch (IOException e) { - throw new MojoExecutionException(e.getMessage(), e); - } - if (bundleName == null || true) { - if (artifact.getFile().exists()) { - log.info("Adding third party jar: " + artifact); - jarFiles.add(artifact.getFile()); - } else { - log.warn("Third party jar not found: " + artifact); - } - } - } - - try { - String version = BundleUtil.osgiVersion(project.getVersion()); - - Manifest mf = BundleUtil.libraryManifest(jarFiles, project.getName(), symbolicName, version, "lib"); - File file = new File(project.getBasedir(), "META-INF"); - file.mkdir(); - file = new File(file, "MANIFEST.MF"); - if (log.isDebugEnabled()) { - log.debug("Generating " + file); - } - - FileOutputStream fos = new FileOutputStream(file); - write(mf, fos); - fos.close(); - - File lib = new File(project.getBasedir(), "lib"); - if (lib.isDirectory()) { - for (File c : lib.listFiles()) { - c.delete(); - } - } - lib.mkdir(); - byte[] buf = new byte[4096]; - for (File jar : jarFiles) { - File jarFile = new File(lib, jar.getName()); - if (log.isDebugEnabled()) { - log.debug("Copying " + jar + " to " + jarFile); - } - FileInputStream in = new FileInputStream(jar); - FileOutputStream out = new FileOutputStream(jarFile); - for (;;) { - int len = in.read(buf); - if (len > 0) { - out.write(buf, 0, len); - } else { - break; - } - } - in.close(); - out.close(); - } - } catch (Exception e) { - throw new MojoExecutionException(e.getMessage(), e); - } - - } - -} |