Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven:install jar file during build process

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)

like image 974
Venkata Avatar asked Jan 14 '11 01:01

Venkata


People also ask

How do I install a Maven JAR file?

With version 2.5 of the maven-install-plugin it gets even better. If the JAR was built by Apache Maven, it'll contain a pom.xml in a subfolder of the META-INF directory, which will be read by default. In that case, all you need to do is: mvn install:install-file -Dfile=<path-to-file>.

What are Maven jars?

What is Maven? Occasionally, you will have 3rd party JARs that you need to put in your local repository for use in your builds, since they don't exist in any public repository like Maven Central. The JARs must be placed in the local repository in the correct place in order for it to be correctly picked up by Apache Maven.

How to install local dependencies into Maven projects?

There are multiple ways we can install local dependencies into maven projects Adding local dependencies systemPath in pom.xml install-file goal is a maven commands used to install local jar files This is easy and simple way to install jar from local repository or path of jar file.

Do I need to learn Maven to build a project?

For the person building a project, this means that it is only necessary to learn a small set of commands to build any Maven project, and the POM will ensure they get the results they desired. There are three built-in build lifecycles: default, clean and site.


1 Answers

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>
like image 71
Stephan Eberle Avatar answered Sep 28 '22 06:09

Stephan Eberle