Maven:install jar file during build process
Asked Answered
M

3

12

I have got a requirement as follows. I need to run ant build file during maven build process. I need to invoke the build.xml from my pom.xml file. I have done that using maven-antrun-plugin. Now I need to install the ant build generated jar file automatically into my local repository before maven compiles my project source. I tried using build-helper-maven-plugin but it did not help. Either I am doing something wrong, or i am not doing right. Please help.

Update

Thank you. ant maven tasks worked for me as well. However I am runing into the following exception at the end of the build process. Any help is highly appreciated. org.apache.tools.ant.ExitException: Permission (java.lang.RuntimePermission exitVM) was not granted. at org.apache.tools.ant.types.Permissions$MySM.checkExit(Permissions.java:196) at java.lang.Runtime.exit(Runtime.java:99) at java.lang.System.exit(System.java:275) at org.codehaus.classworlds.Launcher.main(Launcher.java:376) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:599) at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217) at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152) at org.apache.tools.ant.taskdefs.Java.run(Java.java:771) at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221) at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135) at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108) at org.apache.maven.artifact.ant.Mvn.execute(Mvn.java:81) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:599) 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:390) at org.apache.tools.ant.Target.performTasks(Target.java:411) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399) at org.apache.tools.ant.Project.executeTarget(Project.java:1368) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1251) at org.apache.tools.ant.Main.runBuild(Main.java:809) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Mudguard answered 14/1, 2011 at 1:8 Comment(0)
T
19

I have encountered the same exception as posted above when I was invoking Maven from within an Ant script using artifact:mvn task. I managed to get rid of it by adding the fork="true" to the task invocation as follows:

<artifact:mvn pom="path/to/my-pom.xml" mavenHome="/path/to/maven-2.0.x" fork="true">
    <arg value="install"/>
</artifact:mvn>
Transarctic answered 21/12, 2011 at 10:14 Comment(0)
K
0

If all that your project source needs is access to the contents generated by the ant build, you can use build-helper-maven-plugin to attach the source.

If the contents of the ant build is needed as a dependency, then you should probably move the ant related code to a separate project and build it.

If more details are provided, perhaps, someone can provide a better solution.

Kettie answered 14/1, 2011 at 2:55 Comment(0)
S
0

Take a look at Maven Ant Tasks which is the cousin of maven-antrun-plugin. It allows to invoke some Maven functionalities from ant, like installing your jar into the repository. It worked well for me with an hybrid build half Maven, half Ant.

Stricker answered 14/1, 2011 at 3:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.