felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1810301 - in /felix/sandbox/cziegeler/osgicheck-maven-plugin: ./ src/main/java/org/apache/felix/maven/osgicheck/impl/ src/main/java/org/apache/felix/maven/osgicheck/impl/checks/ src/main/java/org/apache/felix/maven/osgicheck/impl/featureutil/
Date Mon, 02 Oct 2017 07:27:12 GMT
Author: cziegeler
Date: Mon Oct  2 07:27:11 2017
New Revision: 1810301

URL: http://svn.apache.org/viewvc?rev=1810301&view=rev
Log:
Avoid import of unreleased class from Apache Sling

Added:
    felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/featureutil/
    felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/featureutil/ManifestUtil.java
  (with props)
    felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/featureutil/PackageInfo.java
  (with props)
Modified:
    felix/sandbox/cziegeler/osgicheck-maven-plugin/   (props changed)
    felix/sandbox/cziegeler/osgicheck-maven-plugin/pom.xml
    felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/CheckMojo.java
    felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/checks/ImportExportCheck.java

Propchange: felix/sandbox/cziegeler/osgicheck-maven-plugin/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Oct  2 07:27:11 2017
@@ -0,0 +1,5 @@
+.classpath
+.project
+.settings
+target
+bin

Modified: felix/sandbox/cziegeler/osgicheck-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/osgicheck-maven-plugin/pom.xml?rev=1810301&r1=1810300&r2=1810301&view=diff
==============================================================================
--- felix/sandbox/cziegeler/osgicheck-maven-plugin/pom.xml (original)
+++ felix/sandbox/cziegeler/osgicheck-maven-plugin/pom.xml Mon Oct  2 07:27:11 2017
@@ -138,11 +138,6 @@
             <version>6.0.0</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.feature.support</artifactId>
-            <version>0.0.1-SNAPSHOT</version>
-        </dependency>
-        <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.scr</artifactId>
             <version>2.0.12</version>

Modified: felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/CheckMojo.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/CheckMojo.java?rev=1810301&r1=1810300&r2=1810301&view=diff
==============================================================================
--- felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/CheckMojo.java
(original)
+++ felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/CheckMojo.java
Mon Oct  2 07:27:11 2017
@@ -30,6 +30,7 @@ import java.util.jar.Manifest;
 import org.apache.commons.io.FileUtils;
 import org.apache.felix.maven.osgicheck.impl.checks.ImportExportCheck;
 import org.apache.felix.maven.osgicheck.impl.checks.SCRCheck;
+import org.apache.felix.maven.osgicheck.impl.featureutil.ManifestUtil;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -41,7 +42,6 @@ import org.apache.maven.plugins.annotati
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.shared.utils.xml.Xpp3Dom;
 import org.apache.maven.shared.utils.xml.Xpp3DomBuilder;
-import org.apache.sling.feature.support.util.ManifestUtil;
 import org.codehaus.plexus.archiver.UnArchiver;
 import org.codehaus.plexus.archiver.manager.ArchiverManager;
 import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;

Modified: felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/checks/ImportExportCheck.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/checks/ImportExportCheck.java?rev=1810301&r1=1810300&r2=1810301&view=diff
==============================================================================
--- felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/checks/ImportExportCheck.java
(original)
+++ felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/checks/ImportExportCheck.java
Mon Oct  2 07:27:11 2017
@@ -20,9 +20,9 @@ import java.util.List;
 
 import org.apache.felix.maven.osgicheck.impl.Check;
 import org.apache.felix.maven.osgicheck.impl.CheckContext;
+import org.apache.felix.maven.osgicheck.impl.featureutil.ManifestUtil;
+import org.apache.felix.maven.osgicheck.impl.featureutil.PackageInfo;
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.sling.feature.support.util.ManifestUtil;
-import org.apache.sling.feature.support.util.PackageInfo;
 import org.osgi.framework.Version;
 
 /**

Added: felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/featureutil/ManifestUtil.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/featureutil/ManifestUtil.java?rev=1810301&view=auto
==============================================================================
--- felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/featureutil/ManifestUtil.java
(added)
+++ felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/featureutil/ManifestUtil.java
Mon Oct  2 07:27:11 2017
@@ -0,0 +1,88 @@
+/*
+ * 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.felix.maven.osgicheck.impl.featureutil;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.apache.sling.commons.osgi.ManifestHeader;
+import org.osgi.framework.Constants;
+
+/*
+ * This is a simplified copy of the Apache Sling Feature ManifestUtil class.
+ * We keep this copy until the feature module is released in Sling.
+ */
+public class ManifestUtil {
+
+    /**
+     * Get the manifest from the artifact.
+     * @param artifact The file
+     * @throws IOException If the manifest can't be read
+     */
+    public static Manifest getManifest(final File artifact) throws IOException {
+        try (final JarFile file = new JarFile(artifact) ) {
+            return file.getManifest();
+        }
+    }
+
+    public static List<PackageInfo> extractPackages(final Manifest m,
+            final String headerName,
+            final String defaultVersion,
+            final boolean checkOptional) {
+        final String pckInfo = m.getMainAttributes().getValue(headerName);
+        if (pckInfo != null) {
+            final ManifestHeader header = ManifestHeader.parse(pckInfo);
+
+            final List<PackageInfo> pcks = new ArrayList<>();
+            for(final ManifestHeader.Entry entry : header.getEntries()) {
+                String version = entry.getAttributeValue("version");
+                if ( version == null ) {
+                    version = defaultVersion;
+                }
+                boolean optional = false;
+                if ( checkOptional ) {
+                    final String resolution = entry.getDirectiveValue("resolution");
+                    optional = "optional".equalsIgnoreCase(resolution);
+                }
+                final PackageInfo pck = new PackageInfo(entry.getValue(),
+                        version,
+                        optional);
+                pcks.add(pck);
+            }
+
+            return pcks;
+        }
+        return Collections.emptyList();
+    }
+
+    public static List<PackageInfo> extractExportedPackages(final Manifest m) {
+        return extractPackages(m, Constants.EXPORT_PACKAGE, "0.0.0", false);
+    }
+
+    public static List<PackageInfo> extractImportedPackages(final Manifest m) {
+        return extractPackages(m, Constants.IMPORT_PACKAGE, null, true);
+    }
+
+    public static List<PackageInfo> extractDynamicImportedPackages(final Manifest m)
{
+        return extractPackages(m, Constants.DYNAMICIMPORT_PACKAGE, null, false);
+    }
+}

Propchange: felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/featureutil/ManifestUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/featureutil/ManifestUtil.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Added: felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/featureutil/PackageInfo.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/featureutil/PackageInfo.java?rev=1810301&view=auto
==============================================================================
--- felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/featureutil/PackageInfo.java
(added)
+++ felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/featureutil/PackageInfo.java
Mon Oct  2 07:27:11 2017
@@ -0,0 +1,108 @@
+/*
+ * 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.felix.maven.osgicheck.impl.featureutil;
+
+import org.osgi.framework.Version;
+import org.osgi.framework.VersionRange;
+
+/*
+ * This is a copy of the Apache Sling Feature PackageInfo class.
+ * We keep this copy until the feature module is released in Sling.
+ */
+public class PackageInfo implements Comparable<PackageInfo> {
+
+    private final boolean optional;
+    private final String name;
+    private final String version;
+
+    public PackageInfo(final String name, final String version, final boolean optional) {
+        this.name = name;
+        this.version = version;
+        this.optional = optional;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    public boolean isOptional() {
+        return optional;
+    }
+
+    public Version getPackageVersion() {
+        return new Version(this.version);
+    }
+
+    public VersionRange getPackageVersionRange() {
+        return new VersionRange(this.version);
+    }
+
+    @Override
+    public String toString() {
+        return "Package " + name
+                + ";version=" + version
+                + (this.optional ? " (optional)" : "");
+    }
+
+    @Override
+    public int compareTo(final PackageInfo o) {
+        int result = this.name.compareTo(o.name);
+        if ( result == 0 ) {
+            result = this.version.compareTo(o.version);
+        }
+        return result;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + (optional ? 1231 : 1237);
+        result = prime * result + ((version == null) ? 0 : version.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        PackageInfo other = (PackageInfo) obj;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (optional != other.optional)
+            return false;
+        if (version == null) {
+            if (other.version != null)
+                return false;
+        } else if (!version.equals(other.version))
+            return false;
+        return true;
+    }
+
+}

Propchange: felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/featureutil/PackageInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/cziegeler/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/featureutil/PackageInfo.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url



Mime
View raw message