2
votes

These are the steps I've followed:

  • I have forked a 3rd party plugin.
  • I have modified it, and run sbt publishLocal successfully.
  • In order to test it, in the plugins.sbt file of a project, I've changed addSbtPlugin("company" % "some-plugin" % "0.6.5") to this:

    lazy val root = project.in( file(".") ).dependsOn(somePlugin)

    lazy val somePlugin = project.in(file(System.getProperty("user.home")+"/customPath/"))

but SBT cannot compile the plugin in this way, because it doesn't find the used plugins of the plugin, even though I've been able to .

I've tried also to reference ~/.sbt/local/...., i.e., the directory where publishLocal has placed the compiled plugin, but no success. I don't know what do I have to reference exactly (the folder, the generated .jar, the ivy.xml file, ...).

Questions:

  • What is the best way of using a locally built plugin?.
  • Why does it compile alone, but doesn't when embedded in my project?.

Notes:

2

2 Answers

1
votes

The solution is simple. I've followed this steps:

  • I fork an existing project
  • I change the organization in order to be unique, and not to clash with the original author. I use something like organization := com.github.myuser
  • I modify the code
  • I create an account in bintray, and follow this guide in order to publish my custom plugin with sbt publish
  • In a sample project, I import my custom plugin, by adding this line in plugins.sbt: addSbtPlugin("com.github.myuser" % "myplugin" % "1.0")
  • If I make a mistake and don't want to increase the version, I make this:

    sbt ;bintray::unpublish;publish

It is very fast, I've had to wait a few seconds. I know nobody else is using my plugin.

Maybe publishLocal is better and doesn't require to work with 3rd party repositories, but I don't know how it works. This works for me instead.

1
votes

A better solution, well suited when the only intention is to test a future pull request:

  • Fork an existing project
  • Change the version to end with -SNAPSHOT
  • Make your changes
  • Invoke sbt publishLocal
  • Create a sample project in order to test it, that references the -SNAPSHOT version
  • In case of recompiling again the project, reload hangs the whole JVM. I have to exit SBT and enter again.
  • When working, make a pull request to the author.

Suggestion: use the scripted test framework in order to leave a working test.