I'm setting up my very first play app in a mixed build environment. My company uses maven for everything (so far) and I'm trying to get my play app to interact nicely with the rest of my artifacts.
Is there any way to get ivy/sbt/play to deal with SNAPSHOTs in a similar way to maven - namely, either update them from the remote repository always (for example, on a build worker) or use the local .m2 repository until the dependency 'expires' and then refresh it from the server.
I have declared a SNAPSHOT dependency in my Build.scala for an artifact, and I'd like local updates to this dependency to be visible to my play project. On the maven side, I do the following
mvn clean install
which (of course) builds and installs my external artifact to my local maven repository (at ~/.m2/repository). I'd like these changes to be immediately visible to my play project, but I can't figure out how to tell sbt/play to not cache SNAPSHOTs. No matter what I do, this dependency is never refreshed in play - I have to go into the actual play ivy cache and delete the dependency by hand for any changes to be picked up. Ideally, I'd like sbt/ivy to just resolve the path to my local maven repo and not cache it internally. I've got the following in my Build.scala
val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
resolvers += "Local Maven Repository" at "file://" + Path.userHome.absolutePath + "/.m2/repository",
testOptions in Test := Nil
)
When I run a build in play, it properly uses this repo, but then caches the results in the ivy cache. Is there an incantation I can tell Ivy/sbt to not do this? Perhaps something in ivysettings.xml?
@kheraud -> clean /reload/ update -> will not work sbt caches it localy and do not check again for new snapshot in local maven
@dprat -> I have been looking for solution in web and haven't found anything more :(
I gave up - just delete your local package in ivy cache and do play update
you can simplify it and make a script
rm -rf ~/.ivy2/cache/your.package.foo
play update compile
Elsewhere I've seen this ascribed to an SBT defect https://groups.google.com/forum/?fromgroups=#!topic/play-framework/O7_cAdUWQII
One solution seems to be to use Nexus. You will have to deploy from maven to nexus. You will have to use the nexus path instead of mvn. You will have to install and run nexus!
To install nexus go to sonatype and download. Watch file permissions (read the instructions) but it is simple. You will need to put the credentials in ~/.m2/settings.xml. Default is admin, admin123.
<settings>
<servers>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
</settings>
The maven deploy is given to you by nexus, e.g.:
<distributionManagement>
<repository>
<id>releases</id>
<url>http://0.0.0.0:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://0.0.0.0:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
Then mvn deploy
will put your resource there.
Then in the play sbt use
resolvers += "Local Nexus Repository" at "http://0.0.0.0:8081/nexus/content/repositories/snapshots"
You still need to stop play, use play update, and restart play.
You can use:
play reload
// Reload the current application build fileplay update
// Update application dependenciesbefore building your application. I don't know if you can configure sbt to not cache the SNAPSHOT dependencies, but you can script your building process to force reloading dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With