ServiceMix
  1. ServiceMix
  2. SM-2145

jbi-maven-plugin: Artifact unexpectedly filtered

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: jbi-maven-plugin-4.3, jbi-maven-plugin-4.4, jbi-maven-plugin-4.5
    • Fix Version/s: jbi-maven-plugin-4.6
    • Component/s: tooling
    • Labels:
      None

      Description

      Some of the artifacts defined in my project's pom.xml in scope 'compile' are unexpectedly filtered during the generation of a component.
      By debugging the generation process, I have found that this is due to the use of '==' to compare the strings defining two artifact's scopes (GenerateComponentDescriptorMojo.java, line 225). For a reason that I could not establish yet, my artifact as a scope value of 'compile' but the string object is not equal to Artifact.SCOPE_COMPILE.
      I think that one solution for this bug is either to change "artifact.getScope() == Artifact.SCOPE_COMPILE" by "artifact.getScope().equals(Artifact.SCOPE_COMPILE)" or to find the places where the scope of the artifact is set to a value that is not a constant of the class org.apache.maven.artifact.Artifact.

        Activity

        Hide
        Yuriy Sidelnikov added a comment -

        The problem can be fixed by the following patch. Patch has been created for version 4.4
        GenerateComponentMojo.java
        @@ -184,7 +184,7 @@
        ArtifactFilter filter = new ArtifactFilter() {
        public boolean include(Artifact artifact)

        { return !artifact.isOptional() && - (artifact.getScope() == Artifact.SCOPE_RUNTIME || artifact.getScope() == Artifact.SCOPE_COMPILE); + (artifact.getScope().equals(Artifact.SCOPE_RUNTIME) || artifact.getScope().equals(Artifact.SCOPE_COMPILE)); }

        };

        +++ GenerateComponentDescriptorMojo.java
        @@ -224,7 +224,7 @@
        ArtifactFilter filter = new ArtifactFilter() {
        public boolean include(Artifact artifact)

        { return !artifact.isOptional() && - (artifact.getScope() == Artifact.SCOPE_RUNTIME || artifact.getScope() == Artifact.SCOPE_COMPILE); + (artifact.getScope().equals(Artifact.SCOPE_RUNTIME) || artifact.getScope().equals(Artifact.SCOPE_COMPILE)); }

        };

        The "==" operator even for final static strings works fine only if strings were loaded by the same classloader.

        Show
        Yuriy Sidelnikov added a comment - The problem can be fixed by the following patch. Patch has been created for version 4.4 GenerateComponentMojo.java @@ -184,7 +184,7 @@ ArtifactFilter filter = new ArtifactFilter() { public boolean include(Artifact artifact) { return !artifact.isOptional() && - (artifact.getScope() == Artifact.SCOPE_RUNTIME || artifact.getScope() == Artifact.SCOPE_COMPILE); + (artifact.getScope().equals(Artifact.SCOPE_RUNTIME) || artifact.getScope().equals(Artifact.SCOPE_COMPILE)); } }; +++ GenerateComponentDescriptorMojo.java @@ -224,7 +224,7 @@ ArtifactFilter filter = new ArtifactFilter() { public boolean include(Artifact artifact) { return !artifact.isOptional() && - (artifact.getScope() == Artifact.SCOPE_RUNTIME || artifact.getScope() == Artifact.SCOPE_COMPILE); + (artifact.getScope().equals(Artifact.SCOPE_RUNTIME) || artifact.getScope().equals(Artifact.SCOPE_COMPILE)); } }; The "==" operator even for final static strings works fine only if strings were loaded by the same classloader.
        Hide
        Mateusz Prokopowicz added a comment -

        The same problem occurs in GenerateComponentMojo (line: 186) - there are references compared instead of objects. I've attached a patch with the fix

        Show
        Mateusz Prokopowicz added a comment - The same problem occurs in GenerateComponentMojo (line: 186) - there are references compared instead of objects. I've attached a patch with the fix

          People

          • Assignee:
            Jean-Baptiste Onofré
            Reporter:
            Julien Blass
          • Votes:
            5 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:

              Time Tracking

              Estimated:
              Original Estimate - 0.5h
              0.5h
              Remaining:
              Remaining Estimate - 0.5h
              0.5h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development