From 1ad06cf407a69b1ecdbfa356d7dc4c643ed1c938 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Tue, 2 May 2017 22:06:19 +0200 Subject: [PATCH 1/4] Cross-compile plugins for sbt 1.0.0-M5 --- appveyor.yml | 7 +- project/CoursierSettings.scala | 56 +++++++- project/build.properties | 2 +- .../coursier/SbtCompatibility.scala | 120 ++++++++++++++++++ .../main/scala-2.10/sbt/ModuleReportOps.scala | 18 +++ .../coursier/SbtCompatibility.scala | 30 +++++ .../coursier/CoursierPlugin.scala | 56 ++++---- .../coursier/Credentials.scala | 0 .../FallbackDependenciesRepository.scala | 0 .../coursier/FromSbt.scala | 44 +++---- .../coursier/InterProjectRepository.scala | 0 .../coursier/IvyXml.scala | 4 +- .../{scala-2.10 => scala}/coursier/Keys.scala | 5 +- .../coursier/ResolutionError.scala | 0 .../coursier/ResolutionException.scala | 0 .../coursier/SbtBootJars.scala | 0 .../coursier/Settings.scala | 0 .../coursier/Structure.scala | 2 +- .../coursier/Tasks.scala | 2 +- .../coursier/ToSbt.scala | 83 ++++++------ .../coursier/Shading.scala | 0 .../coursier/ShadingPlugin.scala | 16 ++- scripts/travis.sh | 6 +- 23 files changed, 343 insertions(+), 108 deletions(-) create mode 100644 sbt-coursier/src/main/scala-2.10/coursier/SbtCompatibility.scala create mode 100644 sbt-coursier/src/main/scala-2.10/sbt/ModuleReportOps.scala create mode 100644 sbt-coursier/src/main/scala-2.12/coursier/SbtCompatibility.scala rename sbt-coursier/src/main/{scala-2.10 => scala}/coursier/CoursierPlugin.scala (72%) rename sbt-coursier/src/main/{scala-2.10 => scala}/coursier/Credentials.scala (100%) rename sbt-coursier/src/main/{scala-2.10 => scala}/coursier/FallbackDependenciesRepository.scala (100%) rename sbt-coursier/src/main/{scala-2.10 => scala}/coursier/FromSbt.scala (82%) rename sbt-coursier/src/main/{scala-2.10 => scala}/coursier/InterProjectRepository.scala (100%) rename sbt-coursier/src/main/{scala-2.10 => scala}/coursier/IvyXml.scala (98%) rename sbt-coursier/src/main/{scala-2.10 => scala}/coursier/Keys.scala (97%) rename sbt-coursier/src/main/{scala-2.10 => scala}/coursier/ResolutionError.scala (100%) rename sbt-coursier/src/main/{scala-2.10 => scala}/coursier/ResolutionException.scala (100%) rename sbt-coursier/src/main/{scala-2.10 => scala}/coursier/SbtBootJars.scala (100%) rename sbt-coursier/src/main/{scala-2.10 => scala}/coursier/Settings.scala (100%) rename sbt-coursier/src/main/{scala-2.10 => scala}/coursier/Structure.scala (95%) rename sbt-coursier/src/main/{scala-2.10 => scala}/coursier/Tasks.scala (99%) rename sbt-coursier/src/main/{scala-2.10 => scala}/coursier/ToSbt.scala (74%) rename sbt-shading/src/main/{scala-2.10 => scala}/coursier/Shading.scala (100%) rename sbt-shading/src/main/{scala-2.10 => scala}/coursier/ShadingPlugin.scala (87%) diff --git a/appveyor.yml b/appveyor.yml index d735b5d54..fb34102c9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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 diff --git a/project/CoursierSettings.scala b/project/CoursierSettings.scala index f21f9c585..0a833ee9e 100644 --- a/project/CoursierSettings.scala +++ b/project/CoursierSettings.scala @@ -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 diff --git a/project/build.properties b/project/build.properties index 64317fdae..d9654cdc2 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.15 +sbt.version=0.13.16-M1 diff --git a/sbt-coursier/src/main/scala-2.10/coursier/SbtCompatibility.scala b/sbt-coursier/src/main/scala-2.10/coursier/SbtCompatibility.scala new file mode 100644 index 000000000..a6a22eeca --- /dev/null +++ b/sbt-coursier/src/main/scala-2.10/coursier/SbtCompatibility.scala @@ -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 + +} diff --git a/sbt-coursier/src/main/scala-2.10/sbt/ModuleReportOps.scala b/sbt-coursier/src/main/scala-2.10/sbt/ModuleReportOps.scala new file mode 100644 index 000000000..6c6a0f47c --- /dev/null +++ b/sbt-coursier/src/main/scala-2.10/sbt/ModuleReportOps.scala @@ -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) +} diff --git a/sbt-coursier/src/main/scala-2.12/coursier/SbtCompatibility.scala b/sbt-coursier/src/main/scala-2.12/coursier/SbtCompatibility.scala new file mode 100644 index 000000000..422907449 --- /dev/null +++ b/sbt-coursier/src/main/scala-2.12/coursier/SbtCompatibility.scala @@ -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 + } + +} diff --git a/sbt-coursier/src/main/scala-2.10/coursier/CoursierPlugin.scala b/sbt-coursier/src/main/scala/coursier/CoursierPlugin.scala similarity index 72% rename from sbt-coursier/src/main/scala-2.10/coursier/CoursierPlugin.scala rename to sbt-coursier/src/main/scala/coursier/CoursierPlugin.scala index 6a53a3428..9e3396d7f 100644 --- a/sbt-coursier/src/main/scala-2.10/coursier/CoursierPlugin.scala +++ b/sbt-coursier/src/main/scala/coursier/CoursierPlugin.scala @@ -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)) ++ diff --git a/sbt-coursier/src/main/scala-2.10/coursier/Credentials.scala b/sbt-coursier/src/main/scala/coursier/Credentials.scala similarity index 100% rename from sbt-coursier/src/main/scala-2.10/coursier/Credentials.scala rename to sbt-coursier/src/main/scala/coursier/Credentials.scala diff --git a/sbt-coursier/src/main/scala-2.10/coursier/FallbackDependenciesRepository.scala b/sbt-coursier/src/main/scala/coursier/FallbackDependenciesRepository.scala similarity index 100% rename from sbt-coursier/src/main/scala-2.10/coursier/FallbackDependenciesRepository.scala rename to sbt-coursier/src/main/scala/coursier/FallbackDependenciesRepository.scala diff --git a/sbt-coursier/src/main/scala-2.10/coursier/FromSbt.scala b/sbt-coursier/src/main/scala/coursier/FromSbt.scala similarity index 82% rename from sbt-coursier/src/main/scala-2.10/coursier/FromSbt.scala rename to sbt-coursier/src/main/scala/coursier/FromSbt.scala index 37b17fd1a..40653e3e9 100644 --- a/sbt-coursier/src/main/scala-2.10/coursier/FromSbt.scala +++ b/sbt-coursier/src/main/scala/coursier/FromSbt.scala @@ -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, diff --git a/sbt-coursier/src/main/scala-2.10/coursier/InterProjectRepository.scala b/sbt-coursier/src/main/scala/coursier/InterProjectRepository.scala similarity index 100% rename from sbt-coursier/src/main/scala-2.10/coursier/InterProjectRepository.scala rename to sbt-coursier/src/main/scala/coursier/InterProjectRepository.scala diff --git a/sbt-coursier/src/main/scala-2.10/coursier/IvyXml.scala b/sbt-coursier/src/main/scala/coursier/IvyXml.scala similarity index 98% rename from sbt-coursier/src/main/scala-2.10/coursier/IvyXml.scala rename to sbt-coursier/src/main/scala/coursier/IvyXml.scala index b3972ea5e..4b46d82db 100644 --- a/sbt-coursier/src/main/scala-2.10/coursier/IvyXml.scala +++ b/sbt-coursier/src/main/scala/coursier/IvyXml.scala @@ -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 = { diff --git a/sbt-coursier/src/main/scala-2.10/coursier/Keys.scala b/sbt-coursier/src/main/scala/coursier/Keys.scala similarity index 97% rename from sbt-coursier/src/main/scala-2.10/coursier/Keys.scala rename to sbt-coursier/src/main/scala/coursier/Keys.scala index 27a4ecb1d..1aca88cd5 100644 --- a/sbt-coursier/src/main/scala-2.10/coursier/Keys.scala +++ b/sbt-coursier/src/main/scala/coursier/Keys.scala @@ -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") diff --git a/sbt-coursier/src/main/scala-2.10/coursier/ResolutionError.scala b/sbt-coursier/src/main/scala/coursier/ResolutionError.scala similarity index 100% rename from sbt-coursier/src/main/scala-2.10/coursier/ResolutionError.scala rename to sbt-coursier/src/main/scala/coursier/ResolutionError.scala diff --git a/sbt-coursier/src/main/scala-2.10/coursier/ResolutionException.scala b/sbt-coursier/src/main/scala/coursier/ResolutionException.scala similarity index 100% rename from sbt-coursier/src/main/scala-2.10/coursier/ResolutionException.scala rename to sbt-coursier/src/main/scala/coursier/ResolutionException.scala diff --git a/sbt-coursier/src/main/scala-2.10/coursier/SbtBootJars.scala b/sbt-coursier/src/main/scala/coursier/SbtBootJars.scala similarity index 100% rename from sbt-coursier/src/main/scala-2.10/coursier/SbtBootJars.scala rename to sbt-coursier/src/main/scala/coursier/SbtBootJars.scala diff --git a/sbt-coursier/src/main/scala-2.10/coursier/Settings.scala b/sbt-coursier/src/main/scala/coursier/Settings.scala similarity index 100% rename from sbt-coursier/src/main/scala-2.10/coursier/Settings.scala rename to sbt-coursier/src/main/scala/coursier/Settings.scala diff --git a/sbt-coursier/src/main/scala-2.10/coursier/Structure.scala b/sbt-coursier/src/main/scala/coursier/Structure.scala similarity index 95% rename from sbt-coursier/src/main/scala-2.10/coursier/Structure.scala rename to sbt-coursier/src/main/scala/coursier/Structure.scala index b043e0c50..5128e554f 100644 --- a/sbt-coursier/src/main/scala-2.10/coursier/Structure.scala +++ b/sbt-coursier/src/main/scala/coursier/Structure.scala @@ -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]) { diff --git a/sbt-coursier/src/main/scala-2.10/coursier/Tasks.scala b/sbt-coursier/src/main/scala/coursier/Tasks.scala similarity index 99% rename from sbt-coursier/src/main/scala-2.10/coursier/Tasks.scala rename to sbt-coursier/src/main/scala/coursier/Tasks.scala index 5138c74d3..db7ac3c32 100644 --- a/sbt-coursier/src/main/scala-2.10/coursier/Tasks.scala +++ b/sbt-coursier/src/main/scala/coursier/Tasks.scala @@ -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 diff --git a/sbt-coursier/src/main/scala-2.10/coursier/ToSbt.scala b/sbt-coursier/src/main/scala/coursier/ToSbt.scala similarity index 74% rename from sbt-coursier/src/main/scala-2.10/coursier/ToSbt.scala rename to sbt-coursier/src/main/scala/coursier/ToSbt.scala index 9da9a6d23..bb79ad185 100644 --- a/sbt-coursier/src/main/scala-2.10/coursier/ToSbt.scala +++ b/sbt-coursier/src/main/scala/coursier/ToSbt.scala @@ -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 ) } diff --git a/sbt-shading/src/main/scala-2.10/coursier/Shading.scala b/sbt-shading/src/main/scala/coursier/Shading.scala similarity index 100% rename from sbt-shading/src/main/scala-2.10/coursier/Shading.scala rename to sbt-shading/src/main/scala/coursier/Shading.scala diff --git a/sbt-shading/src/main/scala-2.10/coursier/ShadingPlugin.scala b/sbt-shading/src/main/scala/coursier/ShadingPlugin.scala similarity index 87% rename from sbt-shading/src/main/scala-2.10/coursier/ShadingPlugin.scala rename to sbt-shading/src/main/scala/coursier/ShadingPlugin.scala index f2b5bcc38..8f8a894a5 100644 --- a/sbt-shading/src/main/scala-2.10/coursier/ShadingPlugin.scala +++ b/sbt-shading/src/main/scala/coursier/ShadingPlugin.scala @@ -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) diff --git a/scripts/travis.sh b/scripts/travis.sh index a2d2e8cbc..4a499f9fe 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -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 From 6b3c7638744adff73f6294d0023d27970c564b1c Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Wed, 3 May 2017 19:09:58 +0200 Subject: [PATCH 2/4] Dummy refacto --- .../src/main/scala/coursier/Tasks.scala | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sbt-coursier/src/main/scala/coursier/Tasks.scala b/sbt-coursier/src/main/scala/coursier/Tasks.scala index db7ac3c32..f037896dd 100644 --- a/sbt-coursier/src/main/scala/coursier/Tasks.scala +++ b/sbt-coursier/src/main/scala/coursier/Tasks.scala @@ -178,15 +178,17 @@ object Tasks { coursierProject.forAllProjects(state, projects).map(_.values.toVector) } - def coursierPublicationsTask(configsMap: (sbt.Configuration, String)*): Def.Initialize[sbt.Task[Seq[(String, Publication)]]] = - ( - sbt.Keys.state, - sbt.Keys.thisProjectRef, - sbt.Keys.projectID, - sbt.Keys.scalaVersion, - sbt.Keys.scalaBinaryVersion, - sbt.Keys.ivyConfigurations - ).map { (state, projectRef, projId, sv, sbv, ivyConfs) => + def coursierPublicationsTask( + configsMap: (sbt.Configuration, String)* + ): Def.Initialize[sbt.Task[Seq[(String, Publication)]]] = + Def.task { + + val state = sbt.Keys.state.value + val projectRef = sbt.Keys.thisProjectRef.value + val projId = sbt.Keys.projectID.value + val sv = sbt.Keys.scalaVersion.value + val sbv = sbt.Keys.scalaBinaryVersion.value + val ivyConfs = sbt.Keys.ivyConfigurations.value val sbtBinArtifacts = for ((config, targetConfig) <- configsMap) yield { From 86f06a14a84ab666d40417f72d59a6c61263734a Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Wed, 3 May 2017 19:09:59 +0200 Subject: [PATCH 3/4] Fix scripted tests in sbt 1.0 --- appveyor.yml | 4 +-- .../main/scala/coursier/CoursierPlugin.scala | 25 +++++++++++++++++- .../src/main/scala/coursier/Tasks.scala | 24 ++++++++++++----- .../unidoc/build.sbt | 0 .../unidoc/project/plugins.sbt | 0 .../unidoc/src/main/scala/Foo.scala | 0 .../unidoc/test | 0 .../exclude-dependencies/build.sbt | 4 +++ .../exclude-dependencies/project/Dummy.scala | 8 ++++++ .../sbt-coursier/maven-compatible/build.sbt | 6 +++-- .../build.sbt | 20 +++++++++++--- .../cross-project-shading/build.sbt | 0 .../cross-project-shading/coursier | Bin .../jvm/src/main/scala/Main.scala | 0 .../cross-project-shading/project/plugins.sbt | 0 .../shared/src/main/scala/Foo.scala | 0 .../cross-project-shading/test | 0 .../exclude-dependencies/build.sbt | 3 +++ .../exclude-dependencies/project/Dummy.scala | 8 ++++++ scripts/travis.sh | 10 +++++-- 20 files changed, 94 insertions(+), 18 deletions(-) rename sbt-coursier/src/sbt-test/{sbt-coursier => sbt-coursier-0.13}/unidoc/build.sbt (100%) rename sbt-coursier/src/sbt-test/{sbt-coursier => sbt-coursier-0.13}/unidoc/project/plugins.sbt (100%) rename sbt-coursier/src/sbt-test/{sbt-coursier => sbt-coursier-0.13}/unidoc/src/main/scala/Foo.scala (100%) rename sbt-coursier/src/sbt-test/{sbt-coursier => sbt-coursier-0.13}/unidoc/test (100%) create mode 100644 sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/project/Dummy.scala rename sbt-shading/src/sbt-test/{sbt-shading => sbt-shading-0.13}/cross-project-shading/build.sbt (100%) rename sbt-shading/src/sbt-test/{sbt-shading => sbt-shading-0.13}/cross-project-shading/coursier (100%) rename sbt-shading/src/sbt-test/{sbt-shading => sbt-shading-0.13}/cross-project-shading/jvm/src/main/scala/Main.scala (100%) rename sbt-shading/src/sbt-test/{sbt-shading => sbt-shading-0.13}/cross-project-shading/project/plugins.sbt (100%) rename sbt-shading/src/sbt-test/{sbt-shading => sbt-shading-0.13}/cross-project-shading/shared/src/main/scala/Foo.scala (100%) rename sbt-shading/src/sbt-test/{sbt-shading => sbt-shading-0.13}/cross-project-shading/test (100%) create mode 100644 sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/project/Dummy.scala diff --git a/appveyor.yml b/appveyor.yml index fb34102c9..2fc47eaf1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -33,8 +33,8 @@ test_script: - 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 ++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 + - sbt ++2.12.1 "sbt-coursier/scripted sbt-coursier/*" sbt-coursier/publishLocal "sbt-shading/scripted sbt-shading/*" # for sbt 1.0 + - sbt ++2.10.6 "sbt-coursier/scripted sbt-coursier/*" "sbt-coursier/scripted sbt-coursier-0.13/*" sbt-coursier/publishLocal "sbt-shading/scripted sbt-shading/*" "sbt-shading/scripted sbt-shading-0.13/*" # for sbt 0.13 cache: - C:\Users\appveyor\.ivy2\cache - C:\Users\appveyor\.m2 diff --git a/sbt-coursier/src/main/scala/coursier/CoursierPlugin.scala b/sbt-coursier/src/main/scala/coursier/CoursierPlugin.scala index 9e3396d7f..ee1a20da1 100644 --- a/sbt-coursier/src/main/scala/coursier/CoursierPlugin.scala +++ b/sbt-coursier/src/main/scala/coursier/CoursierPlugin.scala @@ -3,6 +3,8 @@ package coursier import sbt._ import sbt.Keys._ +import SbtCompatibility._ + object CoursierPlugin extends AutoPlugin { override def trigger = allRequirements @@ -123,7 +125,28 @@ object CoursierPlugin extends AutoPlugin { coursierResolution := Tasks.resolutionTask().value, coursierSbtClassifiersResolution := Tasks.resolutionTask( sbtClassifiers = true - ).value + ).value, + ivyConfigurations := { + val confs = ivyConfigurations.value + val names = confs.map(_.name).toSet + + // Yes, adding those back in sbt 1.0. Can't distinguish between config test (whose jars with classifier tests ought to + // be added), and sources / docs else (if their JARs are in compile, they would get added too then). + + val extraSources = + if (names("sources")) + None + else + Some(Configuration("sources", "", isPublic = true, extendsConfigs = Vector.empty, transitive = false)) + + val extraDocs = + if (names("docs")) + None + else + Some(Configuration("docs", "", isPublic = true, extendsConfigs = Vector.empty, transitive = false)) + + confs ++ extraSources.toSeq ++ extraDocs.toSeq + } ) override lazy val projectSettings = coursierSettings(None, Seq(Compile, Test).map(c => c -> c.name)) ++ diff --git a/sbt-coursier/src/main/scala/coursier/Tasks.scala b/sbt-coursier/src/main/scala/coursier/Tasks.scala index f037896dd..d6db4d8c2 100644 --- a/sbt-coursier/src/main/scala/coursier/Tasks.scala +++ b/sbt-coursier/src/main/scala/coursier/Tasks.scala @@ -146,9 +146,7 @@ object Tasks { allDependencies <- allDependenciesTask } yield { - val configMap = configurations - .map { cfg => cfg.name -> cfg.extendsConfigs.map(_.name) } - .toMap + val configMap = configurations.map(cfg => cfg.name -> cfg.extendsConfigs.map(_.name)).toMap val proj = FromSbt.project( projId, @@ -190,6 +188,18 @@ object Tasks { val sbv = sbt.Keys.scalaBinaryVersion.value val ivyConfs = sbt.Keys.ivyConfigurations.value + val sourcesConfigOpt = + if (ivyConfigurations.value.exists(_.name == "sources")) + Some("sources") + else + None + + val docsConfigOpt = + if (ivyConfigurations.value.exists(_.name == "docs")) + Some("docs") + else + None + val sbtBinArtifacts = for ((config, targetConfig) <- configsMap) yield { @@ -211,7 +221,7 @@ object Tasks { } val sbtSourceArtifacts = - for ((config, _) <- configsMap) yield { + for ((config, targetConfig) <- configsMap) yield { val publish = publishArtifact .in(projectRef) @@ -225,13 +235,13 @@ object Tasks { .in(packageSrc) .in(config) .find(state) - .map("sources" -> _) + .map(sourcesConfigOpt.getOrElse(targetConfig) -> _) else None } val sbtDocArtifacts = - for ((config, _) <- configsMap) yield { + for ((config, targetConfig) <- configsMap) yield { val publish = publishArtifact .in(projectRef) @@ -245,7 +255,7 @@ object Tasks { .in(packageDoc) .in(config) .find(state) - .map("docs" -> _) + .map(docsConfigOpt.getOrElse(targetConfig) -> _) else None } diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/unidoc/build.sbt b/sbt-coursier/src/sbt-test/sbt-coursier-0.13/unidoc/build.sbt similarity index 100% rename from sbt-coursier/src/sbt-test/sbt-coursier/unidoc/build.sbt rename to sbt-coursier/src/sbt-test/sbt-coursier-0.13/unidoc/build.sbt diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/unidoc/project/plugins.sbt b/sbt-coursier/src/sbt-test/sbt-coursier-0.13/unidoc/project/plugins.sbt similarity index 100% rename from sbt-coursier/src/sbt-test/sbt-coursier/unidoc/project/plugins.sbt rename to sbt-coursier/src/sbt-test/sbt-coursier-0.13/unidoc/project/plugins.sbt diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/unidoc/src/main/scala/Foo.scala b/sbt-coursier/src/sbt-test/sbt-coursier-0.13/unidoc/src/main/scala/Foo.scala similarity index 100% rename from sbt-coursier/src/sbt-test/sbt-coursier/unidoc/src/main/scala/Foo.scala rename to sbt-coursier/src/sbt-test/sbt-coursier-0.13/unidoc/src/main/scala/Foo.scala diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/unidoc/test b/sbt-coursier/src/sbt-test/sbt-coursier-0.13/unidoc/test similarity index 100% rename from sbt-coursier/src/sbt-test/sbt-coursier/unidoc/test rename to sbt-coursier/src/sbt-test/sbt-coursier-0.13/unidoc/test diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/build.sbt b/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/build.sbt index 471a4db63..6c0d86ed7 100644 --- a/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/build.sbt +++ b/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/build.sbt @@ -1,3 +1,7 @@ + +// for SbtExclusionRule with sbt 1.0 +import sbt.internal.librarymanagement._ + scalaVersion := "2.11.8" organization := "io.get-coursier.test" diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/project/Dummy.scala b/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/project/Dummy.scala new file mode 100644 index 000000000..1595e3687 --- /dev/null +++ b/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/project/Dummy.scala @@ -0,0 +1,8 @@ +package sbt.internal.librarymanagement + +// dummy object, to be able to do +// import sbt.internal.librarymanagement._ +// from build.sbt, even in 0.13 +// That import is required in 1.0 for SbtExclusionRule + +object Dummy diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/maven-compatible/build.sbt b/sbt-coursier/src/sbt-test/sbt-coursier/maven-compatible/build.sbt index 7479343f5..f44f79c32 100644 --- a/sbt-coursier/src/sbt-test/sbt-coursier/maven-compatible/build.sbt +++ b/sbt-coursier/src/sbt-test/sbt-coursier/maven-compatible/build.sbt @@ -16,8 +16,10 @@ resolvers += Resolver.url( Patterns( Resolver.ivyStylePatterns.ivyPatterns, Resolver.ivyStylePatterns.artifactPatterns, - isMavenCompatible = true + isMavenCompatible = true, + descriptorOptional = false, + skipConsistencyCheck = false ) ) -libraryDependencies += "org.scalaz.stream" %% "scalaz-stream" % "0.7.1" \ No newline at end of file +libraryDependencies += "org.scalaz.stream" %% "scalaz-stream" % "0.7.1" diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/publish-local-sources-javadoc-conf/build.sbt b/sbt-coursier/src/sbt-test/sbt-coursier/publish-local-sources-javadoc-conf/build.sbt index ad77e0f29..0bae35eb6 100644 --- a/sbt-coursier/src/sbt-test/sbt-coursier/publish-local-sources-javadoc-conf/build.sbt +++ b/sbt-coursier/src/sbt-test/sbt-coursier/publish-local-sources-javadoc-conf/build.sbt @@ -57,10 +57,22 @@ lazy val shared = Seq( val compileDocArtifacts = artifacts("compile", Some("javadoc")) val docArtifacts = artifacts("compile", Some("javadoc"), useClassifiersReport = true) - assert(compileSourceArtifacts.isEmpty) - assert(sourceArtifacts.length == 2) - assert(compileDocArtifacts.isEmpty) - assert(docArtifacts.length == 2) + assert( + compileSourceArtifacts.isEmpty, + "Expected no source artifact in main update report" + ) + assert( + sourceArtifacts.length == 2, + "Expected 2 source artifacts in classifier report" + ) + assert( + compileDocArtifacts.isEmpty, + "Expected no doc artifact in main update report" + ) + assert( + docArtifacts.length == 2, + "Expected 2 doc artifacts in classifier report" + ) } ) diff --git a/sbt-shading/src/sbt-test/sbt-shading/cross-project-shading/build.sbt b/sbt-shading/src/sbt-test/sbt-shading-0.13/cross-project-shading/build.sbt similarity index 100% rename from sbt-shading/src/sbt-test/sbt-shading/cross-project-shading/build.sbt rename to sbt-shading/src/sbt-test/sbt-shading-0.13/cross-project-shading/build.sbt diff --git a/sbt-shading/src/sbt-test/sbt-shading/cross-project-shading/coursier b/sbt-shading/src/sbt-test/sbt-shading-0.13/cross-project-shading/coursier similarity index 100% rename from sbt-shading/src/sbt-test/sbt-shading/cross-project-shading/coursier rename to sbt-shading/src/sbt-test/sbt-shading-0.13/cross-project-shading/coursier diff --git a/sbt-shading/src/sbt-test/sbt-shading/cross-project-shading/jvm/src/main/scala/Main.scala b/sbt-shading/src/sbt-test/sbt-shading-0.13/cross-project-shading/jvm/src/main/scala/Main.scala similarity index 100% rename from sbt-shading/src/sbt-test/sbt-shading/cross-project-shading/jvm/src/main/scala/Main.scala rename to sbt-shading/src/sbt-test/sbt-shading-0.13/cross-project-shading/jvm/src/main/scala/Main.scala diff --git a/sbt-shading/src/sbt-test/sbt-shading/cross-project-shading/project/plugins.sbt b/sbt-shading/src/sbt-test/sbt-shading-0.13/cross-project-shading/project/plugins.sbt similarity index 100% rename from sbt-shading/src/sbt-test/sbt-shading/cross-project-shading/project/plugins.sbt rename to sbt-shading/src/sbt-test/sbt-shading-0.13/cross-project-shading/project/plugins.sbt diff --git a/sbt-shading/src/sbt-test/sbt-shading/cross-project-shading/shared/src/main/scala/Foo.scala b/sbt-shading/src/sbt-test/sbt-shading-0.13/cross-project-shading/shared/src/main/scala/Foo.scala similarity index 100% rename from sbt-shading/src/sbt-test/sbt-shading/cross-project-shading/shared/src/main/scala/Foo.scala rename to sbt-shading/src/sbt-test/sbt-shading-0.13/cross-project-shading/shared/src/main/scala/Foo.scala diff --git a/sbt-shading/src/sbt-test/sbt-shading/cross-project-shading/test b/sbt-shading/src/sbt-test/sbt-shading-0.13/cross-project-shading/test similarity index 100% rename from sbt-shading/src/sbt-test/sbt-shading/cross-project-shading/test rename to sbt-shading/src/sbt-test/sbt-shading-0.13/cross-project-shading/test diff --git a/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/build.sbt b/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/build.sbt index 091b971ab..2a1f71f12 100644 --- a/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/build.sbt +++ b/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/build.sbt @@ -1,4 +1,7 @@ +// for SbtExclusionRule with sbt 1.0 +import sbt.internal.librarymanagement._ + enablePlugins(coursier.ShadingPlugin) shadingNamespace := "test.shaded" shadeNamespaces += "argonaut" diff --git a/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/project/Dummy.scala b/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/project/Dummy.scala new file mode 100644 index 000000000..1595e3687 --- /dev/null +++ b/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/project/Dummy.scala @@ -0,0 +1,8 @@ +package sbt.internal.librarymanagement + +// dummy object, to be able to do +// import sbt.internal.librarymanagement._ +// from build.sbt, even in 0.13 +// That import is required in 1.0 for SbtExclusionRule + +object Dummy diff --git a/scripts/travis.sh b/scripts/travis.sh index 4a499f9fe..0917c2de7 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -67,11 +67,17 @@ is212() { } runSbtCoursierTests() { - sbt ++$SCALA_VERSION coreJVM/publishLocal cache/publishLocal sbt-coursier/scripted + sbt ++$SCALA_VERSION coreJVM/publishLocal cache/publishLocal "sbt-coursier/scripted sbt-coursier/*" + if [ "$SCALA_VERSION" = "2.10" ]; then + sbt ++$SCALA_VERSION "sbt-coursier/scripted sbt-coursier-0.13/*" + fi } runSbtShadingTests() { - sbt ++$SCALA_VERSION sbt-coursier/publishLocal sbt-shading/scripted + sbt ++$SCALA_VERSION coreJVM/publishLocal cache/publishLocal sbt-coursier/publishLocal "sbt-shading/scripted sbt-shading/*" + if [ "$SCALA_VERSION" = "2.10" ]; then + sbt ++$SCALA_VERSION "sbt-shading/scripted sbt-shading-0.13/*" + fi } jsCompile() { From 4daf132da7c68a114eb3605913a266d1000a08bb Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Thu, 4 May 2017 15:25:49 +0200 Subject: [PATCH 4/4] Run sbt plugins tests in separate Travis runs --- .travis.yml | 26 +++++++++++++++++------ scripts/push-gh-pages.sh | 4 ++-- scripts/travis.sh | 46 ++++++++++++++++++++++++++-------------- 3 files changed, 52 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index f68f3e629..a7c87f118 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,28 +10,42 @@ script: # - bash <(curl -s https://codecov.io/bash) matrix: include: - - env: TRAVIS_SCALA_VERSION=2.12.1 PUBLISH=1 + - env: SCALA_VERSION=2.12.1 PUBLISH=1 os: linux jdk: oraclejdk8 - - env: TRAVIS_SCALA_VERSION=2.11.11 PUBLISH=1 + - env: SCALA_VERSION=2.11.11 PUBLISH=1 os: linux jdk: oraclejdk8 sudo: required services: - docker - - env: TRAVIS_SCALA_VERSION=2.10.6 PUBLISH=1 + - env: SCALA_VERSION=2.10.6 PUBLISH=1 os: linux jdk: oraclejdk8 sudo: required services: - docker - - env: TRAVIS_SCALA_VERSION=2.12.1 PUBLISH=1 SCALA_JS=1 + - env: SCALA_VERSION=2.12.1 SBT_COURSIER=1 os: linux jdk: oraclejdk8 - - env: TRAVIS_SCALA_VERSION=2.11.11 PUBLISH=1 SCALA_JS=1 + - env: SCALA_VERSION=2.12.1 SBT_SHADING=1 os: linux jdk: oraclejdk8 - - env: TRAVIS_SCALA_VERSION=2.10.6 PUBLISH=1 SCALA_JS=1 + - env: SCALA_VERSION=2.10.6 SBT_COURSIER=1 + os: linux + jdk: oraclejdk8 + services: + - docker + - env: SCALA_VERSION=2.10.6 SBT_SHADING=1 + os: linux + jdk: oraclejdk8 + - env: SCALA_VERSION=2.12.1 SCALA_JS=1 + os: linux + jdk: oraclejdk8 + - env: SCALA_VERSION=2.11.11 SCALA_JS=1 + os: linux + jdk: oraclejdk8 + - env: SCALA_VERSION=2.10.6 SCALA_JS=1 os: linux jdk: oraclejdk8 env: diff --git a/scripts/push-gh-pages.sh b/scripts/push-gh-pages.sh index de7b56857..9c04f832b 100755 --- a/scripts/push-gh-pages.sh +++ b/scripts/push-gh-pages.sh @@ -1,10 +1,10 @@ #!/bin/bash set -ev -TRAVIS_SCALA_VERSION="$1" +SCALA_VERSION="$1" shift -sbt ++${TRAVIS_SCALA_VERSION} web/fastOptJS +sbt ++${SCALA_VERSION} web/fastOptJS HELPER="$(readlink -f "$(dirname "$0")/push-gh-pages-helper.sh")" diff --git a/scripts/travis.sh b/scripts/travis.sh index 0917c2de7..6f35903b5 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -54,6 +54,14 @@ isScalaJs() { [ "$SCALA_JS" = 1 ] } +sbtCoursier() { + [ "$SBT_COURSIER" = 1 ] +} + +sbtShading() { + [ "$SBT_SHADING" = 1 ] +} + is210() { echo "$SCALA_VERSION" | grep -q "^2\.10" } @@ -182,27 +190,33 @@ if isScalaJs; then else integrationTestsRequirements jvmCompile - runJvmTests - if is210 || is212; then - runSbtCoursierTests - runSbtShadingTests + if sbtCoursier; then + if is210 || is212; then + runSbtCoursierTests + fi + + if is210; then + testSbtCoursierJava6 + fi + elif sbtShading; then + if is210 || is212; then + runSbtShadingTests + fi + else + runJvmTests + + validateReadme + checkBinaryCompatibility + + if is211; then + testLauncherJava6 + fi fi - validateReadme - checkBinaryCompatibility - - # We're not using a jdk6 matrix entry with Travis here as some sources of coursier require Java 7 to compile + # Not using a jdk6 matrix entry with Travis as some sources of coursier require Java 7 to compile # (even though it won't try to call Java 7 specific methods if it detects it runs under Java 6). # The tests here check that coursier is nonetheless fine when run under Java 6. - - if is211; then - testLauncherJava6 - fi - - if is210; then - testSbtCoursierJava6 - fi fi