mirror of https://github.com/sbt/sbt.git
Cross-compile plugins for sbt 1.0.0-M5
This commit is contained in:
parent
14fd1997aa
commit
1ad06cf407
|
|
@ -24,14 +24,17 @@ install:
|
|||
build_script:
|
||||
- sbt ++2.11.11 clean compile coreJVM/publishLocal http-server/publishLocal
|
||||
- sbt ++2.10.6 clean compile
|
||||
- sbt ++2.10.6 coreJVM/publishLocal cache/publishLocal # to make the scripted tests happy
|
||||
- sbt ++2.12.1 coreJVM/publishLocal cache/publishLocal # to make the scripted sbt 1.0 tests happy
|
||||
- sbt ++2.10.6 coreJVM/publishLocal cache/publishLocal # to make the scripted sbt 0.13 tests happy
|
||||
test_script:
|
||||
- ps: Start-Job -filepath .\scripts\start-it-auth-server.ps1 -ArgumentList $pwd
|
||||
- ps: Start-Sleep -s 15 # wait for the first server to have downloaded its dependencies
|
||||
- ps: Start-Job -filepath .\scripts\start-it-no-listing-server.ps1 -ArgumentList $pwd
|
||||
- sbt ++2.12.1 testsJVM/test testsJVM/it:test # Would node be around for testsJS/test?
|
||||
- sbt ++2.11.11 testsJVM/test testsJVM/it:test
|
||||
- sbt ++2.10.6 testsJVM/test testsJVM/it:test sbt-coursier/scripted sbt-coursier/publishLocal sbt-shading/scripted
|
||||
- sbt ++2.10.6 testsJVM/test testsJVM/it:test
|
||||
- sbt ++2.12.1 sbt-coursier/scripted sbt-coursier/publishLocal sbt-shading/scripted # for sbt 1.0
|
||||
- sbt ++2.10.6 sbt-coursier/scripted sbt-coursier/publishLocal sbt-shading/scripted # for sbt 0.13
|
||||
cache:
|
||||
- C:\Users\appveyor\.ivy2\cache
|
||||
- C:\Users\appveyor\.m2
|
||||
|
|
|
|||
|
|
@ -138,9 +138,48 @@ object CoursierSettings {
|
|||
}
|
||||
}
|
||||
|
||||
lazy val divertThingsPlugin = {
|
||||
|
||||
val actualSbtBinaryVersion = Def.setting(
|
||||
sbtBinaryVersion.in(pluginCrossBuild).value.split('.').take(2).mkString(".")
|
||||
)
|
||||
|
||||
val sbtPluginScalaVersions = Map(
|
||||
"0.13" -> "2.10",
|
||||
"1.0" -> "2.12"
|
||||
)
|
||||
|
||||
val sbtScalaVersionMatch = Def.setting {
|
||||
val sbtVer = actualSbtBinaryVersion.value
|
||||
val scalaVer = scalaBinaryVersion.value
|
||||
|
||||
sbtPluginScalaVersions.get(sbtVer).toSeq.contains(scalaVer)
|
||||
}
|
||||
|
||||
Seq(
|
||||
baseDirectory := {
|
||||
if (sbtScalaVersionMatch.value)
|
||||
baseDirectory.value
|
||||
else
|
||||
baseDirectory.value / "dummy"
|
||||
},
|
||||
publish := {
|
||||
if (sbtScalaVersionMatch.value)
|
||||
publish.value
|
||||
},
|
||||
publishLocal := {
|
||||
if (sbtScalaVersionMatch.value)
|
||||
publishLocal.value
|
||||
},
|
||||
publishArtifact := {
|
||||
sbtScalaVersionMatch.value && publishArtifact.value
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
lazy val plugin =
|
||||
javaScalaPluginShared ++
|
||||
Publish.dontPublishIn("2.11", "2.12") ++
|
||||
divertThingsPlugin ++
|
||||
withScriptedTests ++
|
||||
Seq(
|
||||
scriptedLaunchOpts ++= Seq(
|
||||
|
|
@ -150,7 +189,20 @@ object CoursierSettings {
|
|||
"-Dsbttest.base=" + (sourceDirectory.value / "sbt-test").getAbsolutePath
|
||||
),
|
||||
scriptedBufferLog := false,
|
||||
sbtPlugin := (scalaBinaryVersion.value == "2.10"),
|
||||
sbtPlugin := {
|
||||
scalaBinaryVersion.value match {
|
||||
case "2.10" | "2.12" => true
|
||||
case _ => false
|
||||
}
|
||||
},
|
||||
scalaVersion := appConfiguration.value.provider.scalaProvider.version, // required with sbt 0.13.16-M1, to avoid cyclic references
|
||||
sbtVersion := {
|
||||
scalaBinaryVersion.value match {
|
||||
case "2.10" => "0.13.8"
|
||||
case "2.12" => "1.0.0-M5"
|
||||
case _ => sbtVersion.value
|
||||
}
|
||||
},
|
||||
resolvers ++= Seq(
|
||||
// added so that 2.10 artifacts of the other modules can be found by
|
||||
// the too-naive-for-now inter-project resolver of the coursier SBT plugin
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
sbt.version=0.13.15
|
||||
sbt.version=0.13.16-M1
|
||||
|
|
|
|||
|
|
@ -0,0 +1,120 @@
|
|||
package coursier
|
||||
|
||||
import scala.language.implicitConversions
|
||||
|
||||
object SbtCompatibility {
|
||||
|
||||
val GetClassifiersModule = sbt.GetClassifiersModule
|
||||
type GetClassifiersModule = sbt.GetClassifiersModule
|
||||
|
||||
object SbtPomExtraProperties {
|
||||
def POM_INFO_KEY_PREFIX = sbt.mavenint.SbtPomExtraProperties.POM_INFO_KEY_PREFIX
|
||||
}
|
||||
|
||||
type MavenRepository = sbt.MavenRepository
|
||||
|
||||
type IvySbt = sbt.IvySbt
|
||||
|
||||
type Binary = sbt.CrossVersion.Binary
|
||||
type Disabled = sbt.CrossVersion.Disabled.type
|
||||
type Full = sbt.CrossVersion.Full
|
||||
|
||||
implicit class ModuleIDOps(val id: sbt.ModuleID) extends AnyVal {
|
||||
def withConfigurations(configurations: Option[String]): sbt.ModuleID =
|
||||
id.copy(configurations = configurations)
|
||||
def withExtraAttributes(extraAttributes: Map[String, String]): sbt.ModuleID =
|
||||
id.copy(extraAttributes = extraAttributes)
|
||||
}
|
||||
|
||||
implicit class ArtifactOps(val artifact: sbt.Artifact) extends AnyVal {
|
||||
def withType(`type`: String): sbt.Artifact =
|
||||
artifact.copy(`type` = `type`)
|
||||
def withExtension(extension: String): sbt.Artifact =
|
||||
artifact.copy(extension = extension)
|
||||
def withClassifier(classifier: Option[String]): sbt.Artifact =
|
||||
artifact.copy(classifier = classifier)
|
||||
def withUrl(url: Option[sbt.URL]): sbt.Artifact =
|
||||
artifact.copy(url = url)
|
||||
def withExtraAttributes(extraAttributes: Map[String, String]): sbt.Artifact =
|
||||
artifact.copy(extraAttributes = extraAttributes)
|
||||
}
|
||||
|
||||
implicit def toModuleReportOps(report: sbt.ModuleReport): sbt.ModuleReportOps =
|
||||
new sbt.ModuleReportOps(report)
|
||||
|
||||
implicit class ConfigurationOps(val config: sbt.Configuration) extends AnyVal {
|
||||
def withExtendsConfigs(extendsConfigs: Vector[sbt.Configuration]): sbt.Configuration =
|
||||
config.copy(extendsConfigs = extendsConfigs.toList)
|
||||
}
|
||||
|
||||
implicit class CallerCompanionOps(val companion: sbt.Caller.type) extends AnyVal {
|
||||
def apply(
|
||||
caller: sbt.ModuleID,
|
||||
callerConfigurations: Vector[String],
|
||||
callerExtraAttributes: Map[String, String],
|
||||
isForceDependency: Boolean,
|
||||
isChangingDependency: Boolean,
|
||||
isTransitiveDependency: Boolean,
|
||||
isDirectlyForceDependency: Boolean
|
||||
): sbt.Caller =
|
||||
new sbt.Caller(
|
||||
caller,
|
||||
callerConfigurations,
|
||||
callerExtraAttributes,
|
||||
isForceDependency,
|
||||
isChangingDependency,
|
||||
isTransitiveDependency,
|
||||
isDirectlyForceDependency
|
||||
)
|
||||
}
|
||||
|
||||
implicit class ConfigurationReportCompanionOps(val companion: sbt.ConfigurationReport.type) extends AnyVal {
|
||||
def apply(
|
||||
configuration: String,
|
||||
modules: Seq[sbt.ModuleReport],
|
||||
details: Seq[sbt.OrganizationArtifactReport]
|
||||
): sbt.ConfigurationReport =
|
||||
new sbt.ConfigurationReport(
|
||||
configuration,
|
||||
modules,
|
||||
details,
|
||||
Nil
|
||||
)
|
||||
}
|
||||
|
||||
implicit class UpdateReportCompanionOps(val companion: sbt.UpdateReport.type) extends AnyVal {
|
||||
def apply(
|
||||
cachedDescriptor: java.io.File,
|
||||
configurations: Seq[sbt.ConfigurationReport],
|
||||
stats: sbt.UpdateStats,
|
||||
stamps: Map[java.io.File, Long]
|
||||
): sbt.UpdateReport =
|
||||
new sbt.UpdateReport(
|
||||
cachedDescriptor,
|
||||
configurations,
|
||||
stats,
|
||||
stamps
|
||||
)
|
||||
}
|
||||
|
||||
implicit class UpdateStatsCompanionOps(val companion: sbt.UpdateStats.type) extends AnyVal {
|
||||
def apply(
|
||||
resolveTime: Long,
|
||||
downloadTime: Long,
|
||||
downloadSize: Long,
|
||||
cached: Boolean
|
||||
): sbt.UpdateStats =
|
||||
new sbt.UpdateStats(
|
||||
resolveTime,
|
||||
downloadTime,
|
||||
downloadSize,
|
||||
cached
|
||||
)
|
||||
}
|
||||
|
||||
implicit def configVectorToList(configs: Vector[sbt.Configuration]): List[sbt.Configuration] =
|
||||
configs.toList
|
||||
implicit def configListToVector(configs: List[sbt.Configuration]): Vector[sbt.Configuration] =
|
||||
configs.toVector
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package sbt
|
||||
|
||||
// put under the sbt namespace to access private[sbt] things (the copy method used below)
|
||||
|
||||
class ModuleReportOps(val report: sbt.ModuleReport) extends AnyVal {
|
||||
def withPublicationDate(publicationDate: Option[java.util.Calendar]): sbt.ModuleReport =
|
||||
report.copy(publicationDate = publicationDate.map(_.getTime))
|
||||
def withHomepage(homepage: Option[String]): sbt.ModuleReport =
|
||||
report.copy(homepage = homepage)
|
||||
def withExtraAttributes(extraAttributes: Map[String, String]): sbt.ModuleReport =
|
||||
report.copy(extraAttributes = extraAttributes)
|
||||
def withConfigurations(configurations: Vector[String]): sbt.ModuleReport =
|
||||
report.copy(configurations = configurations)
|
||||
def withLicenses(licenses: Vector[(String, Option[String])]): sbt.ModuleReport =
|
||||
report.copy(licenses = licenses)
|
||||
def withCallers(callers: Vector[sbt.Caller]): sbt.ModuleReport =
|
||||
report.copy(callers = callers)
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package coursier
|
||||
|
||||
object SbtCompatibility {
|
||||
|
||||
val GetClassifiersModule = sbt.internal.librarymanagement.GetClassifiersModule
|
||||
type GetClassifiersModule = sbt.internal.librarymanagement.GetClassifiersModule
|
||||
|
||||
object SbtPomExtraProperties {
|
||||
def POM_INFO_KEY_PREFIX = sbt.internal.librarymanagement.mavenint.SbtPomExtraProperties.POM_INFO_KEY_PREFIX
|
||||
}
|
||||
|
||||
type MavenRepository = sbt.librarymanagement.MavenRepository
|
||||
|
||||
type IvySbt = sbt.internal.librarymanagement.IvySbt
|
||||
|
||||
type Binary = sbt.librarymanagement.Binary
|
||||
type Disabled = sbt.librarymanagement.Disabled
|
||||
type Full = sbt.librarymanagement.Full
|
||||
|
||||
implicit class BinaryOps(private val binary: Binary) extends AnyVal {
|
||||
def remapVersion(scalaBinaryVersion: String): String =
|
||||
scalaBinaryVersion
|
||||
}
|
||||
|
||||
implicit class FullOps(private val full: Full) extends AnyVal {
|
||||
def remapVersion(scalaVersion: String): String =
|
||||
scalaVersion
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -47,12 +47,12 @@ object CoursierPlugin extends AutoPlugin {
|
|||
import autoImport._
|
||||
|
||||
lazy val treeSettings = Seq(
|
||||
coursierDependencyTree <<= Tasks.coursierDependencyTreeTask(
|
||||
coursierDependencyTree := Tasks.coursierDependencyTreeTask(
|
||||
inverse = false
|
||||
),
|
||||
coursierDependencyInverseTree <<= Tasks.coursierDependencyTreeTask(
|
||||
).value,
|
||||
coursierDependencyInverseTree := Tasks.coursierDependencyTreeTask(
|
||||
inverse = true
|
||||
)
|
||||
).value
|
||||
)
|
||||
|
||||
def makeIvyXmlBefore[T](
|
||||
|
|
@ -82,48 +82,48 @@ object CoursierPlugin extends AutoPlugin {
|
|||
coursierTtl := Cache.defaultTtl,
|
||||
coursierVerbosity := Settings.defaultVerbosityLevel(sLog.value),
|
||||
mavenProfiles := Set.empty,
|
||||
coursierResolvers <<= Tasks.coursierResolversTask,
|
||||
coursierRecursiveResolvers <<= Tasks.coursierRecursiveResolversTask,
|
||||
coursierSbtResolvers <<= externalResolvers in updateSbtClassifiers,
|
||||
coursierResolvers := Tasks.coursierResolversTask.value,
|
||||
coursierRecursiveResolvers := Tasks.coursierRecursiveResolversTask.value,
|
||||
coursierSbtResolvers := externalResolvers.in(updateSbtClassifiers).value,
|
||||
coursierUseSbtCredentials := true,
|
||||
coursierCredentials := Map.empty,
|
||||
coursierFallbackDependencies <<= Tasks.coursierFallbackDependenciesTask,
|
||||
coursierFallbackDependencies := Tasks.coursierFallbackDependenciesTask.value,
|
||||
coursierCache := Cache.default,
|
||||
coursierArtifacts <<= Tasks.artifactFilesOrErrors(withClassifiers = false),
|
||||
coursierClassifiersArtifacts <<= Tasks.artifactFilesOrErrors(
|
||||
coursierArtifacts := Tasks.artifactFilesOrErrors(withClassifiers = false).value,
|
||||
coursierClassifiersArtifacts := Tasks.artifactFilesOrErrors(
|
||||
withClassifiers = true
|
||||
),
|
||||
coursierSbtClassifiersArtifacts <<= Tasks.artifactFilesOrErrors(
|
||||
).value,
|
||||
coursierSbtClassifiersArtifacts := Tasks.artifactFilesOrErrors(
|
||||
withClassifiers = true,
|
||||
sbtClassifiers = true
|
||||
),
|
||||
).value,
|
||||
makeIvyXmlBefore(deliverLocalConfiguration, shadedConfigOpt),
|
||||
makeIvyXmlBefore(deliverConfiguration, shadedConfigOpt),
|
||||
update <<= Tasks.updateTask(
|
||||
update := Tasks.updateTask(
|
||||
shadedConfigOpt,
|
||||
withClassifiers = false
|
||||
),
|
||||
updateClassifiers <<= Tasks.updateTask(
|
||||
).value,
|
||||
updateClassifiers := Tasks.updateTask(
|
||||
shadedConfigOpt,
|
||||
withClassifiers = true,
|
||||
ignoreArtifactErrors = true
|
||||
),
|
||||
updateSbtClassifiers in Defaults.TaskGlobal <<= Tasks.updateTask(
|
||||
).value,
|
||||
updateSbtClassifiers.in(Defaults.TaskGlobal) := Tasks.updateTask(
|
||||
shadedConfigOpt,
|
||||
withClassifiers = true,
|
||||
sbtClassifiers = true,
|
||||
ignoreArtifactErrors = true
|
||||
),
|
||||
coursierProject <<= Tasks.coursierProjectTask,
|
||||
coursierInterProjectDependencies <<= Tasks.coursierInterProjectDependenciesTask,
|
||||
coursierPublications <<= Tasks.coursierPublicationsTask(packageConfigs: _*),
|
||||
coursierSbtClassifiersModule <<= classifiersModule in updateSbtClassifiers,
|
||||
coursierConfigurations <<= Tasks.coursierConfigurationsTask(None),
|
||||
coursierParentProjectCache <<= Tasks.parentProjectCacheTask,
|
||||
coursierResolution <<= Tasks.resolutionTask(),
|
||||
coursierSbtClassifiersResolution <<= Tasks.resolutionTask(
|
||||
).value,
|
||||
coursierProject := Tasks.coursierProjectTask.value,
|
||||
coursierInterProjectDependencies := Tasks.coursierInterProjectDependenciesTask.value,
|
||||
coursierPublications := Tasks.coursierPublicationsTask(packageConfigs: _*).value,
|
||||
coursierSbtClassifiersModule := classifiersModule.in(updateSbtClassifiers).value,
|
||||
coursierConfigurations := Tasks.coursierConfigurationsTask(None).value,
|
||||
coursierParentProjectCache := Tasks.parentProjectCacheTask.value,
|
||||
coursierResolution := Tasks.resolutionTask().value,
|
||||
coursierSbtClassifiersResolution := Tasks.resolutionTask(
|
||||
sbtClassifiers = true
|
||||
)
|
||||
).value
|
||||
)
|
||||
|
||||
override lazy val projectSettings = coursierSettings(None, Seq(Compile, Test).map(c => c -> c.name)) ++
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
package coursier
|
||||
|
||||
import coursier.ivy.IvyRepository
|
||||
import coursier.ivy.IvyXml.{ mappings => ivyXmlMappings }
|
||||
|
||||
import java.net.{ MalformedURLException, URL }
|
||||
import coursier.ivy.IvyXml.{mappings => ivyXmlMappings}
|
||||
import java.net.{MalformedURLException, URL}
|
||||
|
||||
import coursier.core.Authentication
|
||||
import sbt.{ Resolver, CrossVersion, ModuleID }
|
||||
import sbt.mavenint.SbtPomExtraProperties
|
||||
import sbt.{CrossVersion, ModuleID, Resolver}
|
||||
|
||||
import SbtCompatibility._
|
||||
|
||||
object FromSbt {
|
||||
|
||||
|
|
@ -24,9 +24,9 @@ object FromSbt {
|
|||
scalaVersion: => String,
|
||||
scalaBinaryVersion: => String
|
||||
): String = crossVersion match {
|
||||
case CrossVersion.Disabled => name
|
||||
case f: CrossVersion.Full => name + "_" + f.remapVersion(scalaVersion)
|
||||
case f: CrossVersion.Binary => name + "_" + f.remapVersion(scalaBinaryVersion)
|
||||
case _: Disabled => name
|
||||
case f: Full => name + "_" + f.remapVersion(scalaVersion)
|
||||
case b: Binary => name + "_" + b.remapVersion(scalaBinaryVersion)
|
||||
}
|
||||
|
||||
def attributes(attr: Map[String, String]): Map[String, String] =
|
||||
|
|
@ -178,20 +178,20 @@ object FromSbt {
|
|||
authentication: Option[Authentication]
|
||||
): Option[Repository] =
|
||||
resolver match {
|
||||
case sbt.MavenRepository(_, root) =>
|
||||
mavenRepositoryOpt(root, log, authentication)
|
||||
case r: SbtCompatibility.MavenRepository =>
|
||||
mavenRepositoryOpt(r.root, log, authentication)
|
||||
|
||||
case sbt.FileRepository(_, _, patterns)
|
||||
if patterns.ivyPatterns.lengthCompare(1) == 0 &&
|
||||
patterns.artifactPatterns.lengthCompare(1) == 0 =>
|
||||
case r: sbt.FileRepository
|
||||
if r.patterns.ivyPatterns.lengthCompare(1) == 0 &&
|
||||
r.patterns.artifactPatterns.lengthCompare(1) == 0 =>
|
||||
|
||||
val mavenCompatibleBaseOpt0 = mavenCompatibleBaseOpt(patterns)
|
||||
val mavenCompatibleBaseOpt0 = mavenCompatibleBaseOpt(r.patterns)
|
||||
|
||||
mavenCompatibleBaseOpt0 match {
|
||||
case None =>
|
||||
Some(IvyRepository(
|
||||
"file://" + patterns.artifactPatterns.head,
|
||||
metadataPatternOpt = Some("file://" + patterns.ivyPatterns.head),
|
||||
"file://" + r.patterns.artifactPatterns.head,
|
||||
metadataPatternOpt = Some("file://" + r.patterns.ivyPatterns.head),
|
||||
changing = Some(true),
|
||||
properties = ivyProperties,
|
||||
dropInfoAttributes = true,
|
||||
|
|
@ -201,17 +201,17 @@ object FromSbt {
|
|||
mavenRepositoryOpt("file://" + mavenCompatibleBase, log, authentication)
|
||||
}
|
||||
|
||||
case sbt.URLRepository(_, patterns)
|
||||
if patterns.ivyPatterns.lengthCompare(1) == 0 &&
|
||||
patterns.artifactPatterns.lengthCompare(1) == 0 =>
|
||||
case r: sbt.URLRepository
|
||||
if r.patterns.ivyPatterns.lengthCompare(1) == 0 &&
|
||||
r.patterns.artifactPatterns.lengthCompare(1) == 0 =>
|
||||
|
||||
val mavenCompatibleBaseOpt0 = mavenCompatibleBaseOpt(patterns)
|
||||
val mavenCompatibleBaseOpt0 = mavenCompatibleBaseOpt(r.patterns)
|
||||
|
||||
mavenCompatibleBaseOpt0 match {
|
||||
case None =>
|
||||
Some(IvyRepository(
|
||||
patterns.artifactPatterns.head,
|
||||
metadataPatternOpt = Some(patterns.ivyPatterns.head),
|
||||
r.patterns.artifactPatterns.head,
|
||||
metadataPatternOpt = Some(r.patterns.ivyPatterns.head),
|
||||
changing = None,
|
||||
properties = ivyProperties,
|
||||
dropInfoAttributes = true,
|
||||
|
|
@ -6,13 +6,15 @@ import org.apache.ivy.core.module.id.ModuleRevisionId
|
|||
import scala.collection.JavaConverters._
|
||||
import scala.xml.{Node, PrefixedAttribute}
|
||||
|
||||
import SbtCompatibility._
|
||||
|
||||
object IvyXml {
|
||||
|
||||
// These are required for publish to be fine, later on.
|
||||
def writeFiles(
|
||||
currentProject: Project,
|
||||
shadedConfigOpt: Option[(String, String)],
|
||||
ivySbt: sbt.IvySbt,
|
||||
ivySbt: IvySbt,
|
||||
log: sbt.Logger
|
||||
): Unit = {
|
||||
|
||||
|
|
@ -4,12 +4,13 @@ import java.io.File
|
|||
import java.net.URL
|
||||
|
||||
import coursier.core.Publication
|
||||
|
||||
import sbt.{ GetClassifiersModule, Resolver, SettingKey, TaskKey }
|
||||
import sbt.{Resolver, SettingKey, TaskKey}
|
||||
|
||||
import scala.concurrent.duration.Duration
|
||||
import scalaz.\/
|
||||
|
||||
import SbtCompatibility._
|
||||
|
||||
object Keys {
|
||||
val coursierParallelDownloads = SettingKey[Int]("coursier-parallel-downloads")
|
||||
val coursierMaxIterations = SettingKey[Int]("coursier-max-iterations")
|
||||
|
|
@ -7,7 +7,7 @@ import scala.language.implicitConversions
|
|||
// things from sbt-structure
|
||||
object Structure {
|
||||
|
||||
def structure(state: State): BuildStructure =
|
||||
def structure(state: State) =
|
||||
sbt.Project.structure(state)
|
||||
|
||||
implicit class `enrich SettingKey`[T](key: SettingKey[T]) {
|
||||
|
|
@ -418,7 +418,7 @@ object Tasks {
|
|||
|
||||
def resolutionTask(
|
||||
sbtClassifiers: Boolean = false
|
||||
) = Def.task {
|
||||
): Def.Initialize[sbt.Task[coursier.Resolution]] = Def.task {
|
||||
|
||||
// let's update only one module at once, for a better output
|
||||
// Downloads are already parallel, no need to parallelize further anyway
|
||||
|
|
@ -7,6 +7,8 @@ import coursier.maven.MavenSource
|
|||
|
||||
import sbt._
|
||||
|
||||
import SbtCompatibility._
|
||||
|
||||
object ToSbt {
|
||||
|
||||
private def caching[K, V](f: K => V): K => V = {
|
||||
|
|
@ -28,26 +30,28 @@ object ToSbt {
|
|||
sbt.ModuleID(
|
||||
dependency.module.organization,
|
||||
dependency.module.name,
|
||||
dependency.version,
|
||||
configurations = Some(dependency.configuration),
|
||||
extraAttributes = dependency.module.attributes ++ extraProperties
|
||||
dependency.version
|
||||
).withConfigurations(
|
||||
Some(dependency.configuration)
|
||||
).withExtraAttributes(
|
||||
dependency.module.attributes ++ extraProperties
|
||||
)
|
||||
}
|
||||
|
||||
val artifact = caching[(Module, Map[String, String], Artifact), sbt.Artifact] {
|
||||
case (module, extraProperties, artifact) =>
|
||||
sbt.Artifact(
|
||||
module.name,
|
||||
sbt.Artifact(module.name)
|
||||
// FIXME Get these two from publications
|
||||
artifact.attributes.`type`,
|
||||
MavenSource.typeExtension(artifact.attributes.`type`),
|
||||
Some(artifact.attributes.classifier)
|
||||
.filter(_.nonEmpty)
|
||||
.orElse(MavenSource.typeDefaultClassifierOpt(artifact.attributes.`type`)),
|
||||
Nil,
|
||||
Some(url(artifact.url)),
|
||||
module.attributes ++ extraProperties
|
||||
)
|
||||
.withType(artifact.attributes.`type`)
|
||||
.withExtension(MavenSource.typeExtension(artifact.attributes.`type`))
|
||||
.withClassifier(
|
||||
Some(artifact.attributes.classifier)
|
||||
.filter(_.nonEmpty)
|
||||
.orElse(MavenSource.typeDefaultClassifierOpt(artifact.attributes.`type`))
|
||||
)
|
||||
// .withConfigurations(Vector())
|
||||
.withUrl(Some(url(artifact.url)))
|
||||
.withExtraAttributes(module.attributes ++ extraProperties)
|
||||
}
|
||||
|
||||
val moduleReport = caching[(Dependency, Seq[(Dependency, Project)], Project, Seq[(Artifact, Option[File])]), sbt.ModuleReport] {
|
||||
|
|
@ -63,12 +67,12 @@ object ToSbt {
|
|||
}
|
||||
|
||||
val publicationDate = project.info.publication.map { dt =>
|
||||
new GregorianCalendar(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second).getTime
|
||||
new GregorianCalendar(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)
|
||||
}
|
||||
|
||||
val callers = dependees.map {
|
||||
case (dependee, dependeeProj) =>
|
||||
new Caller(
|
||||
Caller(
|
||||
ToSbt.moduleId(dependee, dependeeProj.properties.toMap),
|
||||
dependeeProj.configurations.keys.toVector,
|
||||
dependee.module.attributes ++ dependeeProj.properties,
|
||||
|
|
@ -80,26 +84,26 @@ object ToSbt {
|
|||
)
|
||||
}
|
||||
|
||||
new sbt.ModuleReport(
|
||||
module = ToSbt.moduleId(dependency, project.properties.toMap),
|
||||
artifacts = sbtArtifacts,
|
||||
missingArtifacts = sbtMissingArtifacts,
|
||||
status = None,
|
||||
publicationDate = publicationDate,
|
||||
resolver = None,
|
||||
artifactResolver = None,
|
||||
evicted = false,
|
||||
evictedData = None,
|
||||
evictedReason = None,
|
||||
problem = None,
|
||||
homepage = Some(project.info.homePage).filter(_.nonEmpty),
|
||||
extraAttributes = dependency.module.attributes ++ project.properties,
|
||||
isDefault = None,
|
||||
branch = None,
|
||||
configurations = project.configurations.keys.toVector,
|
||||
licenses = project.info.licenses,
|
||||
callers = callers
|
||||
sbt.ModuleReport(
|
||||
ToSbt.moduleId(dependency, project.properties.toMap),
|
||||
sbtArtifacts.toVector,
|
||||
sbtMissingArtifacts.toVector
|
||||
)
|
||||
// .withStatus(None)
|
||||
.withPublicationDate(publicationDate)
|
||||
// .withResolver(None)
|
||||
// .withArtifactResolver(None)
|
||||
// .withEvicted(false)
|
||||
// .withEvictedData(None)
|
||||
// .withEvictedReason(None)
|
||||
// .withProblem(None)
|
||||
.withHomepage(Some(project.info.homePage).filter(_.nonEmpty))
|
||||
.withExtraAttributes(dependency.module.attributes ++ project.properties)
|
||||
// .withIsDefault(None)
|
||||
// .withBranch(None)
|
||||
.withConfigurations(project.configurations.keys.toVector)
|
||||
.withLicenses(project.info.licenses.toVector)
|
||||
.withCallers(callers.toVector)
|
||||
}
|
||||
|
||||
private def grouped[K, V](map: Seq[(K, V)]): Map[K, Seq[V]] =
|
||||
|
|
@ -190,18 +194,17 @@ object ToSbt {
|
|||
|
||||
val reports = ToSbt.moduleReports(subRes, classifiersOpt, artifactFileOpt, keepPomArtifact)
|
||||
|
||||
new ConfigurationReport(
|
||||
ConfigurationReport(
|
||||
config,
|
||||
reports.toVector,
|
||||
Nil,
|
||||
Nil
|
||||
Vector()
|
||||
)
|
||||
}
|
||||
|
||||
new UpdateReport(
|
||||
UpdateReport(
|
||||
null,
|
||||
configReports.toVector,
|
||||
new UpdateStats(-1L, -1L, -1L, cached = false),
|
||||
UpdateStats(-1L, -1L, -1L, cached = false),
|
||||
Map.empty
|
||||
)
|
||||
}
|
||||
|
|
@ -6,6 +6,8 @@ import coursier.ivy.IvyXml.{mappings => ivyXmlMappings}
|
|||
import sbt.Keys._
|
||||
import sbt.{AutoPlugin, Compile, Configuration, TaskKey, inConfig}
|
||||
|
||||
import SbtCompatibility._
|
||||
|
||||
object ShadingPlugin extends AutoPlugin {
|
||||
|
||||
override def trigger = noTrigger
|
||||
|
|
@ -13,10 +15,10 @@ object ShadingPlugin extends AutoPlugin {
|
|||
override def requires = sbt.plugins.IvyPlugin
|
||||
|
||||
private val baseSbtConfiguration = Compile
|
||||
val Shading = Configuration("shading", "", isPublic = false, List(baseSbtConfiguration), transitive = true)
|
||||
val Shading = Configuration("shading", "", isPublic = false, Vector(baseSbtConfiguration), transitive = true)
|
||||
|
||||
private val baseDependencyConfiguration = "compile"
|
||||
val Shaded = Configuration("shaded", "", isPublic = true, List(), transitive = true)
|
||||
val Shaded = Configuration("shaded", "", isPublic = true, Vector(), transitive = true)
|
||||
|
||||
// make that a setting?
|
||||
val shadingNamespace = TaskKey[String]("shading-namespace")
|
||||
|
|
@ -53,17 +55,17 @@ object ShadingPlugin extends AutoPlugin {
|
|||
lazy val shadingDefaultArtifactTasks =
|
||||
makePom +: Seq(packageBin, packageSrc, packageDoc).map(_.in(Shading))
|
||||
lazy val shadingJvmPublishSettings = Seq(
|
||||
artifacts <<= sbt.Classpaths.artifactDefs(shadingDefaultArtifactTasks),
|
||||
packagedArtifacts <<= sbt.Classpaths.packaged(shadingDefaultArtifactTasks)
|
||||
artifacts := sbt.Classpaths.artifactDefs(shadingDefaultArtifactTasks).value,
|
||||
packagedArtifacts := sbt.Classpaths.packaged(shadingDefaultArtifactTasks).value
|
||||
)
|
||||
|
||||
import CoursierPlugin.autoImport._
|
||||
|
||||
override lazy val projectSettings =
|
||||
Seq(
|
||||
coursierConfigurations <<= Tasks.coursierConfigurationsTask(
|
||||
coursierConfigurations := Tasks.coursierConfigurationsTask(
|
||||
Some(baseDependencyConfiguration -> Shaded.name)
|
||||
),
|
||||
).value,
|
||||
ivyConfigurations := Shaded +: ivyConfigurations.value.map {
|
||||
conf =>
|
||||
if (conf.name == "compile")
|
||||
|
|
@ -87,7 +89,7 @@ object ShadingPlugin extends AutoPlugin {
|
|||
configuration := baseSbtConfiguration, // wuw
|
||||
ivyConfigurations := ivyConfigurations.in(baseSbtConfiguration).value
|
||||
.filter(_.name != Shaded.name)
|
||||
.map(c => c.copy(extendsConfigs = c.extendsConfigs.filter(_.name != Shaded.name))),
|
||||
.map(c => c.withExtendsConfigs(c.extendsConfigs.filter(_.name != Shaded.name))),
|
||||
libraryDependencies := libraryDependencies.in(baseSbtConfiguration).value.filter { dep =>
|
||||
val isShaded = dep.configurations.exists { mappings =>
|
||||
ivyXmlMappings(mappings).exists(_._1 == Shaded.name)
|
||||
|
|
@ -62,6 +62,10 @@ is211() {
|
|||
echo "$SCALA_VERSION" | grep -q "^2\.11"
|
||||
}
|
||||
|
||||
is212() {
|
||||
echo "$SCALA_VERSION" | grep -q "^2\.12"
|
||||
}
|
||||
|
||||
runSbtCoursierTests() {
|
||||
sbt ++$SCALA_VERSION coreJVM/publishLocal cache/publishLocal sbt-coursier/scripted
|
||||
}
|
||||
|
|
@ -174,7 +178,7 @@ else
|
|||
jvmCompile
|
||||
runJvmTests
|
||||
|
||||
if is210; then
|
||||
if is210 || is212; then
|
||||
runSbtCoursierTests
|
||||
runSbtShadingTests
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in New Issue