Skip to content

Commit

Permalink
Merge pull request #124 from sbt/topic/api
Browse files Browse the repository at this point in the history
Library management API
  • Loading branch information
eed3si9n authored Jul 15, 2017
2 parents 0243eb7 + 509c80c commit 0147e0c
Show file tree
Hide file tree
Showing 249 changed files with 2,696 additions and 1,683 deletions.
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
librarymanagement module for sbt
================================

```
git clone --no-hardlinks --branch 0.13 sbt sbt-modules/librarymanagement
cd sbt-modules/librarymanagement
git filter-branch --index-filter 'git rm --cached -qr -- . && git reset -q $GIT_COMMIT -- ivy util/cross' --prune-empty
git reset --hard
git gc --aggressive
git prune
git cb 1.0
```scala
scala> import java.io.File
import java.io.File

scala> import sbt.librarymanagement._, syntax._
import sbt.librarymanagement._
import syntax._

scala> val log = sbt.util.LogExchange.logger("test")
log: sbt.internal.util.ManagedLogger = sbt.internal.util.ManagedLogger@c439b0f

scala> val lm = {
import sbt.librarymanagement.ivy._
val ivyConfig = InlineIvyConfiguration().withLog(log)
IvyDependencyResolution(ivyConfig)
}
lm: sbt.librarymanagement.DependencyResolution = sbt.librarymanagement.DependencyResolution@6a9b40f8

scala> val module = "commons-io" % "commons-io" % "2.5"
module: sbt.librarymanagement.ModuleID = commons-io:commons-io:2.5

scala> lm.retrieve(module, scalaModuleInfo = None, new File("target"), log)
res0: Either[sbt.librarymanagement.UnresolvedWarning,Vector[java.io.File]] = Right(Vector(target/jars/commons-io/commons-io/commons-io-2.5.jar, target/jars/commons-io/commons-io/commons-io-2.5.jar, target/jars/commons-io/commons-io/commons-io-2.5.jar))
```
23 changes: 18 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def commonSettings: Seq[Setting[_]] = Seq(
)

lazy val lmRoot = (project in file("."))
.aggregate(lm)
.aggregate(lmCore, lmIvy)
.settings(
inThisBuild(
Seq(
Expand Down Expand Up @@ -60,12 +60,12 @@ lazy val lmRoot = (project in file("."))
customCommands
)

lazy val lm = (project in file("librarymanagement"))
lazy val lmCore = (project in file("core"))
.enablePlugins(ContrabandPlugin, JsonCodecPlugin)
.settings(
commonSettings,
name := "librarymanagement",
libraryDependencies ++= Seq(ivy,
jsch,
name := "librarymanagement-core",
libraryDependencies ++= Seq(jsch,
scalaReflect.value,
scalaCompiler.value,
launcherInterface,
Expand Down Expand Up @@ -94,7 +94,20 @@ lazy val lm = (project in file("librarymanagement"))
}
)
.configure(addSbtIO, addSbtUtilLogging, addSbtUtilPosition, addSbtUtilCache)

lazy val lmIvy = (project in file("ivy"))
.enablePlugins(ContrabandPlugin, JsonCodecPlugin)
.dependsOn(lmCore)
.settings(
commonSettings,
name := "librarymanagement-ivy",
libraryDependencies ++= Seq(ivy, scalaTest, scalaCheck),
managedSourceDirectories in Compile +=
baseDirectory.value / "src" / "main" / "contraband-scala",
sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala",
contrabandFormatsForType in generateContrabands in Compile := DatatypeConfig.getFormats,
scalacOptions in (Compile, console) --= Vector("-Ywarn-unused-import", "-Ywarn-unused", "-Xlint"),
)

def customCommands: Seq[Setting[_]] = Seq(
commands += Command.command("release") { state =>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class ConfigurationReportLite private (
case _ => false
}
override def hashCode: Int = {
37 * (37 * (37 * (17 + "ConfigurationReportLite".##) + configuration.##) + details.##)
37 * (37 * (37 * (17 + "sbt.internal.librarymanagement.ConfigurationReportLite".##) + configuration.##) + details.##)
}
override def toString: String = {
"ConfigurationReportLite(" + configuration + ", " + details + ")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class UpdateReportLite private (
case _ => false
}
override def hashCode: Int = {
37 * (37 * (17 + "UpdateReportLite".##) + configurations.##)
37 * (37 * (17 + "sbt.internal.librarymanagement.UpdateReportLite".##) + configurations.##)
}
override def toString: String = {
"UpdateReportLite(" + configurations + ")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class Artifact private (
case _ => false
}
override def hashCode: Int = {
37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "Artifact".##) + name.##) + `type`.##) + extension.##) + classifier.##) + configurations.##) + url.##) + extraAttributes.##) + checksum.##)
37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "sbt.librarymanagement.Artifact".##) + name.##) + `type`.##) + extension.##) + classifier.##) + configurations.##) + url.##) + extraAttributes.##) + checksum.##)
}
override def toString: String = {
"Artifact(" + name + ", " + `type` + ", " + extension + ", " + classifier + ", " + configurations + ", " + url + ", " + extraAttributes + ", " + checksum + ")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class ArtifactTypeFilter private (
case _ => false
}
override def hashCode: Int = {
37 * (37 * (37 * (17 + "ArtifactTypeFilter".##) + types.##) + inverted.##)
37 * (37 * (37 * (17 + "sbt.librarymanagement.ArtifactTypeFilter".##) + types.##) + inverted.##)
}
override def toString: String = {
"ArtifactTypeFilter(" + types + ", " + inverted + ")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class Binary private (
case _ => false
}
override def hashCode: Int = {
37 * (37 * (37 * (17 + "Binary".##) + prefix.##) + suffix.##)
37 * (37 * (37 * (17 + "sbt.librarymanagement.Binary".##) + prefix.##) + suffix.##)
}
override def toString: String = {
"Binary(" + prefix + ", " + suffix + ")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class Caller private (
case _ => false
}
override def hashCode: Int = {
37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "Caller".##) + caller.##) + callerConfigurations.##) + callerExtraAttributes.##) + isForceDependency.##) + isChangingDependency.##) + isTransitiveDependency.##) + isDirectlyForceDependency.##)
37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "sbt.librarymanagement.Caller".##) + caller.##) + callerConfigurations.##) + callerExtraAttributes.##) + isForceDependency.##) + isChangingDependency.##) + isTransitiveDependency.##) + isDirectlyForceDependency.##)
}
override def toString: String = {
s"$caller"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class ChainedResolver private (
case _ => false
}
override def hashCode: Int = {
37 * (37 * (37 * (17 + "ChainedResolver".##) + name.##) + resolvers.##)
37 * (37 * (37 * (17 + "sbt.librarymanagement.ChainedResolver".##) + name.##) + resolvers.##)
}
override def toString: String = {
"ChainedResolver(" + name + ", " + resolvers + ")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class Checksum private (
case _ => false
}
override def hashCode: Int = {
37 * (37 * (37 * (17 + "Checksum".##) + digest.##) + `type`.##)
37 * (37 * (37 * (17 + "sbt.librarymanagement.Checksum".##) + digest.##) + `type`.##)
}
override def toString: String = {
"Checksum(" + digest + ", " + `type` + ")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class ConfigRef private (
case _ => false
}
override def hashCode: Int = {
37 * (37 * (17 + "ConfigRef".##) + name.##)
37 * (37 * (17 + "sbt.librarymanagement.ConfigRef".##) + name.##)
}
override def toString: String = {
name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class ConfigurationReport private (
case _ => false
}
override def hashCode: Int = {
37 * (37 * (37 * (37 * (17 + "ConfigurationReport".##) + configuration.##) + modules.##) + details.##)
37 * (37 * (37 * (37 * (17 + "sbt.librarymanagement.ConfigurationReport".##) + configuration.##) + modules.##) + details.##)
}
override def toString: String = {
s"\t$configuration:\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class ConflictManager private (
case _ => false
}
override def hashCode: Int = {
37 * (37 * (37 * (37 * (17 + "ConflictManager".##) + name.##) + organization.##) + module.##)
37 * (37 * (37 * (37 * (17 + "sbt.librarymanagement.ConflictManager".##) + name.##) + organization.##) + module.##)
}
override def toString: String = {
"ConflictManager(" + name + ", " + organization + ", " + module + ")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class Constant private (
case _ => false
}
override def hashCode: Int = {
37 * (37 * (17 + "Constant".##) + value.##)
37 * (37 * (17 + "sbt.librarymanagement.Constant".##) + value.##)
}
override def toString: String = {
"Constant(" + value + ")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ override def equals(o: Any): Boolean = o match {
case _ => false
}
override def hashCode: Int = {
37 * (17 + "CrossVersion".##)
37 * (17 + "sbt.librarymanagement.CrossVersion".##)
}
override def toString: String = {
"CrossVersion()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class Developer private (
case _ => false
}
override def hashCode: Int = {
37 * (37 * (37 * (37 * (37 * (17 + "Developer".##) + id.##) + name.##) + email.##) + url.##)
37 * (37 * (37 * (37 * (37 * (17 + "sbt.librarymanagement.Developer".##) + id.##) + name.##) + email.##) + url.##)
}
override def toString: String = {
"Developer(" + id + ", " + name + ", " + email + ", " + url + ")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ override def equals(o: Any): Boolean = o match {
case _ => false
}
override def hashCode: Int = {
37 * (17 + "Disabled".##)
37 * (17 + "sbt.librarymanagement.Disabled".##)
}
override def toString: String = {
"Disabled()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class FileConfiguration private (
case _ => false
}
override def hashCode: Int = {
37 * (37 * (37 * (17 + "FileConfiguration".##) + isLocal.##) + isTransactional.##)
37 * (37 * (37 * (17 + "sbt.librarymanagement.FileConfiguration".##) + isLocal.##) + isTransactional.##)
}
override def toString: String = {
"FileConfiguration(" + isLocal + ", " + isTransactional + ")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class FileRepository private (
case _ => false
}
override def hashCode: Int = {
37 * (37 * (37 * (37 * (17 + "FileRepository".##) + name.##) + patterns.##) + configuration.##)
37 * (37 * (37 * (37 * (17 + "sbt.librarymanagement.FileRepository".##) + name.##) + patterns.##) + configuration.##)
}
override def toString: String = {
"FileRepository(" + name + ", " + patterns + ", " + configuration + ")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class Full private (
case _ => false
}
override def hashCode: Int = {
37 * (37 * (37 * (17 + "Full".##) + prefix.##) + suffix.##)
37 * (37 * (37 * (17 + "sbt.librarymanagement.Full".##) + prefix.##) + suffix.##)
}
override def toString: String = {
"Full(" + prefix + ", " + suffix + ")"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]].
*/

// DO NOT EDIT MANUALLY
package sbt.librarymanagement
final class GetClassifiersConfiguration private (
val module: sbt.librarymanagement.GetClassifiersModule,
val excludes: Vector[scala.Tuple2[sbt.librarymanagement.ModuleID, scala.Vector[sbt.librarymanagement.ConfigRef]]],
val updateConfiguration: sbt.librarymanagement.UpdateConfiguration,
val sourceArtifactTypes: Vector[String],
val docArtifactTypes: Vector[String]) extends Serializable {



override def equals(o: Any): Boolean = o match {
case x: GetClassifiersConfiguration => (this.module == x.module) && (this.excludes == x.excludes) && (this.updateConfiguration == x.updateConfiguration) && (this.sourceArtifactTypes == x.sourceArtifactTypes) && (this.docArtifactTypes == x.docArtifactTypes)
case _ => false
}
override def hashCode: Int = {
37 * (37 * (37 * (37 * (37 * (37 * (17 + "sbt.librarymanagement.GetClassifiersConfiguration".##) + module.##) + excludes.##) + updateConfiguration.##) + sourceArtifactTypes.##) + docArtifactTypes.##)
}
override def toString: String = {
"GetClassifiersConfiguration(" + module + ", " + excludes + ", " + updateConfiguration + ", " + sourceArtifactTypes + ", " + docArtifactTypes + ")"
}
protected[this] def copy(module: sbt.librarymanagement.GetClassifiersModule = module, excludes: Vector[scala.Tuple2[sbt.librarymanagement.ModuleID, scala.Vector[sbt.librarymanagement.ConfigRef]]] = excludes, updateConfiguration: sbt.librarymanagement.UpdateConfiguration = updateConfiguration, sourceArtifactTypes: Vector[String] = sourceArtifactTypes, docArtifactTypes: Vector[String] = docArtifactTypes): GetClassifiersConfiguration = {
new GetClassifiersConfiguration(module, excludes, updateConfiguration, sourceArtifactTypes, docArtifactTypes)
}
def withModule(module: sbt.librarymanagement.GetClassifiersModule): GetClassifiersConfiguration = {
copy(module = module)
}
def withExcludes(excludes: Vector[scala.Tuple2[sbt.librarymanagement.ModuleID, scala.Vector[sbt.librarymanagement.ConfigRef]]]): GetClassifiersConfiguration = {
copy(excludes = excludes)
}
def withUpdateConfiguration(updateConfiguration: sbt.librarymanagement.UpdateConfiguration): GetClassifiersConfiguration = {
copy(updateConfiguration = updateConfiguration)
}
def withSourceArtifactTypes(sourceArtifactTypes: Vector[String]): GetClassifiersConfiguration = {
copy(sourceArtifactTypes = sourceArtifactTypes)
}
def withDocArtifactTypes(docArtifactTypes: Vector[String]): GetClassifiersConfiguration = {
copy(docArtifactTypes = docArtifactTypes)
}
}
object GetClassifiersConfiguration {

def apply(module: sbt.librarymanagement.GetClassifiersModule, excludes: Vector[scala.Tuple2[sbt.librarymanagement.ModuleID, scala.Vector[sbt.librarymanagement.ConfigRef]]], updateConfiguration: sbt.librarymanagement.UpdateConfiguration, sourceArtifactTypes: Vector[String], docArtifactTypes: Vector[String]): GetClassifiersConfiguration = new GetClassifiersConfiguration(module, excludes, updateConfiguration, sourceArtifactTypes, docArtifactTypes)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]].
*/

// DO NOT EDIT MANUALLY
package sbt.librarymanagement
import _root_.sjsonnew.{ Unbuilder, Builder, JsonFormat, deserializationError }
trait GetClassifiersConfigurationFormats { self: sbt.librarymanagement.GetClassifiersModuleFormats with sbt.librarymanagement.ModuleIDFormats with sbt.librarymanagement.ConfigRefFormats with sbt.librarymanagement.UpdateConfigurationFormats with sjsonnew.BasicJsonProtocol =>
implicit lazy val GetClassifiersConfigurationFormat: JsonFormat[sbt.librarymanagement.GetClassifiersConfiguration] = new JsonFormat[sbt.librarymanagement.GetClassifiersConfiguration] {
override def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]): sbt.librarymanagement.GetClassifiersConfiguration = {
jsOpt match {
case Some(js) =>
unbuilder.beginObject(js)
val module = unbuilder.readField[sbt.librarymanagement.GetClassifiersModule]("module")
val excludes = unbuilder.readField[Vector[scala.Tuple2[sbt.librarymanagement.ModuleID, scala.Vector[sbt.librarymanagement.ConfigRef]]]]("excludes")
val updateConfiguration = unbuilder.readField[sbt.librarymanagement.UpdateConfiguration]("updateConfiguration")
val sourceArtifactTypes = unbuilder.readField[Vector[String]]("sourceArtifactTypes")
val docArtifactTypes = unbuilder.readField[Vector[String]]("docArtifactTypes")
unbuilder.endObject()
sbt.librarymanagement.GetClassifiersConfiguration(module, excludes, updateConfiguration, sourceArtifactTypes, docArtifactTypes)
case None =>
deserializationError("Expected JsObject but found None")
}
}
override def write[J](obj: sbt.librarymanagement.GetClassifiersConfiguration, builder: Builder[J]): Unit = {
builder.beginObject()
builder.addField("module", obj.module)
builder.addField("excludes", obj.excludes)
builder.addField("updateConfiguration", obj.updateConfiguration)
builder.addField("sourceArtifactTypes", obj.sourceArtifactTypes)
builder.addField("docArtifactTypes", obj.docArtifactTypes)
builder.endObject()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]].
*/

// DO NOT EDIT MANUALLY
package sbt.librarymanagement
final class GetClassifiersModule private (
val id: sbt.librarymanagement.ModuleID,
val scalaModuleInfo: Option[sbt.librarymanagement.ScalaModuleInfo],
val dependencies: Vector[sbt.librarymanagement.ModuleID],
val configurations: Vector[sbt.librarymanagement.Configuration],
val classifiers: Vector[String]) extends Serializable {



override def equals(o: Any): Boolean = o match {
case x: GetClassifiersModule => (this.id == x.id) && (this.scalaModuleInfo == x.scalaModuleInfo) && (this.dependencies == x.dependencies) && (this.configurations == x.configurations) && (this.classifiers == x.classifiers)
case _ => false
}
override def hashCode: Int = {
37 * (37 * (37 * (37 * (37 * (37 * (17 + "sbt.librarymanagement.GetClassifiersModule".##) + id.##) + scalaModuleInfo.##) + dependencies.##) + configurations.##) + classifiers.##)
}
override def toString: String = {
"GetClassifiersModule(" + id + ", " + scalaModuleInfo + ", " + dependencies + ", " + configurations + ", " + classifiers + ")"
}
protected[this] def copy(id: sbt.librarymanagement.ModuleID = id, scalaModuleInfo: Option[sbt.librarymanagement.ScalaModuleInfo] = scalaModuleInfo, dependencies: Vector[sbt.librarymanagement.ModuleID] = dependencies, configurations: Vector[sbt.librarymanagement.Configuration] = configurations, classifiers: Vector[String] = classifiers): GetClassifiersModule = {
new GetClassifiersModule(id, scalaModuleInfo, dependencies, configurations, classifiers)
}
def withId(id: sbt.librarymanagement.ModuleID): GetClassifiersModule = {
copy(id = id)
}
def withScalaModuleInfo(scalaModuleInfo: Option[sbt.librarymanagement.ScalaModuleInfo]): GetClassifiersModule = {
copy(scalaModuleInfo = scalaModuleInfo)
}
def withScalaModuleInfo(scalaModuleInfo: sbt.librarymanagement.ScalaModuleInfo): GetClassifiersModule = {
copy(scalaModuleInfo = Option(scalaModuleInfo))
}
def withDependencies(dependencies: Vector[sbt.librarymanagement.ModuleID]): GetClassifiersModule = {
copy(dependencies = dependencies)
}
def withConfigurations(configurations: Vector[sbt.librarymanagement.Configuration]): GetClassifiersModule = {
copy(configurations = configurations)
}
def withClassifiers(classifiers: Vector[String]): GetClassifiersModule = {
copy(classifiers = classifiers)
}
}
object GetClassifiersModule {

def apply(id: sbt.librarymanagement.ModuleID, scalaModuleInfo: Option[sbt.librarymanagement.ScalaModuleInfo], dependencies: Vector[sbt.librarymanagement.ModuleID], configurations: Vector[sbt.librarymanagement.Configuration], classifiers: Vector[String]): GetClassifiersModule = new GetClassifiersModule(id, scalaModuleInfo, dependencies, configurations, classifiers)
def apply(id: sbt.librarymanagement.ModuleID, scalaModuleInfo: sbt.librarymanagement.ScalaModuleInfo, dependencies: Vector[sbt.librarymanagement.ModuleID], configurations: Vector[sbt.librarymanagement.Configuration], classifiers: Vector[String]): GetClassifiersModule = new GetClassifiersModule(id, Option(scalaModuleInfo), dependencies, configurations, classifiers)
}
Loading

0 comments on commit 0147e0c

Please sign in to comment.