Skip to content

Instantly share code, notes, and snippets.

@retronym
Last active March 7, 2018 00:19
Show Gist options
  • Save retronym/e0beca2da1150a57c584f83d7da0d82a to your computer and use it in GitHub Desktop.
Save retronym/e0beca2da1150a57c584f83d7da0d82a to your computer and use it in GitHub Desktop.
package io.github.retronym
import sbt._
import Keys._
object SbtArgsFilePlugin extends AutoPlugin {
override def trigger = allRequirements
override def requires = sbt.plugins.JvmPlugin
val argsFileContents = taskKey[String]("Contents of file suitable for `scalac @args.txt`")
val argsFile = taskKey[Unit]("Write compiler command line into an args file suitable for `scalac @target/compile.args`")
override lazy val projectSettings = List(Compile, Test).flatMap(c => inConfig(c)(Seq(
argsFileContents := {
((scalacOptions.value :+ "-classpath" :+ dependencyClasspath.value.map(_.data.toString).mkString(":")) ++ sources.value.distinct).mkString("\n")
},
argsFile := {
val f = target.value / (c.name + ".args")
IO.write(f, argsFileContents.value)
streams.value.log.info("Wrote compiler comand line to: " + f.getAbsolutePath)
}
)))
}
@retronym
Copy link
Author

Put this in ~/.sbt/0.13/plugins/ArgsFile.scala

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment