Maven Antrun Plugin
  1. Maven Antrun Plugin
  2. MANTRUN-34

StringIndexOutOfBoundsException in custom ant task referencing 'basedir'

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.1
    • Labels:
      None
    • Environment:
      XP, sun 1.4.2 JDK, maven 2.0.1, maven-antrun-plugin 1.1-SNAPSHOT (built from svn HEAD)

      Description

      A custom ant task that in its java implementation references 'basedir' throws a StringIndexOutOfBoundsException. Executions continues and the result is correct.

      The attached zip contains a M2 project that builds the jar with the ant task and then calls it with the antrun plugin. The result for me is:

      C:\Data\WSAD\POC\CustomAntTask>mvn package
      [INFO] Scanning for projects...
      [INFO] ----------------------------------------------------------------------------
      [INFO] Building Unnamed - nl.ohra.test:CustomAntTask:jar:1.0-SNAPSHOT
      [INFO] task-segment: [package]
      [INFO] ----------------------------------------------------------------------------
      [INFO] [resources:resources]
      [INFO] Using default encoding to copy filtered resources.
      [INFO] [compiler:compile]
      Compiling 1 source file to C:\Data\WSAD\POC\CustomAntTask\target\classes
      [INFO] [resources:testResources]
      [INFO] Using default encoding to copy filtered resources.
      [INFO] [compiler:testCompile]
      [INFO] No sources to compile
      [INFO] [surefire:test]
      [INFO] No tests to run.
      [INFO] [jar:jar]
      [INFO] Building jar: C:\Data\WSAD\POC\CustomAntTask\target\CustomAntTask-1.0-SNAPSHOT.jar
      [INFO] [antrun:run

      {execution: testant}

      ]
      [INFO] Executing tasks
      Trying to override old definition of datatype test
      [WARNING] Error evaluating expression 'basedir'
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      at java.lang.String.substring(String.java:1444)
      at java.lang.String.substring(String.java:1411)
      at org.apache.maven.plugin.antrun.AntPropertyHelper.getPropertyHook(AntPropertyHelper.java:51)
      at org.apache.tools.ant.PropertyHelper.getPropertyHook(PropertyHelper.java:184)
      at org.apache.tools.ant.PropertyHelper.getProperty(PropertyHelper.java:438)
      at org.apache.tools.ant.Project.getProperty(Project.java:474)
      at nl.ohra.test.TestTask.execute(TestTask.java:11)
      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:103)
      at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:83)
      at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:432)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:530)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:47
      2)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:451)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.jav
      a:303)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:270)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:139)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:249)
      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:324)
      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)
      java.lang.StringIndexOutOfBoundsException: String index out of range: -1
      at java.lang.String.substring(String.java:1444)
      at java.lang.String.substring(String.java:1411)
      at org.apache.maven.plugin.antrun.AntPropertyHelper.getPropertyHook(AntPropertyHelper.java:51)
      at org.apache.tools.ant.PropertyHelper.getPropertyHook(PropertyHelper.java:184)
      at org.apache.tools.ant.PropertyHelper.getProperty(PropertyHelper.java:438)
      at org.apache.tools.ant.Project.getProperty(Project.java:474)
      at nl.ohra.test.TestTask.execute(TestTask.java:11)
      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:103)
      at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:83)
      at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:432)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:530)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:47
      2)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:451)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.jav
      a:303)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:270)
      at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:139)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:249)
      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:324)
      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)
      basedir:C:\Data\WSAD\POC\CustomAntTask
      [INFO] Executed tasks
      [INFO] ----------------------------------------------------------------------------
      [INFO] BUILD SUCCESSFUL
      [INFO] ----------------------------------------------------------------------------
      [INFO] Total time: 5 seconds
      [INFO] Finished at: Thu Dec 22 14:59:58 CET 2005
      [INFO] Final Memory: 5M/9M
      [INFO] ----------------------------------------------------------------------------

      C:\Data\WSAD\POC\CustomAntTask>

      1. AntPropertyHelper.patch
        2 kB
        Marcel Schutte
      2. CustomAntTask.zip
        2 kB
        Marcel Schutte
      3. CustomAntTask-extra-tests.zip
        2 kB
        Marcel Schutte

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Carlos Sanchez
            Reporter:
            Marcel Schutte
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development