From 71fddd5e3f44157faa3a1ae2bdc5ec1a7d2def44 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Thu, 5 Jan 2017 13:33:19 +0000 Subject: [PATCH] Upgrade from sbt/datatype to sbt/contraband --- build.sbt | 4 +- .../librarymanagement.json | 72 +++++++++---------- .../internal/librarymanagement/IvyCache.scala | 2 +- .../librarymanagement/IvyRetrieve.scala | 10 +-- .../internal/librarymanagement/JsonUtil.scala | 10 +-- .../librarymanagement/RichUpdateReport.scala | 6 +- .../CachedResolutionResolveEngine.scala | 12 ++-- .../sbt/librarymanagement/ArtifactExtra.scala | 2 +- .../ConfigurationExtra.scala | 2 +- .../librarymanagement/CrossVersionExtra.scala | 4 +- .../sbt/librarymanagement/IvyInterface.scala | 2 +- .../sbt/librarymanagement/ResolverExtra.scala | 2 +- .../librarymanagement/UpdateReportExtra.scala | 4 +- .../src/test/scala/BaseIvySpecification.scala | 8 +-- .../src/test/scala/CustomPomParserTest.scala | 2 +- .../src/test/scala/DMSerializationSpec.scala | 8 +-- project/DatatypeConfig.scala | 29 ++++---- project/Dependencies.scala | 6 +- project/contraband.sbt | 1 + project/sbt-datatype.sbt | 1 - 20 files changed, 94 insertions(+), 93 deletions(-) rename librarymanagement/src/main/{datatype => contraband}/librarymanagement.json (93%) create mode 100644 project/contraband.sbt delete mode 100644 project/sbt-datatype.sbt diff --git a/build.sbt b/build.sbt index 04511e60a..1ff4aaa3d 100644 --- a/build.sbt +++ b/build.sbt @@ -49,7 +49,7 @@ lazy val lm = (project in file("librarymanagement")). libraryDependencies ++= scalaXml.value, resourceGenerators in Compile += Def.task(Util.generateVersionFile(version.value, resourceManaged.value, streams.value, (compile in Compile).value)).taskValue, binaryIssueFilters ++= Seq(), - datatypeFormatsForType in generateDatatypes in Compile := DatatypeConfig.getFormats, + contrabandFormatsForType in generateContrabands in Compile := DatatypeConfig.getFormats, // WORKAROUND sbt/sbt#2205 include managed sources in packageSrc mappings in (Compile, packageSrc) ++= { val srcs = (managedSources in Compile).value @@ -59,7 +59,7 @@ lazy val lm = (project in file("librarymanagement")). } ). configure(addSbtIO, addSbtUtilLogging, addSbtUtilTesting, addSbtUtilCollection, addSbtUtilCompletion, addSbtUtilCache). - enablePlugins(DatatypePlugin, JsonCodecPlugin) + enablePlugins(ContrabandPlugin, JsonCodecPlugin) def customCommands: Seq[Setting[_]] = Seq( commands += Command.command("release") { state => diff --git a/librarymanagement/src/main/datatype/librarymanagement.json b/librarymanagement/src/main/contraband/librarymanagement.json similarity index 93% rename from librarymanagement/src/main/datatype/librarymanagement.json rename to librarymanagement/src/main/contraband/librarymanagement.json index bbcd2ed38..b6dd96e23 100644 --- a/librarymanagement/src/main/datatype/librarymanagement.json +++ b/librarymanagement/src/main/contraband/librarymanagement.json @@ -12,9 +12,9 @@ { "name": "name", "type": "String" }, { "name": "type", "type": "String", "default": "Artifact.DefaultType", "since": "0.0.1" }, { "name": "extension", "type": "String", "default": "Artifact.DefaultExtension", "since": "0.0.1" }, - { "name": "classifier", "type": "String?", "default": "None", "since": "0.0.1" }, + { "name": "classifier", "type": "Option[String]", "default": "None", "since": "0.0.1" }, { "name": "configurations", "type": "sbt.librarymanagement.Configuration*", "default": "Vector.empty", "since": "0.0.1" }, - { "name": "url", "type": "java.net.URL?", "default": "None", "since": "0.0.1" }, + { "name": "url", "type": "Option[java.net.URL]", "default": "None", "since": "0.0.1" }, { "name": "extraAttributes", "type": "Map[String, String]", "default": "Map.empty", "since": "0.0.1" } ], "parentsCompanion": "sbt.librarymanagement.ArtifactFunctions" @@ -208,14 +208,14 @@ "target": "Scala", "type": "record", "fields": [ - { "name": "scalaFullVersion", "type": "String" }, - { "name": "scalaBinaryVersion", "type": "String" }, - { "name": "configurations", "type": "sbt.librarymanagement.Configuration*" }, - { "name": "checkExplicit", "type": "boolean" }, - { "name": "filterImplicit", "type": "boolean" }, - { "name": "overrideScalaVersion", "type": "boolean" }, - { "name": "scalaOrganization", "type": "String", "default": "sbt.librarymanagement.ScalaArtifacts.Organization", "since": "0.0.1" }, - { "name": "scalaArtifacts", "type": "String*", "default": "sbt.librarymanagement.ScalaArtifacts.Artifacts", "since": "0.0.1" } + { "name": "scalaFullVersion", "type": "String" }, + { "name": "scalaBinaryVersion", "type": "String" }, + { "name": "configurations", "type": "sbt.librarymanagement.Configuration*" }, + { "name": "checkExplicit", "type": "boolean" }, + { "name": "filterImplicit", "type": "boolean" }, + { "name": "overrideScalaVersion", "type": "boolean" }, + { "name": "scalaOrganization", "type": "String", "default": "sbt.librarymanagement.ScalaArtifacts.Organization", "since": "0.0.1" }, + { "name": "scalaArtifacts", "type": "scala.Vector[String]", "default": "sbt.librarymanagement.ScalaArtifacts.Artifacts", "since": "0.0.1" } ], "parentsCompanion": "sbt.librarymanagement.IvyScalaFunctions" }, @@ -245,7 +245,7 @@ { "name": "organization", "type": "String" }, { "name": "name", "type": "String" }, { "name": "revision", "type": "String" }, - { "name": "configurations", "type": "String?", "default": "None", "since": "0.0.1" }, + { "name": "configurations", "type": "Option[String]", "default": "None", "since": "0.0.1" }, { "name": "isChanging", "type": "boolean", "default": "false", "since": "0.0.1" }, { "name": "isTransitive", "type": "boolean", "default": "true", "since": "0.0.1" }, { "name": "isForce", "type": "boolean", "default": "false", "since": "0.0.1" }, @@ -254,7 +254,7 @@ { "name": "exclusions", "type": "sbt.librarymanagement.InclExclRule*", "default": "Vector.empty", "since": "0.0.1" }, { "name": "extraAttributes", "type": "Map[String, String]", "default": "Map.empty", "since": "0.0.1" }, { "name": "crossVersion", "type": "sbt.librarymanagement.CrossVersion", "default": "sbt.librarymanagement.Disabled()", "since": "0.0.1" }, - { "name": "branchName", "type": "String?", "default": "None", "since": "0.0.1" } + { "name": "branchName", "type": "Option[String]", "default": "None", "since": "0.0.1" } ], "toString": [ "organization + \":\" + name + \":\" + revision +", @@ -270,15 +270,15 @@ "type": "record", "doc": "Additional information about a project module", "fields": [ - { "name": "nameFormal", "type": "String" }, - { "name": "description", "type": "String", "default": "\"\"", "since": "0.0.1" }, - { "name": "homepage", "type": "java.net.URL?", "default": "None", "since": "0.0.1" }, - { "name": "startYear", "type": "int?", "default": "None", "since": "0.0.1" }, - { "name": "licenses", "type": "scala.Tuple2[String, java.net.URL]*", "default": "Vector.empty", "since": "0.0.1" }, - { "name": "organizationName", "type": "String", "default": "\"\"", "since": "0.0.1" }, - { "name": "organizationHomepage", "type": "java.net.URL?", "default": "None", "since": "0.0.1" }, - { "name": "scmInfo", "type": "sbt.librarymanagement.ScmInfo?", "default": "None", "since": "0.0.1" }, - { "name": "developers", "type": "sbt.librarymanagement.Developer*", "default": "Vector.empty", "since": "0.0.1" } + { "name": "nameFormal", "type": "String" }, + { "name": "description", "type": "String", "default": "\"\"", "since": "0.0.1" }, + { "name": "homepage", "type": "Option[java.net.URL]", "default": "None", "since": "0.0.1" }, + { "name": "startYear", "type": "Option[Int]", "default": "None", "since": "0.0.1" }, + { "name": "licenses", "type": "scala.Tuple2[String, java.net.URL]*", "default": "Vector.empty", "since": "0.0.1" }, + { "name": "organizationName", "type": "String", "default": "\"\"", "since": "0.0.1" }, + { "name": "organizationHomepage", "type": "Option[java.net.URL]", "default": "None", "since": "0.0.1" }, + { "name": "scmInfo", "type": "Option[sbt.librarymanagement.ScmInfo]", "default": "None", "since": "0.0.1" }, + { "name": "developers", "type": "sbt.librarymanagement.Developer*", "default": "Vector.empty", "since": "0.0.1" } ] }, { @@ -295,18 +295,18 @@ { "name": "module", "type": "sbt.librarymanagement.ModuleID" }, { "name": "artifacts", "type": "scala.Tuple2[sbt.librarymanagement.Artifact, java.io.File]*" }, { "name": "missingArtifacts", "type": "sbt.librarymanagement.Artifact*" }, - { "name": "status", "type": "String?", "default": "None", "since": "0.0.1" }, - { "name": "publicationDate", "type": "java.util.Date?", "default": "None", "since": "0.0.1" }, - { "name": "resolver", "type": "String?", "default": "None", "since": "0.0.1" }, - { "name": "artifactResolver", "type": "String?", "default": "None", "since": "0.0.1" }, + { "name": "status", "type": "Option[String]", "default": "None", "since": "0.0.1" }, + { "name": "publicationDate", "type": "Option[java.util.Date]", "default": "None", "since": "0.0.1" }, + { "name": "resolver", "type": "Option[String]", "default": "None", "since": "0.0.1" }, + { "name": "artifactResolver", "type": "Option[String]", "default": "None", "since": "0.0.1" }, { "name": "evicted", "type": "boolean", "default": "false", "since": "0.0.1" }, - { "name": "evictedData", "type": "String?", "default": "None", "since": "0.0.1" }, - { "name": "evictedReason", "type": "String?", "default": "None", "since": "0.0.1" }, - { "name": "problem", "type": "String?", "default": "None", "since": "0.0.1" }, - { "name": "homepage", "type": "String?", "default": "None", "since": "0.0.1" }, + { "name": "evictedData", "type": "Option[String]", "default": "None", "since": "0.0.1" }, + { "name": "evictedReason", "type": "Option[String]", "default": "None", "since": "0.0.1" }, + { "name": "problem", "type": "Option[String]", "default": "None", "since": "0.0.1" }, + { "name": "homepage", "type": "Option[String]", "default": "None", "since": "0.0.1" }, { "name": "extraAttributes", "type": "Map[String, String]", "default": "Map.empty", "since": "0.0.1" }, - { "name": "isDefault", "type": "boolean?", "default": "None", "since": "0.0.1" }, - { "name": "branch", "type": "String?", "default": "None", "since": "0.0.1" }, + { "name": "isDefault", "type": "Option[Boolean]", "default": "None", "since": "0.0.1" }, + { "name": "branch", "type": "Option[String]", "default": "None", "since": "0.0.1" }, { "name": "configurations", "type": "String*", "default": "Vector.empty", "since": "0.0.1" }, { "name": "licenses", "type": "scala.Tuple2[String, Option[String]]*", "default": "Vector.empty", "since": "0.0.1" }, { "name": "callers", "type": "sbt.librarymanagement.Caller*", "default": "Vector.empty", "since": "0.0.1" } @@ -359,7 +359,7 @@ { "name": "excludes", "type": "sbt.internal.librarymanagement.SbtExclusionRule*", "default": "Vector.empty", "since": "0.0.1" }, { "name": "ivyXML", "type": "scala.xml.NodeSeq", "default": "scala.xml.NodeSeq.Empty", "since": "0.0.1" }, { "name": "configurations", "type": "sbt.librarymanagement.Configuration*", "default": "Vector.empty", "since": "0.0.1" }, - { "name": "defaultConfiguration", "type": "sbt.librarymanagement.Configuration?", "default": "None", "since": "0.0.1" }, + { "name": "defaultConfiguration", "type": "Option[sbt.librarymanagement.Configuration]", "default": "None", "since": "0.0.1" }, { "name": "conflictManager", "type": "sbt.librarymanagement.ConflictManager", "default": "sbt.librarymanagement.ConflictManager.default", "since": "0.0.1" } ], "parentsCompanion": "sbt.internal.librarymanagement.InlineConfigurationFunctions" @@ -754,10 +754,10 @@ "target": "Scala", "type": "record", "fields": [ - { "name": "retrieveDirectory", "type": "java.io.File" }, - { "name": "outputPattern", "type": "String" }, - { "name": "sync", "type": "boolean", "default": "false", "since": "0.0.1" }, - { "name": "configurationsToRetrieve", "type": "Set[sbt.librarymanagement.Configuration]?", "default": "None", "since": "0.0.1" } + { "name": "retrieveDirectory", "type": "java.io.File" }, + { "name": "outputPattern", "type": "String" }, + { "name": "sync", "type": "boolean", "default": "false", "since": "0.0.1" }, + { "name": "configurationsToRetrieve", "type": "Option[Set[sbt.librarymanagement.Configuration]]", "default": "None", "since": "0.0.1" } ] }, { diff --git a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyCache.scala b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyCache.scala index 0c1c1f969..80eff7470 100644 --- a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyCache.scala +++ b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyCache.scala @@ -90,7 +90,7 @@ class IvyCache(val ivyHome: Option[File], fileToStore: File => CacheStore) { private def basicLocalIvy(lock: Option[xsbti.GlobalLock], log: Logger) = { val local = Resolver.defaultLocal - val paths = new IvyPaths(new File("."), ivyHome) + val paths = IvyPaths(new File("."), ivyHome) val conf = new InlineIvyConfiguration(paths, Vector(local), Vector.empty, Vector.empty, false, lock, IvySbt.DefaultChecksums, None, UpdateOptions(), log) (new IvySbt(conf, fileToStore), local) } diff --git a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyRetrieve.scala b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyRetrieve.scala index 6f0a7d42e..e27d40c0f 100644 --- a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyRetrieve.scala +++ b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyRetrieve.scala @@ -85,7 +85,7 @@ object IvyRetrieve { case Some(dd) => (toExtraAttributes(dd.getExtraAttributes), dd.isForce, dd.isChanging, dd.isTransitive, false) case None => (Map.empty[String, String], false, false, true, false) } - new Caller(m, callerConfigurations, extraAttributes, isForce, isChanging, isTransitive, isDirectlyForce) + Caller(m, callerConfigurations, extraAttributes, isForce, isChanging, isTransitive, isDirectlyForce) } val revId = dep.getResolvedId val moduleId = toModuleID(revId) @@ -142,7 +142,7 @@ object IvyRetrieve { val callers = dep.getCallers(confReport.getConfiguration).toVector map { toCaller } val (resolved, missing) = artifacts(moduleId, confReport getDownloadReports revId) - new ModuleReport(moduleId, resolved, missing, status, publicationDate, resolver, artifactResolver, + ModuleReport(moduleId, resolved, missing, status, publicationDate, resolver, artifactResolver, evicted, evictedData, evictedReason, problem, homepage, extraAttributes, isDefault, branch, configurations, licenses, callers) } @@ -161,11 +161,11 @@ object IvyRetrieve { } def updateReport(report: ResolveReport, cachedDescriptor: File): UpdateReport = - new UpdateReport(cachedDescriptor, reports(report) map configurationReport, updateStats(report), Map.empty) recomputeStamps () + UpdateReport(cachedDescriptor, reports(report) map configurationReport, updateStats(report), Map.empty) recomputeStamps () def updateStats(report: ResolveReport): UpdateStats = - new UpdateStats(report.getResolveTime, report.getDownloadTime, report.getDownloadSize, false) + UpdateStats(report.getResolveTime, report.getDownloadTime, report.getDownloadSize, false) def configurationReport(confReport: ConfigurationResolveReport): ConfigurationReport = - new ConfigurationReport(confReport.getConfiguration, moduleReports(confReport), organizationArtifactReports(confReport)) + ConfigurationReport(confReport.getConfiguration, moduleReports(confReport), organizationArtifactReports(confReport)) /** * Tries to find Ivy graph path the from node to target. diff --git a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/JsonUtil.scala b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/JsonUtil.scala index 7be87317a..df6f6490d 100644 --- a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/JsonUtil.scala +++ b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/JsonUtil.scala @@ -34,8 +34,8 @@ private[sbt] class JsonUtil(fileToStore: File => CacheStore) { def toLite(ur: UpdateReport): UpdateReportLite = UpdateReportLite(ur.configurations map { cr => ConfigurationReportLite(cr.configuration, cr.details map { oar => - new OrganizationArtifactReport(oar.organization, oar.name, oar.modules map { mr => - new ModuleReport( + OrganizationArtifactReport(oar.organization, oar.name, oar.modules map { mr => + ModuleReport( mr.module, mr.artifacts, mr.missingArtifacts, mr.status, mr.publicationDate, mr.resolver, mr.artifactResolver, mr.evicted, mr.evictedData, mr.evictedReason, @@ -63,7 +63,7 @@ private[sbt] class JsonUtil(fileToStore: File => CacheStore) { def fromLite(lite: UpdateReportLite, cachedDescriptor: File): UpdateReport = { - val stats = new UpdateStats(0L, 0L, 0L, false) + val stats = UpdateStats(0L, 0L, 0L, false) val configReports = lite.configurations map { cr => val details = cr.details val modules = details flatMap { @@ -71,8 +71,8 @@ private[sbt] class JsonUtil(fileToStore: File => CacheStore) { !mr.evicted && mr.problem.isEmpty } } - new ConfigurationReport(cr.configuration, modules, details) + ConfigurationReport(cr.configuration, modules, details) } - new UpdateReport(cachedDescriptor, configReports, stats, Map.empty) + UpdateReport(cachedDescriptor, configReports, stats, Map.empty) } } diff --git a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/RichUpdateReport.scala b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/RichUpdateReport.scala index 8b9f82922..ad6d3ae01 100644 --- a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/RichUpdateReport.scala +++ b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/RichUpdateReport.scala @@ -11,7 +11,7 @@ final class RichUpdateReport(report: UpdateReport) { { val files = report.cachedDescriptor +: allFiles val stamps = files.map(f => (f, f.lastModified)).toMap - new UpdateReport(report.cachedDescriptor, report.configurations, report.stats, stamps) + UpdateReport(report.cachedDescriptor, report.configurations, report.stats, stamps) } import DependencyFilter._ @@ -64,8 +64,8 @@ final class RichUpdateReport(report: UpdateReport) { val newConfigurations = report.configurations.map { confReport => import confReport._ val newModules = modules map { modReport => f(configuration, modReport) } - new ConfigurationReport(configuration, newModules, details) + ConfigurationReport(configuration, newModules, details) } - new UpdateReport(report.cachedDescriptor, newConfigurations, report.stats, report.stamps) + UpdateReport(report.cachedDescriptor, newConfigurations, report.stats, report.stamps) } } diff --git a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/ivyint/CachedResolutionResolveEngine.scala b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/ivyint/CachedResolutionResolveEngine.scala index 8c94be6f6..887a057f3 100644 --- a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/ivyint/CachedResolutionResolveEngine.scala +++ b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/ivyint/CachedResolutionResolveEngine.scala @@ -402,13 +402,13 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine { val cachedDescriptor = getSettings.getResolutionCacheManager.getResolvedIvyFileInCache(md0.getModuleRevisionId) val rootModuleConfigs = md0.getConfigurations.toVector val cachedReports = reports filter { !_.stats.cached } - val stats = new UpdateStats(resolveTime, (cachedReports map { _.stats.downloadTime }).sum, (cachedReports map { _.stats.downloadSize }).sum, false) + val stats = UpdateStats(resolveTime, (cachedReports map { _.stats.downloadTime }).sum, (cachedReports map { _.stats.downloadSize }).sum, false) val configReports = rootModuleConfigs map { conf => log.debug("::: -----------") val crs = reports flatMap { _.configurations filter { _.configuration == conf.getName } } mergeConfigurationReports(conf.getName, crs, os, log) } - new UpdateReport(cachedDescriptor, configReports, stats, Map.empty) + UpdateReport(cachedDescriptor, configReports, stats, Map.empty) } // memory usage 62%, of which 58% is in mergeOrganizationArtifactReports def mergeConfigurationReports(rootModuleConf: String, reports: Vector[ConfigurationReport], os: Vector[IvyOverride], log: Logger): ConfigurationReport = @@ -420,7 +420,7 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine { !mr.evicted && mr.problem.isEmpty } } - new ConfigurationReport(rootModuleConf, modules, details) + ConfigurationReport(rootModuleConf, modules, details) } /** * Returns a tuple of (merged org + name combo, newly evicted modules) @@ -579,7 +579,7 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine { val notEvicted = (survivor ++ newlyEvicted) filter { m => !m.evicted } log.debug("::: adds " + (notEvicted map { _.module }).mkString(", ")) log.debug("::: evicted " + (evicted map { _.module }).mkString(", ")) - val x = new OrganizationArtifactReport(organization, name, survivor ++ newlyEvicted) + val x = OrganizationArtifactReport(organization, name, survivor ++ newlyEvicted) val nextModules = transitivelyEvict(rootModuleConf, rest, allModules, evicted, log) x :: resolveConflicts(rest, nextModules) }) @@ -644,7 +644,7 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine { } val newlyEvicted = affected map { _.withEvicted(true).withEvictedReason(Some("transitive-evict")) } if (affected.isEmpty) oar - else new OrganizationArtifactReport(organization, name, unaffected ++ newlyEvicted) + else OrganizationArtifactReport(organization, name, unaffected ++ newlyEvicted) } Seq(((organization, name), oars)) } @@ -761,7 +761,7 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine { } mergeConfigurationReports(conf0.getName, remappedCRs, os, log) } - new UpdateReport(ur.cachedDescriptor, configurations, ur.stats, ur.stamps) + UpdateReport(ur.cachedDescriptor, configurations, ur.stats, ur.stamps) } } diff --git a/librarymanagement/src/main/scala/sbt/librarymanagement/ArtifactExtra.scala b/librarymanagement/src/main/scala/sbt/librarymanagement/ArtifactExtra.scala index e3a2d2793..fe662ca78 100644 --- a/librarymanagement/src/main/scala/sbt/librarymanagement/ArtifactExtra.scala +++ b/librarymanagement/src/main/scala/sbt/librarymanagement/ArtifactExtra.scala @@ -38,7 +38,7 @@ abstract class ArtifactFunctions { def apply(name: String, url: URL): Artifact = Artifact(name, extract(url, DefaultType), extract(url, DefaultExtension), None, Vector.empty, Some(url)) def apply(name: String, `type`: String, extension: String, classifier: Option[String], configurations: Vector[Configuration], url: Option[URL]): Artifact = - Artifact(name, `type`, extension, classifier, configurations, url, Map.empty) + Artifact(name, `type`, extension, classifier, configurations, url, Map.empty[String, String]) val DefaultExtension = "jar" val DefaultType = "jar" diff --git a/librarymanagement/src/main/scala/sbt/librarymanagement/ConfigurationExtra.scala b/librarymanagement/src/main/scala/sbt/librarymanagement/ConfigurationExtra.scala index f0d0fff7f..f3b267e24 100644 --- a/librarymanagement/src/main/scala/sbt/librarymanagement/ConfigurationExtra.scala +++ b/librarymanagement/src/main/scala/sbt/librarymanagement/ConfigurationExtra.scala @@ -4,7 +4,7 @@ package sbt.librarymanagement object Configurations { - def config(name: String) = new Configuration(name) + def config(name: String) = Configuration(name) def default: Seq[Configuration] = defaultMavenConfigurations def defaultMavenConfigurations: Seq[Configuration] = Seq(Compile, Runtime, Test, Provided, Optional) def defaultInternal: Seq[Configuration] = Seq(CompileInternal, RuntimeInternal, TestInternal) diff --git a/librarymanagement/src/main/scala/sbt/librarymanagement/CrossVersionExtra.scala b/librarymanagement/src/main/scala/sbt/librarymanagement/CrossVersionExtra.scala index d212e0e0a..ae1ec1c61 100644 --- a/librarymanagement/src/main/scala/sbt/librarymanagement/CrossVersionExtra.scala +++ b/librarymanagement/src/main/scala/sbt/librarymanagement/CrossVersionExtra.scala @@ -13,10 +13,10 @@ abstract class CrossVersionFunctions { val TransitionSbtVersion = CrossVersionUtil.TransitionSbtVersion /** Cross-versions a module with the full version (typically the full Scala version). */ - def full: CrossVersion = new Full() + def full: CrossVersion = Full() /** Cross-versions a module with the binary version (typically the binary Scala version). */ - def binary: CrossVersion = new Binary() + def binary: CrossVersion = Binary() private[sbt] def append(s: String): Option[String => String] = Some(x => crossName(x, s)) diff --git a/librarymanagement/src/main/scala/sbt/librarymanagement/IvyInterface.scala b/librarymanagement/src/main/scala/sbt/librarymanagement/IvyInterface.scala index cded9dcb5..7f7e1dc91 100644 --- a/librarymanagement/src/main/scala/sbt/librarymanagement/IvyInterface.scala +++ b/librarymanagement/src/main/scala/sbt/librarymanagement/IvyInterface.scala @@ -7,7 +7,7 @@ import org.apache.ivy.core.module.descriptor import org.apache.ivy.util.filter.{ Filter => IvyFilter } abstract class InclExclRuleFunctions { - def everything = new InclExclRule("*", "*", "*", Vector.empty) + def everything = InclExclRule("*", "*", "*", Vector.empty) } abstract class ArtifactTypeFilterExtra { diff --git a/librarymanagement/src/main/scala/sbt/librarymanagement/ResolverExtra.scala b/librarymanagement/src/main/scala/sbt/librarymanagement/ResolverExtra.scala index 9e73c1d7b..ce939a1ce 100644 --- a/librarymanagement/src/main/scala/sbt/librarymanagement/ResolverExtra.scala +++ b/librarymanagement/src/main/scala/sbt/librarymanagement/ResolverExtra.scala @@ -28,7 +28,7 @@ final class RawRepository(val resolver: DependencyResolver) extends Resolver(res abstract class MavenRepositoryFunctions { def apply(name: String, root: String, localIfFile: Boolean = true): MavenRepository = - new MavenRepo(name, root, localIfFile) + MavenRepo(name, root, localIfFile) } abstract class PatternsFunctions { diff --git a/librarymanagement/src/main/scala/sbt/librarymanagement/UpdateReportExtra.scala b/librarymanagement/src/main/scala/sbt/librarymanagement/UpdateReportExtra.scala index a0f98b020..23a93db8d 100644 --- a/librarymanagement/src/main/scala/sbt/librarymanagement/UpdateReportExtra.scala +++ b/librarymanagement/src/main/scala/sbt/librarymanagement/UpdateReportExtra.scala @@ -29,7 +29,7 @@ abstract class ConfigurationReportExtra { } def retrieve(f: (String, ModuleID, Artifact, File) => File): ConfigurationReport = - new ConfigurationReport(configuration, modules map { _.retrieve((mid, art, file) => f(configuration, mid, art, file)) }, details) + ConfigurationReport(configuration, modules map { _.retrieve((mid, art, file) => f(configuration, mid, art, file)) }, details) } abstract class ModuleReportExtra { @@ -141,7 +141,7 @@ abstract class UpdateReportExtra { } def retrieve(f: (String, ModuleID, Artifact, File) => File): UpdateReport = - new UpdateReport(cachedDescriptor, configurations map { _ retrieve f }, stats, stamps) + UpdateReport(cachedDescriptor, configurations map { _ retrieve f }, stats, stamps) /** Gets the report for the given configuration, or `None` if the configuration was not resolved.*/ def configuration(s: String) = configurations.find(_.configuration == s) diff --git a/librarymanagement/src/test/scala/BaseIvySpecification.scala b/librarymanagement/src/test/scala/BaseIvySpecification.scala index dc7f2a4bf..7906abb4f 100644 --- a/librarymanagement/src/test/scala/BaseIvySpecification.scala +++ b/librarymanagement/src/test/scala/BaseIvySpecification.scala @@ -30,7 +30,7 @@ trait BaseIvySpecification extends UnitSpec { def module(moduleId: ModuleID, deps: Vector[ModuleID], scalaFullVersion: Option[String], uo: UpdateOptions = UpdateOptions(), overrideScalaVersion: Boolean = true): IvySbt#Module = { val ivyScala = scalaFullVersion map { fv => - new IvyScala( + IvyScala( scalaFullVersion = fv, scalaBinaryVersion = CrossVersionUtil.binaryScalaVersion(fv), configurations = Vector.empty, @@ -56,7 +56,7 @@ trait BaseIvySpecification extends UnitSpec { def chainResolver = ChainedResolver("sbt-chain", resolvers) def mkIvyConfiguration(uo: UpdateOptions): IvyConfiguration = { - val paths = new IvyPaths(currentBase, Some(currentTarget)) + val paths = IvyPaths(currentBase, Some(currentTarget)) val other = Vector.empty val moduleConfs = Vector(ModuleConfiguration("*", chainResolver)) val off = false @@ -66,8 +66,8 @@ trait BaseIvySpecification extends UnitSpec { } def makeUpdateConfiguration: UpdateConfiguration = { - val retrieveConfig = new RetrieveConfiguration(currentManaged, Resolver.defaultRetrievePattern).withSync(false) - new UpdateConfiguration(Some(retrieveConfig), false, UpdateLogging.Full, ArtifactTypeFilter.forbid(Set("src", "doc"))) + val retrieveConfig = RetrieveConfiguration(currentManaged, Resolver.defaultRetrievePattern).withSync(false) + UpdateConfiguration(Some(retrieveConfig), false, UpdateLogging.Full, ArtifactTypeFilter.forbid(Set("src", "doc"))) } def ivyUpdateEither(module: IvySbt#Module): Either[UnresolvedWarning, UpdateReport] = { diff --git a/librarymanagement/src/test/scala/CustomPomParserTest.scala b/librarymanagement/src/test/scala/CustomPomParserTest.scala index eceec0d93..ba4b48161 100644 --- a/librarymanagement/src/test/scala/CustomPomParserTest.scala +++ b/librarymanagement/src/test/scala/CustomPomParserTest.scala @@ -14,7 +14,7 @@ class CustomPomParserTest extends UnitSpec { withTemporaryDirectory { cacheDir => val repoUrl = getClass.getResource("/test-maven-repo") val local = MavenRepository("Test Repo", repoUrl.toExternalForm) - val paths = new IvyPaths(new File("."), Some(cacheDir)) + val paths = IvyPaths(new File("."), Some(cacheDir)) val conf = new InlineIvyConfiguration(paths, Vector(local), Vector.empty, Vector.empty, false, None, Vector("sha1", "md5"), None, UpdateOptions(), log) val ivySbt = new IvySbt(conf, DefaultFileToStore) val resolveOpts = new ResolveOptions().setConfs(Array("default")) diff --git a/librarymanagement/src/test/scala/DMSerializationSpec.scala b/librarymanagement/src/test/scala/DMSerializationSpec.scala index ab1bb457b..bbbeef4f8 100644 --- a/librarymanagement/src/test/scala/DMSerializationSpec.scala +++ b/librarymanagement/src/test/scala/DMSerializationSpec.scala @@ -51,13 +51,13 @@ class DMSerializationSpec extends UnitSpec { } lazy val updateReportExample = - new UpdateReport(new File("./foo"), Vector(configurationReportExample), - new UpdateStats(0, 0, 0, false), Map(new File("./foo") -> 0)) + UpdateReport(new File("./foo"), Vector(configurationReportExample), + UpdateStats(0, 0, 0, false), Map(new File("./foo") -> 0)) lazy val configurationReportExample = - new ConfigurationReport("compile", Vector(moduleReportExample), + ConfigurationReport("compile", Vector(moduleReportExample), Vector(organizationArtifactReportExample)) lazy val organizationArtifactReportExample = - new OrganizationArtifactReport("org", "name", Vector(moduleReportExample)) + OrganizationArtifactReport("org", "name", Vector(moduleReportExample)) lazy val moduleReportExample = ModuleReport(ModuleID("org", "name", "1.0"), Vector.empty, Vector.empty) diff --git a/project/DatatypeConfig.scala b/project/DatatypeConfig.scala index 78159c476..9e5c8ffc5 100644 --- a/project/DatatypeConfig.scala +++ b/project/DatatypeConfig.scala @@ -1,23 +1,24 @@ -import sbt.datatype.{ CodecCodeGen, TpeRef } +import sbt.contraband.ast._ +import sbt.contraband.CodecCodeGen object DatatypeConfig { /** Extract the only type parameter from a TpeRef */ - def oneArg(tpe: TpeRef): TpeRef = { - val pat = s"""${CodecCodeGen.removeTypeParameters(tpe.name)}[<\\[](.+?)[>\\]]""".r + def oneArg(tpe: Type): Type = { + val pat = s"""${tpe.removeTypeParameters.name}[<\\[](.+?)[>\\]]""".r val pat(arg0) = tpe.name - TpeRef(arg0, false, false, false) + NamedType(arg0 split '.' toList) } /** Extract the two type parameters from a TpeRef */ - def twoArgs(tpe: TpeRef): List[TpeRef] = { - val pat = s"""${CodecCodeGen.removeTypeParameters(tpe.name)}[<\\[](.+?), (.+?)[>\\]]""".r + def twoArgs(tpe: Type): List[Type] = { + val pat = s"""${tpe.removeTypeParameters.name}[<\\[](.+?), (.+?)[>\\]]""".r val pat(arg0, arg1) = tpe.name - TpeRef(arg0, false, false, false) :: TpeRef(arg1, false, false, false) :: Nil + NamedType(arg0 split '.' toList) :: NamedType(arg1 split '.' toList) :: Nil } /** Codecs that were manually written. */ - val myCodecs: PartialFunction[String, TpeRef => List[String]] = { + val myCodecs: PartialFunction[String, Type => List[String]] = { case "java.util.Date" => { _ => "sbt.internal.librarymanagement.formats.DateFormat" :: Nil } case "scala.xml.NodeSeq" => { _ => "sbt.internal.librarymanagement.formats.NodeSeqFormat" :: Nil } @@ -32,7 +33,7 @@ object DatatypeConfig { { _ => "sbt.internal.librarymanagement.formats.UpdateOptionsFormat" :: Nil } // TODO: These are handled by BasicJsonProtocol, and sbt-datatype should handle them by default, imo - case "Option" | "Set" => { tpe => getFormats(oneArg(tpe)) } + case "Option" | "Set" | "scala.Vector" => { tpe => getFormats(oneArg(tpe)) } case "Map" | "Tuple2" | "scala.Tuple2" => { tpe => twoArgs(tpe).flatMap(getFormats) } case "Int" | "Long" => { _ => Nil } } @@ -43,13 +44,13 @@ object DatatypeConfig { "sbt.librarymanagement.ExclusionRule") /** Returns the list of formats required to encode the given `TpeRef`. */ - val getFormats: TpeRef => List[String] = + val getFormats: Type => List[String] = CodecCodeGen.extensibleFormatsForType { - case TpeRef("sbt.internal.librarymanagement.RetrieveConfiguration", false, false, false) => + case NamedType(List("sbt", "internal", "librarymanagement", "RetrieveConfiguration"), _) => "sbt.librarymanagement.RetrieveConfigurationFormats" :: Nil - case tpe @ TpeRef(name, _, _, _) if myCodecs isDefinedAt CodecCodeGen.removeTypeParameters(name) => - myCodecs(CodecCodeGen.removeTypeParameters(name))(tpe) - case TpeRef(name, _, _, _) if excluded contains CodecCodeGen.removeTypeParameters(name) => + case tpe: Type if myCodecs isDefinedAt tpe.removeTypeParameters.name => + myCodecs(tpe.removeTypeParameters.name)(tpe) + case tpe: Type if excluded contains tpe.removeTypeParameters.name => Nil case other => CodecCodeGen.formatsForType(other) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index ffd6d43ac..5403ebe05 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -4,8 +4,8 @@ import Keys._ object Dependencies { val scala211 = "2.11.8" - private val ioVersion = "1.0.0-M6" - private val utilVersion = "0.1.0-M15" + private val ioVersion = "1.0.0-M9" + private val utilVersion = "1.0.0-M17" private val sbtIO = "org.scala-sbt" %% "io" % ioVersion @@ -45,7 +45,7 @@ object Dependencies { val jsch = "com.jcraft" % "jsch" % "0.1.46" intransitive () val scalaReflect = Def.setting { "org.scala-lang" % "scala-reflect" % scalaVersion.value } val scalaXml = scala211Module("scala-xml", "1.0.5") - val sjsonnewVersion = "0.4.1" + val sjsonnewVersion = "0.7.0" val sjsonnewScalaJson = "com.eed3si9n" %% "sjson-new-scalajson" % sjsonnewVersion private def scala211Module(name: String, moduleVersion: String) = diff --git a/project/contraband.sbt b/project/contraband.sbt new file mode 100644 index 000000000..88961b8f9 --- /dev/null +++ b/project/contraband.sbt @@ -0,0 +1 @@ +addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.0-M3") diff --git a/project/sbt-datatype.sbt b/project/sbt-datatype.sbt deleted file mode 100644 index c13a23ad7..000000000 --- a/project/sbt-datatype.sbt +++ /dev/null @@ -1 +0,0 @@ -addSbtPlugin("org.scala-sbt" % "sbt-datatype" % "0.2.8")