mirror of https://github.com/sbt/sbt.git
Automatically add maven-plugin to classpathTypes for sbt plugins (#28)
This commit is contained in:
parent
c8e18af3ef
commit
8d568af4d9
|
|
@ -44,9 +44,13 @@ object CoursierPlugin extends AutoPlugin {
|
|||
@deprecated("Use sbtCoursierVersion instead", "1.1.0-M9")
|
||||
val coursierVersion = sbtCoursierVersion
|
||||
|
||||
val addSbtCoursier = {
|
||||
val addSbtCoursier: Seq[Def.Setting[_]] = {
|
||||
import sbt._
|
||||
addSbtPlugin("io.get-coursier" % "sbt-coursier" % sbtCoursierVersion)
|
||||
Seq(
|
||||
addSbtPlugin("io.get-coursier" % "sbt-coursier" % sbtCoursierVersion),
|
||||
// seems needed for some sbt plugins (https://github.com/coursier/coursier/issues/450)
|
||||
classpathTypes += "maven-plugin"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
scalaVersion := "2.12.8"
|
||||
enablePlugins(JavaAppPackaging)
|
||||
|
||||
lazy val check = taskKey[Unit]("")
|
||||
|
||||
check := {
|
||||
val cmd = "target/universal/stage/bin/maven-plugin-classpath-type"
|
||||
val cmd0 =
|
||||
if (sys.props("os.name").toLowerCase(java.util.Locale.ROOT).contains("windows"))
|
||||
cmd + ".bat"
|
||||
else
|
||||
cmd
|
||||
val b = new ProcessBuilder(cmd0)
|
||||
b.inheritIO()
|
||||
val p = b.start()
|
||||
val retCode = p.waitFor()
|
||||
assert(retCode == 0, s"Command $cmd returned code $retCode")
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
addSbtCoursier
|
||||
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.3")
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
addSbtPlugin {
|
||||
|
||||
val name = sys.props.getOrElse(
|
||||
"plugin.name",
|
||||
sys.error("plugin.name Java property not set")
|
||||
)
|
||||
val version = sys.props.getOrElse(
|
||||
"plugin.version",
|
||||
sys.error("plugin.version Java property not set")
|
||||
)
|
||||
|
||||
"io.get-coursier" % name % version
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
|
||||
object Main extends App {
|
||||
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
$ delete output
|
||||
> stage
|
||||
> check
|
||||
$ exists output
|
||||
$ delete output
|
||||
|
|
@ -7,7 +7,7 @@ import coursier.sbtcoursiershared.SbtCoursierShared
|
|||
import sbt.{AutoPlugin, Classpaths, Def, Setting, Task, taskKey}
|
||||
import sbt.Project.inTask
|
||||
import sbt.KeyRanks.DTask
|
||||
import sbt.Keys.{appConfiguration, autoScalaLibrary, dependencyResolution, excludeDependencies, scalaBinaryVersion, scalaOrganization, scalaVersion, streams, updateClassifiers, updateSbtClassifiers}
|
||||
import sbt.Keys.{appConfiguration, autoScalaLibrary, classpathTypes, dependencyResolution, excludeDependencies, scalaBinaryVersion, scalaOrganization, scalaVersion, streams, updateClassifiers, updateSbtClassifiers}
|
||||
import sbt.librarymanagement.DependencyResolution
|
||||
|
||||
object LmCoursierPlugin extends AutoPlugin {
|
||||
|
|
@ -17,9 +17,13 @@ object LmCoursierPlugin extends AutoPlugin {
|
|||
object autoImport {
|
||||
val coursierConfiguration = taskKey[CoursierConfiguration]("General dependency management (Coursier) settings, such as the resolvers and options to use.").withRank(DTask)
|
||||
|
||||
val addSbtCoursier = {
|
||||
val addSbtCoursier: Seq[Def.Setting[_]] = {
|
||||
import sbt._
|
||||
addSbtPlugin("io.get-coursier" % "sbt-lm-coursier" % sbtCoursierVersion)
|
||||
Seq(
|
||||
addSbtPlugin("io.get-coursier" % "sbt-lm-coursier" % sbtCoursierVersion),
|
||||
// seems needed for some sbt plugins (https://github.com/coursier/coursier/issues/450)
|
||||
classpathTypes += "maven-plugin"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue