felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Felix Meschberger (JIRA)" <j...@apache.org>
Subject [jira] Commented: (FELIX-2681) NPE in assertMinScrAnnotationArtifactVersion when checking min. version of annotations dependency
Date Tue, 02 Nov 2010 19:42:25 GMT

    [ https://issues.apache.org/jira/browse/FELIX-2681?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12927566#action_12927566
] 

Felix Meschberger commented on FELIX-2681:
------------------------------------------

This is weird -- I cannot reproduce. What version of Maven are you using ?

Nevertheless, a potential patch could be:

diff --git a/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java
b/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescri
index 8517989..cf412be 100644
--- a/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java
+++ b/scrplugin/maven-scr-plugin/src/main/java/org/apache/felix/scrplugin/mojo/SCRDescriptorMojo.java
@@ -246,7 +246,20 @@ public class SCRDescriptorMojo extends AbstractMojo {
             // compare version number
             try
             {
+                // try to find out the artifact's version
                 ArtifactVersion aVersion = a.getSelectedVersion();
+                if (aVersion == null)
+                {
+                    String version = a.getVersion();
+                    if (version == null)
+                    {
+                        getLog().error("Cannot find version of " + a + ", assuming 0.0.0");
+                        version = "0.0.0";
+                    }
+                    aVersion = new DefaultArtifactVersion(version);
+                }
+
+                // assert minimal version
                 if (SCR_ANN_MIN_VERSION.compareTo(aVersion) > 0)
                 {
                     getLog().error("Project depends on " + a);


> NPE in assertMinScrAnnotationArtifactVersion when checking min. version of annotations
dependency
> -------------------------------------------------------------------------------------------------
>
>                 Key: FELIX-2681
>                 URL: https://issues.apache.org/jira/browse/FELIX-2681
>             Project: Felix
>          Issue Type: Bug
>          Components: Maven SCR Plugin
>    Affects Versions:  maven-scr-plugin-1.6.0
>         Environment: windows 7 64bit
>            Reporter: Stefan Seifert
>            Assignee: Felix Meschberger
>             Fix For: maven-scr-plugin-1.6.2
>
>
> i tested the scr plugin 1.6.0 from the staging repository:
> https://repository.apache.org/content/repositories/orgapachefelix-010/
> with a complex project consisting of mutliple osgi bundles and custom annotation tag
providers.
> compiling this set of maven projects/osgi bundles fails with this stackstrace:
> java.lang.NullPointerException
>         at org.apache.maven.artifact.DefaultArtifact.getSelectedVersion(DefaultArtifact.java:621)
>         at org.apache.felix.scrplugin.mojo.SCRDescriptorMojo.assertMinScrAnnotationArtifactVersion(SCRDescriptorMojo.java:249)
>         at org.apache.felix.scrplugin.mojo.SCRDescriptorMojo.getClassPath(SCRDescriptorMojo.java:216)
>         at org.apache.felix.scrplugin.mojo.SCRDescriptorMojo.execute(SCRDescriptorMojo.java:167)
>         at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
>         at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>         at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>         at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
>         at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> the annotations dependeny is declared like this:
>       <dependency>
>         <groupId>org.apache.felix</groupId>
>         <artifactId>org.apache.felix.scr.annotations</artifactId>
>         <version>1.4.0</version>
>         <scope>compile</scope>
>       </dependency>
> debugging shows that the "versionrange" member variable of the artifact is null.
> if i change the version declaration to 
>         <version>[1.4.0,)</version>
> the stacktrace changes:
> java.lang.NullPointerException
>         at org.apache.maven.artifact.versioning.DefaultArtifactVersion.compareTo(DefaultArtifactVersion.java:54)
>         at org.apache.felix.scrplugin.mojo.SCRDescriptorMojo.assertMinScrAnnotationArtifactVersion(SCRDescriptorMojo.java:250)
>         at org.apache.felix.scrplugin.mojo.SCRDescriptorMojo.getClassPath(SCRDescriptorMojo.java:216)
>         at org.apache.felix.scrplugin.mojo.SCRDescriptorMojo.execute(SCRDescriptorMojo.java:167)
>         at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
>         at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
>         at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>         at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>         at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
>         at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> because the value returned by getSelectedVersion() is null.
> please note: the annotation depency is not declared in the project that fails to compile,
but in a project the failing project depends upon (transitive dependency).
> looking on the documentation of the Artifact interface i'm not sure if the getSelectedVersion()
method is really intended to be used by plugins.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message