Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven publish jar to .ivy

Tags:

maven

scala

sbt

I have a maven project, which will produce a jar file, and I want to use it in another sbt project. Is there any method to publish the jar file to .ivy rather than in .m2?

I try to put the jar file in the libs under the sbt project, but it does not work. and use the mvn install the jar to the .m2 does not work too.

like image 326
Djvu Avatar asked Nov 26 '15 02:11

Djvu


1 Answers

As I understand it you have a maven project and an SBT project. The SBT project depends on the artifact produced by your maven project.

You ask how to publish the maven produced artifact to your local .ivy so it can be picked up by the SBT project.

you can probably achieve that using an ant task in the maven build.

However I'd like to suggest different angles :

Make the sbt project aware of the local .m2

Simply add resolvers += Resolver.mavenLocal to your sbt build definition, if you don't want to pollute the main build definition, add that line to a local.sbt file alongside the main build defition. SBT merges all the .sbt files found at the project root.

Publish to a controlled repository

This is especially useful if you want the build to be easily reproduceable outside of your local machine. The idea is simply to publish the maven project to an actual server, either an internal nexus/artifactory server for proprietary code or to a public artefact hosting (such as bintray) I use bintray all the time to publish custom builds of opensource projects while I wait for PRs to be merged in master and published an the official build.

Add your artifact server as a resolver to the SBT project and you are good to go :)

like image 181
Jean Avatar answered Nov 15 '22 23:11

Jean