Last active
March 7, 2018 00:19
-
-
Save retronym/e0beca2da1150a57c584f83d7da0d82a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put this in
~/.sbt/0.13/plugins/ArgsFile.scala