Uploaded image for project: 'Etch'
  1. Etch
  2. ETCH-69

Compiler throws URISyntaxException if there are spaces in the classpath

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0.2
    • 1.1
    • compiler
    • None
    • Windows XP, java 1.6, maven 2.0.9, ant 1.7.0

    Description

      While trying to write a maven POM that executes the etch task via the antrun plugin, I discovered EtchCompiler throwing an exception if the path to the etch jars contains spaces. This resulted from my M2 repository being located in c:\Documents and Settings\brian\.m2\repository. The output is:

      -
      $ mvn package
      [INFO] Scanning for projects...
      [INFO] ------------------------------------------------------------------------
      [INFO] Building Spawn API Client and Server Interfaces
      [INFO] task-segment: [package]
      [INFO] ------------------------------------------------------------------------
      [INFO] [antrun:run

      {execution: default}

      ]
      [INFO] Executing tasks

      init:

      generate:
      java.net.URISyntaxException: Illegal character in path at index 18: file:/C:/Documents and Settings/brian/.m2/repository/org/apa
      che/maven/plugins/maven-antrun-plugin/1.1/maven-antrun-plugin-1.1.jar
      at java.net.URI$Parser.fail(URI.java:2809)
      at java.net.URI$Parser.checkChars(URI.java:2982)
      at java.net.URI$Parser.parseHierarchical(URI.java:3066)
      at java.net.URI$Parser.parse(URI.java:3014)
      at java.net.URI.<init>(URI.java:578)
      at java.net.URL.toURI(URL.java:918)
      at etch.compiler.EtchCompiler.setupClassLoader(EtchCompiler.java:222)
      at etch.tools.ant.EtchCompileTask.execute(EtchCompileTask.java:245)
      at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
      at org.apache.tools.ant.Task.perform(Task.java:364)
      at org.apache.tools.ant.Target.execute(Target.java:341)
      at org.apache.tools.ant.Target.performTasks(Target.java:369)
      at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
      at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37)
      at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
      at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382)
      at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
      at org.apache.tools.ant.Task.perform(Task.java:364)
      at org.apache.tools.ant.Target.execute(Target.java:341)
      at org.apache.maven.plugin.antrun.AbstractAntMojo.executeTasks(AbstractAntMojo.java:108)
      at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:83)
      at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:540)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:519)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:356)
      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)
      [INFO] ------------------------------------------------------------------------
      [ERROR] BUILD ERROR
      [INFO] ------------------------------------------------------------------------
      [INFO] Error executing ant tasks
      -

      The documentation for URL.toURI() says that it cannot produce a URI if the URL is not RFC 2396 compliant. Using a multi-arg constructor for URI fixes the problem. In EtchCompiler.java, replace line 222 with:
      String scheme = "file";
      int pathBegin = scheme.length() + 1;
      String path = s.substring(pathBegin);
      // multi-arg constructor properly escapes paths
      File f = new File(new URI(scheme, null, path, null));

      Attachments

        Activity

          People

            sccomer Robert Scott Comer
            bsmith94 Brian Smith
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: