aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1235099 - in /aries/trunk/versioning: ./ org.apache.aries.versioning.plugin/ org.apache.aries.versioning.plugin/src/ org.apache.aries.versioning.plugin/src/main/ org.apache.aries.versioning.plugin/src/main/java/ org.apache.aries.versioning...
Date Tue, 24 Jan 2012 00:54:00 GMT
Author: djencks
Date: Tue Jan 24 00:53:59 2012
New Revision: 1235099

URL: http://svn.apache.org/viewvc?rev=1235099&view=rev
Log:
ARIES-757 fake plugin that checks a bundle against itself

Added:
    aries/trunk/versioning/org.apache.aries.versioning.plugin/
    aries/trunk/versioning/org.apache.aries.versioning.plugin/pom.xml   (with props)
    aries/trunk/versioning/org.apache.aries.versioning.plugin/src/
    aries/trunk/versioning/org.apache.aries.versioning.plugin/src/main/
    aries/trunk/versioning/org.apache.aries.versioning.plugin/src/main/java/
    aries/trunk/versioning/org.apache.aries.versioning.plugin/src/main/java/org/
    aries/trunk/versioning/org.apache.aries.versioning.plugin/src/main/java/org/apache/
    aries/trunk/versioning/org.apache.aries.versioning.plugin/src/main/java/org/apache/aries/
    aries/trunk/versioning/org.apache.aries.versioning.plugin/src/main/java/org/apache/aries/versioning/
    aries/trunk/versioning/org.apache.aries.versioning.plugin/src/main/java/org/apache/aries/versioning/mojo/
    aries/trunk/versioning/org.apache.aries.versioning.plugin/src/main/java/org/apache/aries/versioning/mojo/VersionCheckerMojo.java
  (with props)
Modified:
    aries/trunk/versioning/pom.xml
    aries/trunk/versioning/versioning-checker/pom.xml
    aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/BundleCompatibility.java
    aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/BundleInfo.java
    aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/SemanticVersioningChecker.java
    aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/VersionChange.java

Added: aries/trunk/versioning/org.apache.aries.versioning.plugin/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/versioning/org.apache.aries.versioning.plugin/pom.xml?rev=1235099&view=auto
==============================================================================
--- aries/trunk/versioning/org.apache.aries.versioning.plugin/pom.xml (added)
+++ aries/trunk/versioning/org.apache.aries.versioning.plugin/pom.xml Tue Jan 24 00:53:59
2012
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>org.apache.aries.versioning</artifactId>
+        <groupId>org.apache.aries.versioning</groupId>
+        <version>0.1.0-SNAPSHOT</version>
+    </parent>
+    <groupId>org.apache.aries.versioning</groupId>
+    <artifactId>org.apache.aries.versioning.plugin</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>maven-plugin</packaging>
+    <name>org.apache.aries.versioning.plugin Maven Mojo</name>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.versioning</groupId>
+            <artifactId>org.apache.aries.versioning.checker</artifactId>
+            <version>0.1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>asm</groupId>
+            <artifactId>asm-all</artifactId>
+            <version>3.3.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+            <version>2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.1</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>

Propchange: aries/trunk/versioning/org.apache.aries.versioning.plugin/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: aries/trunk/versioning/org.apache.aries.versioning.plugin/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: aries/trunk/versioning/org.apache.aries.versioning.plugin/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: aries/trunk/versioning/org.apache.aries.versioning.plugin/src/main/java/org/apache/aries/versioning/mojo/VersionCheckerMojo.java
URL: http://svn.apache.org/viewvc/aries/trunk/versioning/org.apache.aries.versioning.plugin/src/main/java/org/apache/aries/versioning/mojo/VersionCheckerMojo.java?rev=1235099&view=auto
==============================================================================
--- aries/trunk/versioning/org.apache.aries.versioning.plugin/src/main/java/org/apache/aries/versioning/mojo/VersionCheckerMojo.java
(added)
+++ aries/trunk/versioning/org.apache.aries.versioning.plugin/src/main/java/org/apache/aries/versioning/mojo/VersionCheckerMojo.java
Tue Jan 24 00:53:59 2012
@@ -0,0 +1,81 @@
+/*
+ * Copyright 20012 The Apache Software Foundation.
+ *
+ * Licensed 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.aries.versioning.mojo;
+
+import org.apache.aries.util.manifest.BundleManifest;
+import org.apache.aries.versioning.check.BundleCompatibility;
+import org.apache.aries.versioning.check.BundleInfo;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * Goal which touches a timestamp file.
+ *
+ * @goal version-check
+ * 
+ * @phase install
+ */
+public class VersionCheckerMojo
+    extends AbstractMojo
+{
+    /**
+     * Location of the file.
+     * @parameter expression="${project.build.directory}/classes"
+     * @required
+     */
+    private File oldFile;
+    /**
+     * Location of the file.
+     * @parameter expression="${project.build.directory}/classes"
+     * @required
+     */
+    private File newFile;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        try {
+            BundleInfo oldBundle = getBundleInfo(oldFile);
+            BundleInfo newBundle = getBundleInfo(newFile);
+            String bundleSymbolicName = newBundle.getBundleManifest().getSymbolicName();
+            URLClassLoader oldClassLoader = new URLClassLoader(new URL[] {oldBundle.getBundle().toURI().toURL()});
+            URLClassLoader newClassLoader = new URLClassLoader(new URL[] {newBundle.getBundle().toURI().toURL()});
+            BundleCompatibility bundleCompatibility = new BundleCompatibility(bundleSymbolicName,
newBundle, oldBundle, oldClassLoader, newClassLoader);
+            bundleCompatibility.invoke();
+            getLog().info(bundleCompatibility.getBundleElement());
+            getLog().info(bundleCompatibility.getPkgElements());
+        } catch (MalformedURLException e) {
+
+        } catch (IOException e) {
+
+        }
+
+
+    }
+
+    private BundleInfo getBundleInfo(File f) {
+        BundleManifest bundleManifest = BundleManifest.fromBundle(f);
+        return new BundleInfo(bundleManifest, f);
+    }
+}

Propchange: aries/trunk/versioning/org.apache.aries.versioning.plugin/src/main/java/org/apache/aries/versioning/mojo/VersionCheckerMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: aries/trunk/versioning/org.apache.aries.versioning.plugin/src/main/java/org/apache/aries/versioning/mojo/VersionCheckerMojo.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: aries/trunk/versioning/org.apache.aries.versioning.plugin/src/main/java/org/apache/aries/versioning/mojo/VersionCheckerMojo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: aries/trunk/versioning/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/versioning/pom.xml?rev=1235099&r1=1235098&r2=1235099&view=diff
==============================================================================
--- aries/trunk/versioning/pom.xml (original)
+++ aries/trunk/versioning/pom.xml Tue Jan 24 00:53:59 2012
@@ -1,44 +1,43 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.aries</groupId>
-        <artifactId>java5-parent</artifactId>
-        <version>0.6-SNAPSHOT</version>
-        <relativePath/>
-    </parent>
-
-    <groupId>org.apache.aries.versioning</groupId>
-    <artifactId>org.apache.aries.versioning</artifactId>
-    <packaging>pom</packaging>
-    <name>Apache Aries Semantic Versioning Checker</name>
-    <version>0.1.0-SNAPSHOT</version>
-    <description>
-        OSGi Semantic Versioning Checker
-    </description>
-
-
-    <modules>
-        <module>versioning-checker</module>
-    </modules>
-
-</project>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries</groupId>
+        <artifactId>java5-parent</artifactId>
+        <version>0.6-SNAPSHOT</version>
+        <relativePath/>
+    </parent>
+
+    <groupId>org.apache.aries.versioning</groupId>
+    <artifactId>org.apache.aries.versioning</artifactId>
+    <packaging>pom</packaging>
+    <name>Apache Aries Semantic Versioning Checker</name>
+    <version>0.1.0-SNAPSHOT</version>
+    <description>
+        OSGi Semantic Versioning Checker
+    </description>
+
+
+    <modules>
+        <module>versioning-checker</module>
+    <module>org.apache.aries.versioning.plugin</module>
+  </modules>
+
+</project>
\ No newline at end of file

Modified: aries/trunk/versioning/versioning-checker/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/versioning/versioning-checker/pom.xml?rev=1235099&r1=1235098&r2=1235099&view=diff
==============================================================================
--- aries/trunk/versioning/versioning-checker/pom.xml (original)
+++ aries/trunk/versioning/versioning-checker/pom.xml Tue Jan 24 00:53:59 2012
@@ -84,7 +84,7 @@
             <groupId>asm</groupId>
             <artifactId>asm-all</artifactId>
             <optional>true</optional>
-            <version>3.2</version>
+            <version>3.3.1</version>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>

Modified: aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/BundleCompatibility.java
URL: http://svn.apache.org/viewvc/aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/BundleCompatibility.java?rev=1235099&r1=1235098&r2=1235099&view=diff
==============================================================================
--- aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/BundleCompatibility.java
(original)
+++ aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/BundleCompatibility.java
Tue Jan 24 00:53:59 2012
@@ -66,18 +66,15 @@ public class BundleCompatibility {
     private boolean bundleVersionCorrect;
     private BundleInfo currentBundle;
     private BundleInfo baseBundle;
-    private StringBuilder pkgElements;
+    private StringBuilder pkgElements = new StringBuilder();
 
     private VersionChange bundleChange;
     private final Map<String, VersionChange> packageChanges = new HashMap<String,
VersionChange>();
 
-    public BundleCompatibility(String bundleSymbolicName, String bundleElement, boolean bundleVersionCorrect,
BundleInfo currentBundle, BundleInfo baseBundle, StringBuilder pkgElements, URLClassLoader
oldJarsLoader, URLClassLoader newJarsLoader) {
+    public BundleCompatibility(String bundleSymbolicName, BundleInfo currentBundle, BundleInfo
baseBundle, URLClassLoader oldJarsLoader, URLClassLoader newJarsLoader) {
         this.bundleSymbolicName = bundleSymbolicName;
-        this.bundleElement = bundleElement;
-        this.bundleVersionCorrect = bundleVersionCorrect;
         this.currentBundle = currentBundle;
         this.baseBundle = baseBundle;
-        this.pkgElements = pkgElements;
         this.oldJarsLoader = oldJarsLoader;
         this.newJarsLoader = newJarsLoader;
     }
@@ -94,6 +91,10 @@ public class BundleCompatibility {
         return bundleElement;
     }
 
+    public StringBuilder getPkgElements() {
+        return pkgElements;
+    }
+
     public boolean isBundleVersionCorrect() {
         return bundleVersionCorrect;
     }
@@ -140,7 +141,7 @@ public class BundleCompatibility {
                         }
                     }
                     // We have scanned the whole packages, report the result
-                    if (majorChange.isChange() || minorChange.isChange()) {
+//                    if (majorChange.isChange() || minorChange.isChange()) {
                         String oldVersion = pkg.getValue().getPackageVersion();
                         String newVersion = currPkgContents.getPackageVersion();
                         if (majorChange.isChange()) {
@@ -159,9 +160,10 @@ public class BundleCompatibility {
                             }
                         }  else {
                             packageChanges.put(pkgName, new VersionChange(VERSION_CHANGE_TYPE.NO_CHANGE,
oldVersion, newVersion));
+                            pkgElements.append(getPkgStatusText(pkgName, VERSION_CHANGE_TYPE.NO_CHANGE,
pkg.getValue().getPackageVersion(), currPkgContents.getPackageVersion(), "", ""));
                         }
                         pkgElements.append("\r\n");
-                    }
+//                    }
                 }
             }
             // If there is a package version change, the bundle version needs to be updated.
@@ -486,9 +488,7 @@ public class BundleCompatibility {
     private String getStatusText(VERSION_CHANGE_TYPE status, String oldVersionStr, String
newVersionStr) {
 
         VersionChange versionChange = new VersionChange(status, oldVersionStr, newVersionStr);
-        return " oldVersion=\"" + versionChange.getOldVersion()
-                + "\" currentVersion=\"" + versionChange.getNewVersion() +
-                "\" recommendedVersion=\"" + versionChange.getRecommendedNewVersion() + "\"
correct=\"" + versionChange.isCorrect();
+        return versionChange.toString();
     }
 
     private String transformForXml(String str) {

Modified: aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/BundleInfo.java
URL: http://svn.apache.org/viewvc/aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/BundleInfo.java?rev=1235099&r1=1235098&r2=1235099&view=diff
==============================================================================
--- aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/BundleInfo.java
(original)
+++ aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/BundleInfo.java
Tue Jan 24 00:53:59 2012
@@ -31,7 +31,7 @@ public class BundleInfo {
     private final BundleManifest bundleManifest;
     private final File bundle;
 
-    BundleInfo(BundleManifest bm, File bundle) {
+    public BundleInfo(BundleManifest bm, File bundle) {
         this.bundleManifest = bm;
         this.bundle = bundle;
     }

Modified: aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/SemanticVersioningChecker.java
URL: http://svn.apache.org/viewvc/aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/SemanticVersioningChecker.java?rev=1235099&r1=1235098&r2=1235099&view=diff
==============================================================================
--- aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/SemanticVersioningChecker.java
(original)
+++ aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/SemanticVersioningChecker.java
Tue Jan 24 00:53:59 2012
@@ -110,9 +110,10 @@ public class SemanticVersioningChecker {
                 if (baseBundle == null) {
                     _logger.debug("The bundle " + bundleSymbolicName + " has no counterpart
in the base. The semantic version validation does not apply to this bundle.");
                 } else {
-                    BundleCompatibility bundleCompatibility = new BundleCompatibility(bundleSymbolicName,
bundleElement, bundleVersionCorrect, currentBundle, baseBundle, pkgElements, oldJarsLoader,
newJarsLoader).invoke();
+                    BundleCompatibility bundleCompatibility = new BundleCompatibility(bundleSymbolicName,
currentBundle, baseBundle, oldJarsLoader, newJarsLoader).invoke();
                     bundleVersionCorrect = bundleCompatibility.isBundleVersionCorrect();
                     bundleElement = bundleCompatibility.getBundleElement();
+                    pkgElements = bundleCompatibility.getPkgElements();
                 }
                 // Need to write bundle element and then package elements
                 if ((!!!bundleVersionCorrect) || ((pkgElements.length() > 0))) {

Modified: aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/VersionChange.java
URL: http://svn.apache.org/viewvc/aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/VersionChange.java?rev=1235099&r1=1235098&r2=1235099&view=diff
==============================================================================
--- aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/VersionChange.java
(original)
+++ aries/trunk/versioning/versioning-checker/src/main/java/org/apache/aries/versioning/check/VersionChange.java
Tue Jan 24 00:53:59 2012
@@ -23,8 +23,8 @@ package org.apache.aries.versioning.chec
 import org.osgi.framework.Version;
 
 /**
-* @version $Rev:$ $Date:$
-*/
+ * @version $Rev:$ $Date:$
+ */
 class VersionChange {
     private BundleCompatibility.VERSION_CHANGE_TYPE changeType;
     private Version oldVersion;
@@ -72,4 +72,11 @@ class VersionChange {
     public boolean isCorrect() {
         return correct;
     }
+
+    @Override
+    public String toString() {
+        return " oldVersion=\"" + getOldVersion()
+                + "\" currentVersion=\"" + getNewVersion() +
+                "\" recommendedVersion=\"" + getRecommendedNewVersion() + "\" correct=\""
+ isCorrect();
+    }
 }



Mime
View raw message