You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2018/09/17 07:47:25 UTC
svn commit: r1841049 - in /felix/trunk/tools/osgicheck-maven-plugin:
README.md pom.xml
src/main/java/org/apache/felix/maven/osgicheck/impl/CheckMojo.java
src/main/java/org/apache/felix/maven/osgicheck/impl/checks/ConsumerProviderTypeCheck.java
Author: cziegeler
Date: Mon Sep 17 07:47:25 2018
New Revision: 1841049
URL: http://svn.apache.org/viewvc?rev=1841049&view=rev
Log:
FELIX-5925 : Add check for packages with versions but without explicit provider/consumer type information
Modified:
felix/trunk/tools/osgicheck-maven-plugin/README.md
felix/trunk/tools/osgicheck-maven-plugin/pom.xml
felix/trunk/tools/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/CheckMojo.java
felix/trunk/tools/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/checks/ConsumerProviderTypeCheck.java
Modified: felix/trunk/tools/osgicheck-maven-plugin/README.md
URL: http://svn.apache.org/viewvc/felix/trunk/tools/osgicheck-maven-plugin/README.md?rev=1841049&r1=1841048&r2=1841049&view=diff
==============================================================================
--- felix/trunk/tools/osgicheck-maven-plugin/README.md (original)
+++ felix/trunk/tools/osgicheck-maven-plugin/README.md Mon Sep 17 07:47:25 2018
@@ -1,7 +1,9 @@
# osgicheck-maven-plugin
Maven Plugin checking several OSGi aspects of your project
-Add this plugin to your plugins section:
+## Perform Checks
+
+Add this plugin to your plugins section to enable checking your project:
```xml
<plugin>
@@ -14,7 +16,52 @@ Add this plugin to your plugins section:
<goals>
<goal>check</goal>
</goals>
+ <configuration>
+ <mode>[DEFAULT|STRICT|ERRORS_ONLY|OFF]</mode>
+ <!-- config needs to be specified as a cdata section -->
+ <config>
+ <![CDATA[
+ <name_of_the_check_task>
+ <skip>[false|true]</skip>
+ <!-- task specific configuration -->
+ </name_of_the_check_task>
+ ]]>
+ </config>
+ </configuration>
</execution>
</executions>
- </plugin>
+ </plugin>
```
+
+## Available Checks
+
+### Import / Export Check
+
+* Name: package
+* Configuration: none
+
+The following checks are performed:
+* Exports without a version (ERROR)
+* Import without a version (range) (WARNING)
+* Dynamic import without a version (range) (WARNING)
+* Dynamic import * (WARNING)
+* Export of private looking package (WARNING)
+
+### Declarative Services Check
+
+* Name: scr
+* Configuration: none
+
+The following checks are performed:
+* Immediate flag
+* Unary references should be greedy
+* References ordering (Not finished yet)
+
+### Usage of ProviderType / ConsumerType
+
+* Name: exportannotation
+* Configuration: none
+
+The following checks are performed:
+* If a package is exported, the classes must be marked with either ConsumerType or ProviderType
+
Modified: felix/trunk/tools/osgicheck-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/tools/osgicheck-maven-plugin/pom.xml?rev=1841049&r1=1841048&r2=1841049&view=diff
==============================================================================
--- felix/trunk/tools/osgicheck-maven-plugin/pom.xml (original)
+++ felix/trunk/tools/osgicheck-maven-plugin/pom.xml Mon Sep 17 07:47:25 2018
@@ -33,7 +33,7 @@
<properties>
<maven.version>3.5.0</maven.version>
- <felix.java.version>8</felix.java.version>
+ <felix.java.version>7</felix.java.version>
</properties>
<prerequisites>
Modified: felix/trunk/tools/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/CheckMojo.java
URL: http://svn.apache.org/viewvc/felix/trunk/tools/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/CheckMojo.java?rev=1841049&r1=1841048&r2=1841049&view=diff
==============================================================================
--- felix/trunk/tools/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/CheckMojo.java (original)
+++ felix/trunk/tools/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/CheckMojo.java Mon Sep 17 07:47:25 2018
@@ -150,59 +150,69 @@ public class CheckMojo extends AbstractM
final Class<?>[] checks = new Class<?>[] {ImportExportCheck.class, SCRCheck.class, ConsumerProviderTypeCheck.class};
for(final Class<?> c : checks) {
+ // instantiate
final Check check = (Check)c.newInstance();
- check.check(new CheckContext() {
- private final Map<String, String> conf;
- {
- if ( configuration != null ) {
- final Xpp3Dom cfg = configuration.getChild(check.getName());
- if ( cfg != null ) {
- final Map<String, String> map = new HashMap<>();
- for(final Xpp3Dom child : cfg.getChildren()) {
- map.put(child.getName(), child.getValue());
- }
- conf = map;
- } else {
- conf = Collections.emptyMap();
- }
- } else {
- conf = Collections.emptyMap();
+ // extract configuration
+ final Map<String, String> config;
+ if ( configuration != null ) {
+ final Xpp3Dom cfg = configuration.getChild(check.getName());
+ if ( cfg != null ) {
+ final Map<String, String> map = new HashMap<>();
+ for(final Xpp3Dom child : cfg.getChildren()) {
+ map.put(child.getName(), child.getValue());
+ }
+ config = map;
+ } else {
+ config = Collections.emptyMap();
+ }
+ } else {
+ config = Collections.emptyMap();
+ }
+ getLog().debug("Configuration for " + check.getName() + " : " + config);
+
+ final String skip = config.get("skip");
+ if ( !Boolean.valueOf(skip) ) {
+ getLog().debug("Executing " + check.getName() + "...");
+ check.check(new CheckContext() {
+
+ private final Map<String, String> conf = config;
+
+ @Override
+ public File getRootDir() {
+ return dir;
}
- getLog().debug("Configuration for " + check.getName() + " : " + conf);
- }
-
- @Override
- public File getRootDir() {
- return dir;
- }
- @Override
- public Manifest getManifest() {
- return mf;
- }
+ @Override
+ public Manifest getManifest() {
+ return mf;
+ }
- @Override
- public Map<String, String> getConfiguration() {
- return conf;
- }
+ @Override
+ public Map<String, String> getConfiguration() {
+ return conf;
+ }
- @Override
- public Log getLog() {
- return CheckMojo.this.getLog();
- }
+ @Override
+ public Log getLog() {
+ return CheckMojo.this.getLog();
+ }
- @Override
- public void reportWarning(String message) {
- warnings.add(message);
- }
+ @Override
+ public void reportWarning(String message) {
+ warnings.add(message);
+ }
- @Override
- public void reportError(String message) {
- errors.add(message);
- }
+ @Override
+ public void reportError(String message) {
+ errors.add(message);
+ }
- });
+ });
+ getLog().debug("Finished " + check.getName() + "...");
+ } else {
+ getLog().debug("Skipping executing " + check.getName());
+ }
}
} catch (final InstantiationException | IllegalAccessException e) {
throw new MojoExecutionException(e.getMessage(), e);
Modified: felix/trunk/tools/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/checks/ConsumerProviderTypeCheck.java
URL: http://svn.apache.org/viewvc/felix/trunk/tools/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/checks/ConsumerProviderTypeCheck.java?rev=1841049&r1=1841048&r2=1841049&view=diff
==============================================================================
--- felix/trunk/tools/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/checks/ConsumerProviderTypeCheck.java (original)
+++ felix/trunk/tools/osgicheck-maven-plugin/src/main/java/org/apache/felix/maven/osgicheck/impl/checks/ConsumerProviderTypeCheck.java Mon Sep 17 07:47:25 2018
@@ -39,14 +39,14 @@ import org.objectweb.asm.tree.ClassNode;
/**
* The following checks are performed:
* <ul>
- * <li>If a package is exported, the interfaces must be marked with either ConsumerType or ProviderType
+ * <li>If a package is exported, the classes must be marked with either ConsumerType or ProviderType
* </ul>
*/
public class ConsumerProviderTypeCheck implements Check {
@Override
public String getName() {
- return "typecheck";
+ return "exportannotation";
}
private boolean include(final File f) {