1

I have a task called prePublishCheck which ensures that the Git working tree isn't dirty before publishing a JAR to Artifactory, which is supposed to run before the publish task in an AutoPlugin.

How can I get SBT to run this task before publish?

The following code has no effect with at least sbt 1.1.5:

// Has no effect on `publish`
prePublishCheck := { throw new Exception("test") },
publish := (prePublishCheck before publish).value

// Has no effect on `publish`
prePublishCheck := { throw new Exception("test") },
prePublishCheck := (prePublishCheck before publish).value

These similar answers are obsolete:

Neil
  • 24,551
  • 15
  • 60
  • 81
  • `dependsOn` is not obsolete. have you tried to use it? – laughedelic May 18 '18 at 00:01
  • You might want to look at the [_SBT Release_](https://github.com/sbt/sbt-release) plugin, which does something similar to what you want—and a whole lot more—and which also allows customization of the release process. – Mike Allen May 18 '18 at 02:11
  • @laughedelic How would you use `dependsOn` for the `publish` task? I couldn't find any examples to make it work. – Neil Jun 14 '18 at 19:28
  • 1
    You can write something like `publish := publish.dependsOn(prePublishCheck).value` – laughedelic Jun 14 '18 at 22:33

0 Answers0