4286

install jar built from ant task into local maven repository

Question:

This is the command I want to run at the end of my Ant script:

mvn install:install-file -Dfile=C:\dev\common\somejar.jar -DgroupId=com.myco.gt -DartifactId=somejar-Dversion=1.0.0 -Dpackaging=jar -DgeneratePOM=true

If I enter the following target at the end of my Ant script:

<target name='install_mvn_dependencies' depends='build_jars'> <exec executable="mvn"> <arg value="install:install-file"/> <arg value="-Dfile=c:\dev\common\somejar.jar"/> <arg value ="-DgroupId=com.myco.gt"/> <arg value="-DartifactId=somejar"/> <arg value="-Dversion=1.2.0"/> <arg value="-Dpackaging=jar"/> <arg value="-DgeneratePOM=true"/> </exec> </target>

I get CreateProcess error=2. The system cannot find the path specified.

even though I can run mvn on the command line. What gives?

Answer1:

The mvn command is actually a batch command, so you can't execute it directly. Try this:

<exec executable="cmd.exe"> <arg value="/c"/> <arg value="mvn.bat"/> <arg value="install:install-file"/> <arg value="-Dfile=c:\dev\common\somejar.jar"/> <arg value ="-DgroupId=com.myco.gt"/> <arg value="-DartifactId=somejar"/> <arg value="-Dversion=1.2.0"/> <arg value="-Dpackaging=jar"/> <arg value="-DgeneratePOM=true"/> </exec>

Answer2:

As it is ant / java, I would expect this: (untested!)

<arg value="-Dfile=c:\\dev\\common\\somejar.jar"/>

Notice the double backslash, else it will be an escape and the path might not be found. IIRC you can also use forward slashes.

<arg value="-Dfile=c:/dev/common/somejar.jar"/>

See also: <a href="https://stackoverflow.com/questions/1799684/ant-produces-jsfl-with-backslashes-instead-of-slashes" rel="nofollow">Ant produces jsfl with backslashes instead of slashes</a>

Recommend

  • How to pass capabilities as a environmental variable to batch script while running the VSTS build de
  • my OS is windows7,i want to build the developing environment of sakai oae
  • Maven project fail to call jar file
  • Restful WebServices in Java using Eclipse, Tomcat and Jersey
  • Cannot run Maven command
  • Maven offline build fails when it encouners google guava url with invalid character
  • Create project from maven archetype via Apache Ivy
  • How to refactor “if” statement into an “unless” statement?
  • Jars Issues in Maven Spring Hibernate Project
  • Missing artifact com.oracle:ojdbc6:jar:11.2.0 ?
  • compare xml files with maven or ant
  • Passing value with spaces as cmd parameter to programs
  • If statements and && or ||
  • How would you add maven to an existing GWT project in Eclipse with m2e installed?
  • Maven deploy secondary file to repository
  • Calculate Sum From Moving 4 Rows in SQL
  • Skip a unit test from a Nose2 Plugin
  • Forcing the user to enter a property using Maven
  • How to preserve alias property while signing app?
  • Does many include's (in “case”) in ASP classic hurt the performance of the server?
  • Simple way to Delete the Last Child of a GameObject
  • C++ calling the default constructor with parens vs without parens [duplicate]
  • TCP Ping in Silverlight
  • How to obtain service credentials for a service instance created on IBM Bluemix without binding the
  • Hakyll says “Dependency cycle detected: …”
  • how to automatically enter password when using ssh?
  • why 0.1+0.2-0.3= 5.5511151231258E-17 in php [duplicate]
  • Yii2: Using Kartik Depdrop Widget?
  • How do you keep a running instance for Google App Engine
  • OOP Javascript - Is “get property” method necessary?
  • Bad request using file_get_contents for PUT request in PHP
  • Illegal mix of collations for operation for date/time comparison
  • SSO with signing and signature validation doesn't work
  • Deserializing XML into class C#
  • How do you join a server to an Active Directory (domain)?
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?