Karaf
  1. Karaf
  2. KARAF-526

add-features-to-repo: descriptor with file contains spaces on unix

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.1.4
    • Fix Version/s: 4.0.0, 3.0.2
    • Labels:
      None
    • Environment:

      unix

      Description

      Configuration:
      <groupId>org.apache.karaf.tooling</groupId>
      <artifactId>features-maven-plugin</artifactId>
      <executions>
      <execution>
      <goals>
      <goal>add-features-to-repo</goal>
      </goals>
      <configuration>
      <descriptors>
      <descriptor>file:$

      {basedir}/target/classes/activemq-features.xml</descriptor>

      ${basedir}

      contains spaces at target PC. Result:
      Caused by: java.lang.IllegalArgumentException
      at java.net.URI.create(URI.java:842)
      at org.apache.karaf.tooling.features.AddFeaturesToRepoMojo.execute(AddFeaturesToRepoMojo.java:130)

      Looking into sources I found
      org.apache.karaf.tooling.features.MojoSupport.translateFromMaven()
      There is a check for windows and replacement spaces with %20.
      Simple fix:

      } else if (uri.startsWith("file:")) {
      if (System.getProperty("os.name").startsWith("Windows")) {
      String baseDir = uri.substring(5).replace('
      ', '/').replaceAll(" ", "%20");
      String result = baseDir;
      if (baseDir.indexOf(":") > 0)

      { result = "file:///" + baseDir; }

      return result;
      } else

      { return uri.replaceAll(" ", "%20"); }

      }

        Issue Links

          Activity

          Hide
          Jean-Baptiste Onofré added a comment -

          I'm not sure that %20 works in the same way on Windows and Unix.
          Maybe just an escape sequence is enough on Unix: replaceAll(" ", "\ ").

          I'm trying like this.

          Show
          Jean-Baptiste Onofré added a comment - I'm not sure that %20 works in the same way on Windows and Unix. Maybe just an escape sequence is enough on Unix: replaceAll(" ", "\ "). I'm trying like this.
          Hide
          Alexey Markevich added a comment -

          This method called from
          org.apache.karaf.tooling.features.AddFeaturesToRepoMojo.execute() line 130:
          Repository repo = new Repository(URI.create(translateFromMaven(uri)));
          So problem with URI object creation will be solved by replacing spaces with %20

          Show
          Alexey Markevich added a comment - This method called from org.apache.karaf.tooling.features.AddFeaturesToRepoMojo.execute() line 130: Repository repo = new Repository(URI.create(translateFromMaven(uri))); So problem with URI object creation will be solved by replacing spaces with %20
          Hide
          Jean-Baptiste Onofré added a comment -

          Sorry I didn't see that we use an URI. In that case, %20 works fine on an URI (or URL).

          I will update in this way.

          Show
          Jean-Baptiste Onofré added a comment - Sorry I didn't see that we use an URI. In that case, %20 works fine on an URI (or URL). I will update in this way.
          Hide
          David Jencks added a comment -

          Trying to figure out how to encode uris yourself is never going to work as well as what's in the jdk. If you use the right URI constructor the URI will do the encoding for you, with all the necessary escaped characters, correctly. Although the URI javadoc doesn't really explain what to do, you can find the right constructor by looking at the Harmony URI implementation. If no one beats me to it I'll try to find some time to investigate.

          Show
          David Jencks added a comment - Trying to figure out how to encode uris yourself is never going to work as well as what's in the jdk. If you use the right URI constructor the URI will do the encoding for you, with all the necessary escaped characters, correctly. Although the URI javadoc doesn't really explain what to do, you can find the right constructor by looking at the Harmony URI implementation. If no one beats me to it I'll try to find some time to investigate.

            People

            • Assignee:
              Jean-Baptiste Onofré
              Reporter:
              Alexey Markevich
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - 1m
                1m
                Remaining:
                Remaining Estimate - 1m
                1m
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development