mirror of https://github.com/sbt/sbt.git
**Problem** When using scala-native, we can't enable semanticdb etc because of the platform-level platform. **Solution** Since compilerPlugin(...) is always going to be JVM, just add an explicit JVM platform to the given ModuleID.
This commit is contained in:
parent
03c371db5e
commit
56c3fdbd0b
|
|
@ -4813,8 +4813,8 @@ trait BuildExtra extends BuildCommon with DefExtra {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Transforms `dependency` to be in the auto-compiler plugin configuration. */
|
/** Transforms `dependency` to be in the auto-compiler plugin configuration. */
|
||||||
def compilerPlugin(dependency: ModuleID): ModuleID = {
|
def compilerPlugin(dependency: ModuleID): ModuleID =
|
||||||
dependency.configurations match {
|
dependency.configurations match
|
||||||
case Some(confs) if confs.toLowerCase != "compile" && confs.nonEmpty =>
|
case Some(confs) if confs.toLowerCase != "compile" && confs.nonEmpty =>
|
||||||
sys.error(
|
sys.error(
|
||||||
s"""Configuration-scoped compiler plugins are not supported.
|
s"""Configuration-scoped compiler plugins are not supported.
|
||||||
|
|
@ -4823,9 +4823,10 @@ trait BuildExtra extends BuildCommon with DefExtra {
|
||||||
|The plugin will be applied to all configurations.""".stripMargin
|
|The plugin will be applied to all configurations.""".stripMargin
|
||||||
)
|
)
|
||||||
case _ =>
|
case _ =>
|
||||||
dependency.withConfigurations(Some("plugin->default(compile)"))
|
// Compiler plugins should ignore the subproject platform and use JVM
|
||||||
}
|
dependency
|
||||||
}
|
.withConfigurations(Some("plugin->default(compile)"))
|
||||||
|
.platform(Platform.jvm)
|
||||||
|
|
||||||
/** Adds `dependency` to `libraryDependencies` in the auto-compiler plugin configuration. */
|
/** Adds `dependency` to `libraryDependencies` in the auto-compiler plugin configuration. */
|
||||||
def addCompilerPlugin(dependency: ModuleID): Setting[Seq[ModuleID]] =
|
def addCompilerPlugin(dependency: ModuleID): Setting[Seq[ModuleID]] =
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
package example
|
|
||||||
|
|
||||||
object Hello {
|
|
||||||
def main(args: Array[String]): Unit = {
|
|
||||||
println("Hello!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
ThisBuild / scalaVersion := "2.12.21"
|
|
||||||
|
|
||||||
lazy val check = taskKey[Unit]("")
|
|
||||||
|
|
||||||
lazy val root = (project in file("."))
|
|
||||||
.settings(
|
|
||||||
name := "hello",
|
|
||||||
check := {
|
|
||||||
val rs = scalaCompilerBridgeResolvers.value
|
|
||||||
assert(rs.exists(r => r.name == "Triplequote Maven Releases"))
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
> check
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
package sbtmyplugin
|
|
||||||
|
|
||||||
import sbt._
|
|
||||||
import sbt.Keys._
|
|
||||||
|
|
||||||
object HydraPlugin extends AutoPlugin {
|
|
||||||
override def requires: Plugins = plugins.JvmPlugin
|
|
||||||
override def trigger: PluginTrigger = allRequirements
|
|
||||||
|
|
||||||
override lazy val projectSettings = Seq(
|
|
||||||
resolvers += "Triplequote Maven Releases" at "https://repo.triplequote.com/artifactory/libs-release/",
|
|
||||||
) ++ inConfig(Compile)(compileSettings) ++ inConfig(Test)(compileSettings)
|
|
||||||
|
|
||||||
private lazy val compileSettings: Seq[Def.Setting[_]] = inTask(compile)(compileInputsSettings)
|
|
||||||
|
|
||||||
private def compileInputsSettings: Seq[Setting[_]] = Seq(
|
|
||||||
scalaCompilerBridgeSource := {
|
|
||||||
ModuleID("com.triplequote", "hydra-bridge_1_0", "2.1.4")
|
|
||||||
.withConfigurations(Some(Configurations.Compile.name))
|
|
||||||
.sources()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package example
|
||||||
|
|
||||||
|
case class A()
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
semanticdbEnabled := true
|
||||||
|
scalaVersion := "2.13.18"
|
||||||
|
enablePlugins(ScalaNativePlugin)
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.11")
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
> compile
|
||||||
Loading…
Reference in New Issue