Skip to content

Commit

Permalink
Revert "add exclusions and custom configuration to dependencies (#254)"
Browse files Browse the repository at this point in the history
This reverts commit a4713c3.
  • Loading branch information
lihaoyi committed Apr 6, 2018
1 parent c6572bc commit 9ebd19b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 143 deletions.
4 changes: 2 additions & 2 deletions main/test/src/mill/eval/JavaCompileJarTests.scala
Expand Up @@ -11,10 +11,10 @@ import mill.util.Strict.Agg
import utest._
import mill._
object JavaCompileJarTests extends TestSuite{
def compileAll(sources: Seq[PathRef])(implicit ctx: Dest) = {
def compileAll(sources: mill.util.Loose.Agg[PathRef])(implicit ctx: Dest) = {
mkdir(ctx.dest)
import ammonite.ops._
%("javac", sources.map(_.path.toString()), "-d", ctx.dest)(wd = ctx.dest)
%("javac", sources.map(_.path.toString()).toSeq, "-d", ctx.dest)(wd = ctx.dest)
PathRef(ctx.dest)
}

Expand Down
14 changes: 0 additions & 14 deletions scalalib/src/mill/scalalib/Dep.scala
Expand Up @@ -3,20 +3,6 @@ import mill.util.JsonFormatters._
import upickle.default.{macroRW, ReadWriter => RW}
sealed trait Dep {
def configure(attributes: coursier.Attributes): Dep
def exclude(exclusions: (String, String)*): Dep =
this match {
case dep : Dep.Java => dep.copy(dep = dep.dep.copy(exclusions = dep.dep.exclusions ++ exclusions))
case dep : Dep.Scala => dep.copy(dep = dep.dep.copy(exclusions = dep.dep.exclusions ++ exclusions))
case dep : Dep.Point => dep.copy(dep = dep.dep.copy(exclusions = dep.dep.exclusions ++ exclusions))
}
def excludeOrg(organizations: String*): Dep = exclude(organizations.map(_ -> "*"): _*)
def excludeName(names: String*): Dep = exclude(names.map("*" -> _): _*)
def withConfiguration(configuration: String): Dep =
this match {
case dep : Dep.Java => dep.copy(dep = dep.dep.copy(configuration = configuration))
case dep : Dep.Scala => dep.copy(dep = dep.dep.copy(configuration = configuration))
case dep : Dep.Point => dep.copy(dep = dep.dep.copy(configuration = configuration))
}
}
object Dep{

Expand Down
8 changes: 2 additions & 6 deletions scalalib/src/mill/scalalib/publish/Ivy.scala
Expand Up @@ -41,12 +41,8 @@ object Ivy {
}

private def renderDependency(dep: Dependency) = {
if (dep.exclusions.isEmpty)
<dependency org={dep.artifact.group} name={dep.artifact.id} rev={dep.artifact.version} conf={s"${dep.scope}->default(${dep.configuration.getOrElse("compile")})"} />
else
<dependency org={dep.artifact.group} name={dep.artifact.id} rev={dep.artifact.version} conf={s"${dep.scope}->default(${dep.configuration.getOrElse("compile")})"}>
{dep.exclusions.map(ex => <exclude org={ex._1} name={ex._2} matcher="exact"/>).toSeq}
</dependency>
val scope = scopeToConf(dep.scope)
<dependency org={dep.artifact.group} name={dep.artifact.id} rev={dep.artifact.version} conf={s"$scope->default(compile)"}></dependency>
}

private def scopeToConf(s: Scope): String = s match {
Expand Down
28 changes: 6 additions & 22 deletions scalalib/src/mill/scalalib/publish/Pom.scala
Expand Up @@ -90,28 +90,12 @@ object Pom {
case Scope.Test => <scope>test</scope>
case Scope.Runtime => <scope>runtime</scope>
}
if (d.exclusions.isEmpty)
<dependency>
<groupId>{d.artifact.group}</groupId>
<artifactId>{d.artifact.id}</artifactId>
<version>{d.artifact.version}</version>
{scope}
</dependency>
else
<dependency>
<groupId>{d.artifact.group}</groupId>
<artifactId>{d.artifact.id}</artifactId>
<version>{d.artifact.version}</version>
<exclusions>
{d.exclusions.map(ex =>
<exclude>
<groupId>{ex._1}</groupId>
<artifactId>{ex._2}</artifactId>
</exclude>
)}.toSeq
</exclusions>
{scope}
</dependency>
<dependency>
<groupId>{d.artifact.group}</groupId>
<artifactId>{d.artifact.id}</artifactId>
<version>{d.artifact.version}</version>
{scope}
</dependency>
}

}
16 changes: 4 additions & 12 deletions scalalib/src/mill/scalalib/publish/settings.scala
Expand Up @@ -15,9 +15,7 @@ object Artifact {
case Dep.Java(dep, cross) =>
Dependency(
Artifact(dep.module.organization, dep.module.name, dep.version),
Scope.Compile,
if (dep.configuration == "" ) None else Some(dep.configuration),
dep.exclusions.toList
Scope.Compile
)
case Dep.Scala(dep, cross) =>
Dependency(
Expand All @@ -26,9 +24,7 @@ object Artifact {
s"${dep.module.name}_${scalaBin}",
dep.version
),
Scope.Compile,
if (dep.configuration == "") None else Some(dep.configuration),
dep.exclusions.toList
Scope.Compile
)
case Dep.Point(dep, cross) =>
Dependency(
Expand All @@ -37,9 +33,7 @@ object Artifact {
s"${dep.module.name}_${scalaFull}",
dep.version
),
Scope.Compile,
if (dep.configuration == "") None else Some(dep.configuration),
dep.exclusions.toList
Scope.Compile
)
}
}
Expand All @@ -55,9 +49,7 @@ object Scope {

case class Dependency(
artifact: Artifact,
scope: Scope,
configuration: Option[String] = None,
exclusions: Seq[(String, String)] = Nil
scope: Scope
)

case class Developer(
Expand Down
18 changes: 0 additions & 18 deletions scalalib/test/src/mill/scalalib/ResolveDepsTests.scala
Expand Up @@ -26,24 +26,6 @@ object ResolveDepsTests extends TestSuite {
assert(paths.items.next.path.toString.contains("natives-macos"))
}

'excludeTransitiveDeps - {
val deps = Agg(ivy"com.lihaoyi::pprint:0.5.3".exclude("com.lihaoyi" -> "fansi_2.12"))
val Success(paths) = evalDeps(deps)
assert(!paths.exists(_.path.toString.contains("fansi_2.12")))
}

'excludeTransitiveDepsByOrg - {
val deps = Agg(ivy"com.lihaoyi::pprint:0.5.3".excludeOrg("com.lihaoyi"))
val Success(paths) = evalDeps(deps)
assert(!paths.exists(path => path.path.toString.contains("com/lihaoyi") && !path.path.toString.contains("pprint_2.12")))
}

'excludeTransitiveDepsByName - {
val deps = Agg(ivy"com.lihaoyi::pprint:0.5.3".excludeName("fansi_2.12"))
val Success(paths) = evalDeps(deps)
assert(!paths.exists(_.path.toString.contains("fansi_2.12")))
}

'errOnInvalidOrgDeps - {
val deps = Agg(ivy"xxx.yyy.invalid::pprint:0.5.3")
val Failure(errMsg, _) = evalDeps(deps)
Expand Down
60 changes: 0 additions & 60 deletions scalalib/test/src/mill/scalalib/publish/IvyTests.scala

This file was deleted.

12 changes: 3 additions & 9 deletions scalalib/test/src/mill/scalalib/publish/PomTests.scala
Expand Up @@ -15,9 +15,7 @@ object PomTests extends TestSuite {
Dependency(Artifact("com.lihaoyi", "mill-main_2.12", "0.1.4"),
Scope.Compile),
Dependency(Artifact("org.scala-sbt", "test-interface", "1.0"),
Scope.Compile),
Dependency(Artifact("com.lihaoyi", "pprint_2.12", "0.5.3"),
Scope.Compile, exclusions = List("com.lihaoyi" -> "fansi_2.12", "*" -> "sourcecode_2.12"))
Scope.Compile)
)
val settings = PomSettings(
description = "mill-scalalib",
Expand Down Expand Up @@ -106,7 +104,7 @@ object PomTests extends TestSuite {
'dependencies - {
val dependencies = fullPom \ "dependencies" \ "dependency"

assert(dependencies.size == 3)
assert(dependencies.size == 2)

val pomDeps = deps.indexed

Expand All @@ -116,11 +114,7 @@ object PomTests extends TestSuite {
singleText(dep \ "groupId") == pomDeps(index).artifact.group,
singleText(dep \ "artifactId") == pomDeps(index).artifact.id,
singleText(dep \ "version") == pomDeps(index).artifact.version,
optText(dep \ "scope").isEmpty,
(dep \ "exclusions").zipWithIndex.forall { case (node, j) =>
singleText(node \ "exclude" \ "groupId") == pomDeps(index).exclusions(j)._1 &&
singleText(node \ "exclude" \ "artifactId") == pomDeps(index).exclusions(j)._2
}
optText(dep \ "scope").isEmpty
)
}
}
Expand Down

0 comments on commit 9ebd19b

Please sign in to comment.