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

StringIndexOutOfBoundsException in custom ant task referencing 'basedir'

    Details

    • Type: Bug Bug
    • Status: Closed 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)
    • Testcase included:
      yes
    • Number of attachments :
      3

      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>

        Activity

        Hide
        Marcel Schutte added a comment -

        The attached file 'AntPropertyHelper.patch' contains a patch for this bug. 'basedir' was treated the same way as 'project.xxxx' properties were.

        While testing this fix, I found another problem with properties of the following format 'project.xxxx.yyyy'. First AntPropertyHelper would trim this to 'xxxx.yyyy'. After that, ReflectionValueExtractor.evaluate(String, Object) would trim this to 'yyyy' because it delegates to ReflectionValueExtractor.evaluate(String, Object, true). I've modified AntPropertyHelper to always use the three-arg evaluate() method for clarity.

        The basedir property is now resolved as 'mavenproject.getBasedir().getPath()'

        Please use the attached project-zip 'CustomAntTask-extra-tests.zip' to test. Before applying the patch the result for me is:

        C:\work\CustomAntTask>mvn -Dproject.cmdline=commandlineparameter 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]
        [INFO] Nothing to compile - all classes are up to date
        [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:\work\CustomAntTask\target\CustomAntTask-1.0-SNAPSHOT.jar
        [INFO] [antrun:run

        {execution: testant}

        ]
        [INFO] Executing tasks
        [echo] basedir:C:\work\CustomAntTask
        [echo] sourceDirectory:src/main/java
        sourceDirectory:null
        project.cmdline:commandlineparameter
        [WARNING] Error evaluating expression 'basedir'
        java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(String.java:1768)
        at java.lang.String.substring(String.java:1735)
        at org.apache.maven.plugin.antrun.AntPropertyHelper.getPropertyHook(AntPropertyHelper.java:5
        1)
        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:13)
        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(DefaultLifec
        ycleExecutor.java:472)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.
        java:451)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultL
        ifecycleExecutor.java:303)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleE
        xecutor.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:585)
        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:1768)
        at java.lang.String.substring(String.java:1735)
        at org.apache.maven.plugin.antrun.AntPropertyHelper.getPropertyHook(AntPropertyHelper.java:5
        1)
        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:13)
        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(DefaultLifec
        ycleExecutor.java:472)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.
        java:451)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultL
        ifecycleExecutor.java:303)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleE
        xecutor.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:585)
        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:\work\CustomAntTask
        [INFO] Executed tasks
        [INFO] ----------------------------------------------------------------------------
        [INFO] BUILD SUCCESSFUL
        [INFO] ----------------------------------------------------------------------------
        [INFO] Total time: 4 seconds
        [INFO] Finished at: Fri Dec 23 00:19:53 CET 2005
        [INFO] Final Memory: 4M/9M
        [INFO] ----------------------------------------------------------------------------

        C:\work\CustomAntTask>

        This is the original exception, but it also shows the result of trying to get 'project.build.sourceDirectory' from within the ant-task.

        After applying the patch the result is:

        C:\work\CustomAntTask>mvn -Dproject.cmdline=commandlineparameter 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]
        [INFO] Nothing to compile - all classes are up to date
        [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:\work\CustomAntTask\target\CustomAntTask-1.0-SNAPSHOT.jar
        [INFO] [antrun:run

        {execution: testant}

        ]
        [INFO] Executing tasks
        [echo] basedir:C:\work\CustomAntTask
        [echo] sourceDirectory:src/main/java
        sourceDirectory:C:\work\CustomAntTask\src\main\java
        project.cmdline:commandlineparameter
        basedir:C:\work\CustomAntTask
        [INFO] Executed tasks
        [INFO] ----------------------------------------------------------------------------
        [INFO] BUILD SUCCESSFUL
        [INFO] ----------------------------------------------------------------------------
        [INFO] Total time: 4 seconds
        [INFO] Finished at: Fri Dec 23 00:29:40 CET 2005
        [INFO] Final Memory: 4M/9M
        [INFO] ----------------------------------------------------------------------------

        C:\work\CustomAntTask>

        The three properties that are read in the ant task are correct now.

        The only strange thing is that $

        {project.build.sourceDirectory}

        when used in pom.xml returns a relative path and getProperty("project.build.sourceDirectory") is absolute. Ideas? anybody?

        Show
        Marcel Schutte added a comment - The attached file 'AntPropertyHelper.patch' contains a patch for this bug. 'basedir' was treated the same way as 'project.xxxx' properties were. While testing this fix, I found another problem with properties of the following format 'project.xxxx.yyyy'. First AntPropertyHelper would trim this to 'xxxx.yyyy'. After that, ReflectionValueExtractor.evaluate(String, Object) would trim this to 'yyyy' because it delegates to ReflectionValueExtractor.evaluate(String, Object, true). I've modified AntPropertyHelper to always use the three-arg evaluate() method for clarity. The basedir property is now resolved as 'mavenproject.getBasedir().getPath()' Please use the attached project-zip 'CustomAntTask-extra-tests.zip' to test. Before applying the patch the result for me is: C:\work\CustomAntTask>mvn -Dproject.cmdline=commandlineparameter 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] [INFO] Nothing to compile - all classes are up to date [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:\work\CustomAntTask\target\CustomAntTask-1.0-SNAPSHOT.jar [INFO] [antrun:run {execution: testant} ] [INFO] Executing tasks [echo] basedir:C:\work\CustomAntTask [echo] sourceDirectory:src/main/java sourceDirectory:null project.cmdline:commandlineparameter [WARNING] Error evaluating expression 'basedir' java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1768) at java.lang.String.substring(String.java:1735) at org.apache.maven.plugin.antrun.AntPropertyHelper.getPropertyHook(AntPropertyHelper.java:5 1) 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:13) 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(DefaultLifec ycleExecutor.java:472) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor. java:451) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultL ifecycleExecutor.java:303) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleE xecutor.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:585) 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:1768) at java.lang.String.substring(String.java:1735) at org.apache.maven.plugin.antrun.AntPropertyHelper.getPropertyHook(AntPropertyHelper.java:5 1) 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:13) 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(DefaultLifec ycleExecutor.java:472) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor. java:451) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultL ifecycleExecutor.java:303) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleE xecutor.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:585) 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:\work\CustomAntTask [INFO] Executed tasks [INFO] ---------------------------------------------------------------------------- [INFO] BUILD SUCCESSFUL [INFO] ---------------------------------------------------------------------------- [INFO] Total time: 4 seconds [INFO] Finished at: Fri Dec 23 00:19:53 CET 2005 [INFO] Final Memory: 4M/9M [INFO] ---------------------------------------------------------------------------- C:\work\CustomAntTask> This is the original exception, but it also shows the result of trying to get 'project.build.sourceDirectory' from within the ant-task. After applying the patch the result is: C:\work\CustomAntTask>mvn -Dproject.cmdline=commandlineparameter 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] [INFO] Nothing to compile - all classes are up to date [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:\work\CustomAntTask\target\CustomAntTask-1.0-SNAPSHOT.jar [INFO] [antrun:run {execution: testant} ] [INFO] Executing tasks [echo] basedir:C:\work\CustomAntTask [echo] sourceDirectory:src/main/java sourceDirectory:C:\work\CustomAntTask\src\main\java project.cmdline:commandlineparameter basedir:C:\work\CustomAntTask [INFO] Executed tasks [INFO] ---------------------------------------------------------------------------- [INFO] BUILD SUCCESSFUL [INFO] ---------------------------------------------------------------------------- [INFO] Total time: 4 seconds [INFO] Finished at: Fri Dec 23 00:29:40 CET 2005 [INFO] Final Memory: 4M/9M [INFO] ---------------------------------------------------------------------------- C:\work\CustomAntTask> The three properties that are read in the ant task are correct now. The only strange thing is that $ {project.build.sourceDirectory} when used in pom.xml returns a relative path and getProperty("project.build.sourceDirectory") is absolute. Ideas? anybody?
        Hide
        Carlos Sanchez added a comment -

        Added testcase as test5

        Show
        Carlos Sanchez added a comment - Added testcase as test5

          People

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

            Dates

            • Created:
              Updated:
              Resolved: