You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Guillaume Boué (JIRA)" <ji...@apache.org> on 2017/05/30 22:10:04 UTC
[jira] [Updated] (MANTRUN-197) Can't use ant import task in target
xml
[ https://issues.apache.org/jira/browse/MANTRUN-197?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Guillaume Boué updated MANTRUN-197:
-----------------------------------
Issue Type: Wish (was: Bug)
> Can't use ant import task in target xml
> ---------------------------------------
>
> Key: MANTRUN-197
> URL: https://issues.apache.org/jira/browse/MANTRUN-197
> Project: Maven Antrun Plugin
> Issue Type: Wish
> Affects Versions: 1.8
> Reporter: Christoph Dittberner
>
> I want to externalize a macrodef to include it in different ant excecutions. But using the ant import task throws an exception because the import task has be defined *outside* of a target definition. There seems no way to specify markup outside of or before the autogenerated main target tag to include the import statement in the generated target/ant-run/build-main.xml.
> example to illustrate the problem:
> {code:title=src/ant/macrodef.xml|xml}
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <project name="macrodef">
> <macrodef name="hello">
> <sequential>
> <echo>hello world.</echo>
> </sequential>
> </macrodef>
> </project>
> {code}
> {code:title=pom.xml|xml}
> ...
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-antrun-plugin</artifactId>
> <version>1.8</version>
> <executions>
> <execution>
> <id>call-macrodef-1st</id>
> <phase>process-sources</phase>
> <goals>
> <goal>run</goal>
> </goals>
> <configuration>
> <target>
> <import file="src/ant/macrodef.xml"/>
>
> <hello/>
> </target>
> </configuration>
> </execution>
> <execution>
> <id>call-macrodef-2nd</id>
> <phase>process-sources</phase>
> <goals>
> <goal>run</goal>
> </goals>
> <configuration>
> <target>
> <import file="src/ant/macrodef.xml"/>
>
> <hello/>
> <hello/>
> </target>
> </configuration>
> </execution>
> <executions>
>
> ...
>
> </plugin>
> ...
> {code}
> {code:title=stacktrace}
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (generate-launchers-server) on project project.build.dist: An Ant BuildException has occured: import only allowed as a top-level task
> around Ant part ...<import file="n:\project.build.dist/src/ant/macrodef.xml"/>... @ 4:61 in n:\project.build.dist\target\antrun\build-main.xml
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
> at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
> at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
> at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
> at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
> at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
> at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
> at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
> at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
> at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
> at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
> at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
> Caused by: org.apache.maven.plugin.MojoExecutionException: An Ant BuildException has occured: import only allowed as a top-level task
> around Ant part ...<import file="n:\project.build.dist/src/ant/macrodef.xml"/>... @ 4:61 in n:\project.build.dist\target\antrun\build-main.xml
> at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:342)
> at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
> at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
> ... 20 more
> Caused by: n:\project.build.dist\target\antrun\build-main.xml:4: import only allowed as a top-level task
> at org.apache.tools.ant.taskdefs.ImportTask.execute(ImportTask.java:133)
> at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
> at org.apache.tools.ant.Task.perform(Task.java:348)
> at org.apache.tools.ant.Target.execute(Target.java:435)
> at org.apache.tools.ant.Target.performTasks(Target.java:456)
> at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
> at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
> at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:313)
> ... 22 more
>
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)