Karaf
  1. Karaf
  2. KARAF-244

features-maven-plugin does not work with maven 3

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.0
    • Fix Version/s: 2.1.3, 2.2.0
    • Component/s: karaf-tooling
    • Labels:
      None

      Description

      Now that maven 3 has been released, I think it is important to get the features-maven-plugin to work under maven 3. The problem is that you normally use "mvn:" url's in the features-maven-plugin, e g:

      <build>
      <plugins>
      <plugin>
      <groupId>org.apache.karaf.tooling</groupId>
      <artifactId>features-maven-plugin</artifactId>
      <executions>
      <execution>
      <id>add-features-to-repo</id>
      <phase>generate-resources</phase>
      <goals>
      <goal>add-features-to-repo</goal>
      </goals>
      <configuration>
      <descriptors>
      <descriptor>mvn:org.apache.karaf/apache-karaf/$

      {karaf-version}

      /xml/features</descriptor>
      </descriptors>
      <features>
      <feature>ssh</feature>
      <feature>management</feature>
      <feature>webconsole</feature>
      </features>
      <repository>$

      {project.build.directory}

      /features-repo</repository>
      </configuration>
      </execution>
      </executions>
      </plugin>

      But the url handler for "mvn:" does not work under maven 3 due to changes in the classpath handling. An alternative must be developed. I've noticed on the ops4j mailing list that something called pax-url-aether is in the works. Maybe that's an option for features-maven-plugin?

      1. maven3.patch
        1 kB
        Andreas Pieber

        Activity

        Hide
        Andreas Pieber added a comment -

        IMHO this issue was already fixed by the pax-url upgrade. At least it works like a charm for me using mvn3

        Show
        Andreas Pieber added a comment - IMHO this issue was already fixed by the pax-url upgrade. At least it works like a charm for me using mvn3
        Hide
        Bengt Rodehav added a comment - - edited

        Andreas,

        I've now tried Karaf 2.1.2 (and the associated features-maven-plugin) together with Maven 3.0.1 but it still doesn't work for me. I get the following output from maven:

        [ERROR] Failed to execute goal org.apache.karaf.tooling:features-maven-plugin:2.1.2:add-features-to-repo (add-features-to-repo) on project assembly: Error populating repository: unknown protocol: null -> [Help 1]

        Show
        Bengt Rodehav added a comment - - edited Andreas, I've now tried Karaf 2.1.2 (and the associated features-maven-plugin) together with Maven 3.0.1 but it still doesn't work for me. I get the following output from maven: [ERROR] Failed to execute goal org.apache.karaf.tooling:features-maven-plugin:2.1.2:add-features-to-repo (add-features-to-repo) on project assembly: Error populating repository: unknown protocol: null -> [Help 1]
        Hide
        Andreas Pieber added a comment -

        What exactly do you do? I tried to reproduce your error doing the following

        a) install mvn 3.0.1
        b) svn co http://svn.apache.org/repos/asf/karaf/branches/karaf-2.1.x/
        c) apply https://issues.apache.org/jira/browse/KARAF-319
        d) mvn clean install

        and it works without any problems

        Show
        Andreas Pieber added a comment - What exactly do you do? I tried to reproduce your error doing the following a) install mvn 3.0.1 b) svn co http://svn.apache.org/repos/asf/karaf/branches/karaf-2.1.x/ c) apply https://issues.apache.org/jira/browse/KARAF-319 d) mvn clean install and it works without any problems
        Hide
        Andreas Pieber added a comment -

        yes... I can reproduce it on my windows machine. Using unix everything works fine... WTF? I give it a shot

        Show
        Andreas Pieber added a comment - yes... I can reproduce it on my windows machine. Using unix everything works fine... WTF? I give it a shot
        Hide
        Bengt Rodehav added a comment -

        Very strange that the behaviour differs between Windows and Unix regarding this. I understand if you're puzzled...

        I wish you happy hunting

        Show
        Bengt Rodehav added a comment - Very strange that the behaviour differs between Windows and Unix regarding this. I understand if you're puzzled... I wish you happy hunting
        Hide
        Andreas Pieber added a comment -

        Ok... I'm comming closer... the problem is burried in org.apache.karaf.tooling.features.MojoSupport

        This method:

            protected String getLocalRepoUrl() {
                 if (System.getProperty("os.name").startsWith("Windows")) {
                     String baseDir = localRepo.getBasedir().replace('\\', '/').replaceAll(" ", "%20");
                     return localRepo.getProtocol() + ":///" + baseDir;
                 } else {
                         return localRepo.getUrl();
                 }
            }
        

        ; or to be more specifc this part:

        localRepo.getProtocol()
        

        return null. This would explain y it always works in linux but not in windows... I've absolutely no idea y this line returns null? Replacing localRepo.getProcol() with "file" works like a charm, but I'm afraid this is not the solution we want to have, do we?

        Show
        Andreas Pieber added a comment - Ok... I'm comming closer... the problem is burried in org.apache.karaf.tooling.features.MojoSupport This method: protected String getLocalRepoUrl() { if ( System .getProperty( "os.name" ).startsWith( "Windows" )) { String baseDir = localRepo.getBasedir().replace('\\', '/').replaceAll( " " , "%20" ); return localRepo.getProtocol() + ": ///" + baseDir; } else { return localRepo.getUrl(); } } ; or to be more specifc this part: localRepo.getProtocol() return null. This would explain y it always works in linux but not in windows... I've absolutely no idea y this line returns null? Replacing localRepo.getProcol() with "file" works like a charm, but I'm afraid this is not the solution we want to have, do we?
        Hide
        Bengt Rodehav added a comment -

        Have you tried to call "localRepo.getUrl()" for Windows?

        Maybe the special treatment of Windows is not needed anymore?

        Show
        Bengt Rodehav added a comment - Have you tried to call "localRepo.getUrl()" for Windows? Maybe the special treatment of Windows is not needed anymore?
        Hide
        Andreas Pieber added a comment -

        mhm windows still needs this "special" treatment... But found a only "half-hacky" workaround:

        return new URL(localRepo.getUrl()).getProtocol() + ":///" + baseDir; works

        I've experimented with whitespaces and alternative repo locations. It seams that this fixes the problem for windows. The trunk contains exactly the same problem. I'll provide a patch within the next minutes.

        Show
        Andreas Pieber added a comment - mhm windows still needs this "special" treatment... But found a only "half-hacky" workaround: return new URL(localRepo.getUrl()).getProtocol() + ":///" + baseDir; works I've experimented with whitespaces and alternative repo locations. It seams that this fixes the problem for windows. The trunk contains exactly the same problem. I'll provide a patch within the next minutes.
        Hide
        Andreas Pieber added a comment -

        btw: the patch applys to karaf-2.1.x and trunk

        Show
        Andreas Pieber added a comment - btw: the patch applys to karaf-2.1.x and trunk
        Hide
        Bengt Rodehav added a comment -

        I tried your patch and my application now builds with maven 3.0.1.

        Thanks a lot for your work. I assume you will check the patch into trunk and that it will be part of the next Karaf release?

        Show
        Bengt Rodehav added a comment - I tried your patch and my application now builds with maven 3.0.1. Thanks a lot for your work. I assume you will check the patch into trunk and that it will be part of the next Karaf release?
        Hide
        Andreas Pieber added a comment -

        I would, but I'm no commiter I hope that the patch make its way in the trunk as well as in a 2.1.3 release since it also affects projects like servicemix

        Show
        Andreas Pieber added a comment - I would, but I'm no commiter I hope that the patch make its way in the trunk as well as in a 2.1.3 release since it also affects projects like servicemix
        Hide
        Andreas Pieber added a comment -

        Verified and works; thanks

        Show
        Andreas Pieber added a comment - Verified and works; thanks

          People

          • Assignee:
            Guillaume Nodet
            Reporter:
            Bengt Rodehav
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development