summaryrefslogtreecommitdiffstats
path: root/branches/sca-equinox/tools/maven
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-11-05 00:42:10 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-11-05 00:42:10 +0000
commit57ec345e853d83b76f36f9cef74e95a3237a2e74 (patch)
tree77d8e08e0fc9816721b772f90b3bd22eb698e915 /branches/sca-equinox/tools/maven
parent8c5612a58086ee0eaa45c166fc8c2c9a09ecff1b (diff)
Adding the support to aggregate 3rd party jars into one bundle to fix split package issues
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@711481 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-equinox/tools/maven')
-rw-r--r--branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactAggregation.java73
-rw-r--r--branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactMember.java61
-rw-r--r--branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java60
3 files changed, 187 insertions, 7 deletions
diff --git a/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactAggregation.java b/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactAggregation.java
new file mode 100644
index 0000000000..062c935ad9
--- /dev/null
+++ b/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactAggregation.java
@@ -0,0 +1,73 @@
+/*
+ * 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.sca.tools.bundle.plugin;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+
+
+public class ArtifactAggregation {
+ private String symbolicName;
+ private String version;
+ private List<ArtifactMember> artifactMemebers = new ArrayList<ArtifactMember>();
+ private transient List<Artifact> artifacts = new ArrayList<Artifact>();
+
+ public List<Artifact> getArtifacts() {
+ return artifacts;
+ }
+
+ public String getSymbolicName() {
+ return symbolicName;
+ }
+
+ public void setSymbolicName(String symbolicName) {
+ this.symbolicName = symbolicName;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public List<ArtifactMember> getArtifactMembers() {
+ return artifactMemebers;
+ }
+
+ public void setArtifactMembers(List<ArtifactMember> artifacts) {
+ this.artifactMemebers = artifacts;
+ }
+
+ public String toString() {
+ return symbolicName + ";version=\"" + version + "\"\n" + artifactMemebers;
+ }
+
+ public boolean matches(Artifact artifact) {
+ for(ArtifactMember m: artifactMemebers) {
+ if(m.matches(artifact)) {
+ return true;
+ }
+ }
+ return false;
+ }
+} \ No newline at end of file
diff --git a/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactMember.java b/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactMember.java
new file mode 100644
index 0000000000..19315aa19f
--- /dev/null
+++ b/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactMember.java
@@ -0,0 +1,61 @@
+/*
+ * 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.sca.tools.bundle.plugin;
+
+import org.apache.maven.artifact.Artifact;
+
+public class ArtifactMember {
+ private String groupId;
+ private String artifactId;
+ private String version;
+
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(String groupId) {
+ this.groupId = groupId;
+ }
+
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ public void setArtifactId(String artifactId) {
+ this.artifactId = artifactId;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String toString() {
+ return groupId + ":" + artifactId + ":" + version;
+ }
+
+ public boolean matches(Artifact artifact) {
+ return groupId.equals(artifact.getGroupId()) && (artifactId == null || artifactId.equals("")
+ || artifactId.equals("*") || artifactId.equals(artifact.getArtifactId()))
+ && (version == null || version.equals("") || version.equals("*") || version.equals(artifact.getVersion()));
+ }
+}
diff --git a/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java b/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java
index ba35485eb5..de03d0d6d2 100644
--- a/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java
+++ b/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java
@@ -104,6 +104,11 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
*/
private boolean generatePlugin;
+ /**
+ * @parameter
+ */
+ private ArtifactAggregation[] artifactAggregations;
+
public void execute() throws MojoExecutionException {
Log log = getLog();
@@ -148,10 +153,10 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
Artifact artifact = (Artifact)o;
// Only consider Compile and Runtime dependencies
- if (!(Artifact.SCOPE_COMPILE.equals(artifact.getScope())
- || Artifact.SCOPE_RUNTIME.equals(artifact.getScope())
- || Artifact.SCOPE_PROVIDED.equals(artifact.getScope())
- || (generateTargetPlatform && Artifact.SCOPE_TEST.equals(artifact.getScope())))) {
+ if (!(Artifact.SCOPE_COMPILE.equals(artifact.getScope()) || Artifact.SCOPE_RUNTIME.equals(artifact
+ .getScope())
+ || Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) || (generateTargetPlatform && Artifact.SCOPE_TEST
+ .equals(artifact.getScope())))) {
log.info("Skipping artifact: " + artifact);
continue;
}
@@ -226,6 +231,20 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
continue;
}
+ if (artifactAggregations != null) {
+ boolean aggregated = false;
+ for (ArtifactAggregation group : artifactAggregations) {
+ if (group.matches(artifact)) {
+ group.getArtifacts().add(artifact);
+ aggregated = true;
+ break;
+ }
+ }
+ if (aggregated) {
+ continue;
+ }
+ }
+
// Create a bundle directory for a non-OSGi JAR
log.info("Adding JAR artifact: " + artifact);
String version = BundleUtil.osgiVersion(artifact.getVersion());
@@ -246,9 +265,36 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
}
}
+ if (artifactAggregations != null) {
+ for (ArtifactAggregation group : artifactAggregations) {
+ if (group.getArtifacts().isEmpty()) {
+ continue;
+ }
+ String symbolicName = group.getSymbolicName();
+ String version = group.getVersion();
+ File dir = new File(root, symbolicName + "-" + version);
+ dir.mkdir();
+ Set<File> jarFiles = new HashSet<File>();
+ for (Artifact a : group.getArtifacts()) {
+ log.info("Aggragating JAR artifact: " + a);
+ jarFiles.add(a.getFile());
+ copyFile(a.getFile(), dir);
+ }
+ Manifest mf = BundleUtil.libraryManifest(jarFiles, symbolicName, symbolicName, version, null);
+ File file = new File(dir, "META-INF");
+ file.mkdirs();
+ file = new File(file, "MANIFEST.MF");
+
+ FileOutputStream fos = new FileOutputStream(file);
+ write(mf, fos);
+ fos.close();
+ bundleSymbolicNames.add(symbolicName);
+ }
+ }
+
// Generate a PDE target
if (generateTargetPlatform) {
- File target = new File(project.getBuild().getDirectory(), project.getArtifactId()+".target");
+ File target = new File(project.getBuild().getDirectory(), project.getArtifactId() + ".target");
FileOutputStream targetFile = new FileOutputStream(target);
writeTarget(new PrintStream(targetFile), bundleSymbolicNames, eclipseFeatures);
targetFile.close();
@@ -290,11 +336,11 @@ public class ModuleBundlesBuildMojo extends AbstractMojo {
ps.println("<?pde version=\"3.2\"?>");
ps.println("<target name=\"Eclipse Target - " + project.getArtifactId() + "\">");
-
+
ps.println(" <targetJRE>");
ps.println(" <execEnv>J2SE-1.5</execEnv>");
ps.println(" </targetJRE>");
-
+
ps.println(" <location useDefault=\"true\"/>");
// ps.println("<content useAllPlugins=\"true\">");