tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r711481 - in /tuscany/branches/sca-equinox: distribution/pdetarget/ tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/
Date Wed, 05 Nov 2008 00:42:11 GMT
Author: rfeng
Date: Tue Nov  4 16:42:10 2008
New Revision: 711481

URL: http://svn.apache.org/viewvc?rev=711481&view=rev
Log:
Adding the support to aggregate 3rd party jars into one bundle to fix split package issues

Added:
    tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactAggregation.java
  (with props)
    tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactMember.java
  (with props)
Modified:
    tuscany/branches/sca-equinox/distribution/pdetarget/pom.xml
    tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java

Modified: tuscany/branches/sca-equinox/distribution/pdetarget/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/distribution/pdetarget/pom.xml?rev=711481&r1=711480&r2=711481&view=diff
==============================================================================
--- tuscany/branches/sca-equinox/distribution/pdetarget/pom.xml (original)
+++ tuscany/branches/sca-equinox/distribution/pdetarget/pom.xml Tue Nov  4 16:42:10 2008
@@ -93,6 +93,26 @@
                                     <excludeGroupIds>
                                         <excludeGroupId>org.apache.tuscany.sca</excludeGroupId>
                                     </excludeGroupIds>
+                                    <artifactAggregations>
+                                        <artifactAggregation>
+                                            <symbolicName>com.google.gdata</symbolicName>
+                                            <version>1.0</version>
+                                            <artifactMembers>
+                                                <artifactMember>
+                                                    <groupId>com.google.gdata</groupId>
+                                                    <artifactId>*</artifactId>
+                                                    <version>1.0</version>
+                                                </artifactMember>
+                                                <!-- 
+                                                <artifactMember>
+                                                    <groupId>com.google.gdata</groupId>
+                                                    <artifactId>gdata-media</artifactId>
+                                                    <version>1.0</version>
+                                                </artifactMember>
+                                                 -->
+                                            </artifactMembers>
+                                        </artifactAggregation>
+                                    </artifactAggregations>
                                 </configuration>
                             </execution>
                         </executions>

Added: tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactAggregation.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactAggregation.java?rev=711481&view=auto
==============================================================================
--- tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactAggregation.java
(added)
+++ tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactAggregation.java
Tue Nov  4 16:42:10 2008
@@ -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

Propchange: tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactAggregation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactAggregation.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactMember.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactMember.java?rev=711481&view=auto
==============================================================================
--- tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactMember.java
(added)
+++ tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactMember.java
Tue Nov  4 16:42:10 2008
@@ -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()));
+    }
+}

Propchange: tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactMember.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ArtifactMember.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java?rev=711481&r1=711480&r2=711481&view=diff
==============================================================================
--- tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java
(original)
+++ tuscany/branches/sca-equinox/tools/maven/maven-bundle-plugin/src/main/java/org/apache/tuscany/sca/tools/bundle/plugin/ModuleBundlesBuildMojo.java
Tue Nov  4 16:42:10 2008
@@ -104,6 +104,11 @@
      */
     private boolean generatePlugin;
 
+    /**
+     * @parameter
+     */
+    private ArtifactAggregation[] artifactAggregations;
+
     public void execute() throws MojoExecutionException {
         Log log = getLog();
 
@@ -148,10 +153,10 @@
                 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 @@
                         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 @@
                 }
             }
 
+            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 @@
         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\">");



Mime
View raw message