Re: How to run the mvn install command on sbt scala file.

288 views
Skip to first unread message

Robin Green

unread,
Oct 17, 2012, 4:31:11 AM10/17/12
to simple-b...@googlegroups.com
OK, I think what you mean is you have an sbt project which depends on a separate Maven project or subproject, and you'd like to build the Maven project as one step of building the sbt project. I would first like to suggest an alternative approach (which is admittedly more complicated, but I think is more in line with "industry best practice"). You could have, in a Jenkins or Hudson build server, a project for your sbt project, which depends on a project for the Maven project. So when any changes to the Maven project are made, Jenkins or Hudson will automatically rebuild the sbt project, after the Maven project has been successfully rebuilt. But it won't unnecessarily rebuild or republish the Maven project (at least, not if you configure the Maven project in Jenkins/Hudson to poll SCM).

IMPORTANT: Note that if you have a central Maven server for your company or team, it is not necessary for every developer who checks out the sbt project to build the Maven project. So that objection is easily dealt with. However, you do then have to configure sbt to check your company or team Maven server. Which can be a bit of a pain (see past threads ad nauseum).

Personally, I like to have my own Jenkins server (running on localhost), so I can run a "proper" build before pushing code to the main repository, to check that I'm not going to break the build.

Anyway, if you still want to do it the way you asked for, you can just run arbitrary shell commands from sbt, so, you can just do this (in Scala >= 2.9.1):

 import scala.sys.process._ 
 "mvn install" !

I think there is a different way to do it in older versions of Scala.

On Tuesday, 16 October 2012 13:10:36 UTC+1, Madhuri reddy wrote:
Want to run the maven install command  from  " project /build.scala"   sbt file .
 
mavenProject
       | pom.xml
 
val mavenprojectname = task {{
//Here i need to run the maven command to run the project and get the jars in my local .m2 ropo.
}
 
 
 
 
Reply all
Reply to author
Forward
0 new messages