I've configured SBT (0.11.0) to pull in a GitHub project as a dependency, as per my answer on this question here.
It works fine except that I can't seem to get SBT to re-compile my Git dependency when it gets updated. In other words: if I make an update to the dependency, push to Git and reload my project's SBT and run package, then SBT does not recompile the external Git dependency when compiling my project.
I've tried creating a new branch in my Git dependency (say, forcenew) and updating the branch in my SBT project configuration to use this:
lazy val depProject = RootProject(uri("git://github.com/me/dep-project.git#forcenew"))
But even this doesn't force a refresh. I'm a bit stumped - I can't even find where SBT puts the Git project to compile it (it doesn't seem to be in ~/.sbt/ or ~/.ivy2/)...
Any help greatly appreciated!
From: https://github.com/sbt/sbt/issues/335
this should be fixed in 0.12.0, just call "sbt update"
It was fixed in 0.12.0 so sbt update is enough, but got back in 13.0 -- for now, you have to wipe dependency from ~/.sbt/staging/ manually
You likely want to clear out ~/.sbt/staging/
A quick hack you can add to your build.sbt:
def removegit = Command.command("removegit"){state =>
val home = sys.env("HOME")
val k = ("rm -rf "+ home + "/.sbt/0.13/staging/").!
state
}
commands ++= Seq(removegit)
And then sbt removegit will wipe that directory. This doesn't do anything smart like checking commits, which would be a great upgrade... The repos are being stored in ~/.sbt/0.13/staging/ on my machine, you may need to adjust that.
Related
When I typed sbt, it displays the information below for very long time..
sbt
Getting org.scala-sbt sbt 0.13.7 ...
But is there a way to show detailed information about (1) how sbt resolves dependencies and (2) which repository every package is downloading from? I tried sbt -v and sbt --verbose but neither works..
To show resolved dependencies, there is an sbt plugin
https://github.com/jrudolph/sbt-dependency-graph
Which repository every package is downloading from
I'm not sure what do you need this information for. If dependency is not available in one repository sbt looks it up in another, until it finds it, or stops with unresolved dependency otherwise. So if you have dependency A in both repositories R1 & R2, source repository might change depending on R1 responsiveness.
I'm trying to use the RootProject feature of SBT to download another project from a git repo, for example:
lazy val schwatcher = RootProject(uri("https://github.com/lloydmeta/schwatcher.git"))
lazy val root = project in file(".") dependsOn schwatcher
This successfully downloads the git repo and basically runs the "sbt compile" command on the git repo, compiling all of the classes. However, I'd like it to go one step beyond running the usual "sbt compile" command. Instead, I want it to run "sbt package" so that a jar file is produced. Is there any way to do this?
Thanks.
Have you tried using the One-Jar SBT plugin? I used it a while back for another project and it was simple to use.
There is also the sbt-assembly plugin, which is more maintained.
How I can delete my project from local repository? I previously published it using publish-local SBT command.
I want to clean all compiled and cached stuff because I don't see any changes in my project after recompiling it and redeploying on server.
If you want to retry sbt publishLocal, add your module version x.x.x-SNAPSHOT.
Run publishLocal again and note where it writes the published jars to. For me, it was ~/.ivy2/local. Removing this directory cleared the locally published repository.
There is a sbt command clean. if you need you can add additional folders to clean task in your build file
cleanFiles <+= baseDirectory { base => base / "temp" }
I've a multi-project structure which builds with sbt 0.11.3. I wanted to centralize my dependency versions, project versions, artifacts, shell prompt stuff and such. It would be really helpful for my plans on release management and version control. So I've created a plugin and put my global configurations there. My projects read it from github and build it as a plugin. Everything is lovely.
./project/project/Build.scala
import sbt._
object PluginDef extends Build {
override lazy val projects = Seq(root)
lazy val root = Project("plugins", file(".")) dependsOn(versionPlugin)
lazy val versionPlugin = uri("git://github.com/config.git") //changed the uri here
}
So sbt fetches the plugins latest version if it haven't been already. Caches that version in ~/.sbt/staging/somehashcode. But I couldn't make it update the project when there are changes in plugin project. I manually go and update it whenever needed. Sadly, in a 20 man team its causing some problems.
How can we make it check for plugin updates?
I haven't tried this, but the following might work.
refreshing plugin
update to sbt 0.12.1, which fixes update
then from sbt shell:
> reload plugins
> update
> reload return
specifying a particular tree
It may be helpful to fix the source dependency to a particular point in time for some situations. If so you can add commit hash or tag as "git://github.com/config.git#hash".
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 file
play update // Update application dependencies
before 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.
I'm not sure how this works, but "another guy told me" - yes, that's the extent of my references for this - that cleaning out the "repository" folder in the play installation might help.
I have a little "refresh.sh" script that does this:
rm -rf /opt/play/repository/cache/com.mycompany
play clean
play update
play run
It seems to work for me. Where "/opt/play" is where you have your play installation and "com.mycompany" is what you need to refresh.
I'm not saying this is right, but it might be worth of shot if nothing else works.
As of sbt version 0.13.6 (Aug 2014), one can use build settings flag updateOptions in Build.scala/build.sbt, to control SNAPSHOT resolution.
updateOptions := updateOptions.value.withLatestSnapshots(false/true)
Documentation about this new feature is here
Corresponding pull request on github for details.