aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--stage1/Stage1Lib.scala4
-rw-r--r--stage1/resolver.scala68
-rw-r--r--test/simple/build/build.scala28
-rw-r--r--test/test.scala2
5 files changed, 68 insertions, 35 deletions
diff --git a/.gitignore b/.gitignore
index a924fed..b6ecdc7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,4 @@ examples/dotty-example/_site
examples/scalajs-plain-example/server/public/generated
examples/scalajs-react-example/server/public/generated
.cbt-loop.tmp
+test/simple/src_generated
diff --git a/stage1/Stage1Lib.scala b/stage1/Stage1Lib.scala
index 1cda9fd..83febe8 100644
--- a/stage1/Stage1Lib.scala
+++ b/stage1/Stage1Lib.scala
@@ -239,7 +239,7 @@ class Stage1Lib( logger: Logger ) extends BaseLib{
zincDeps
.collect{ case d @
BoundMavenDependency(
- _, _, MavenDependency( "com.typesafe.sbt", "sbt-interface", _, Classifier.none, _), _
+ _, _, MavenDependency( "com.typesafe.sbt", "sbt-interface", _, Classifier.none, _), _, _
) => d
}
.headOption
@@ -250,7 +250,7 @@ class Stage1Lib( logger: Logger ) extends BaseLib{
zincDeps
.collect{ case d @
BoundMavenDependency(
- _, _, MavenDependency( "com.typesafe.sbt", "compiler-interface", _, Classifier.sources, _), _
+ _, _, MavenDependency( "com.typesafe.sbt", "compiler-interface", _, Classifier.sources, _), _, _
) => d
}
.headOption
diff --git a/stage1/resolver.scala b/stage1/resolver.scala
index 1d539a2..105177e 100644
--- a/stage1/resolver.scala
+++ b/stage1/resolver.scala
@@ -220,7 +220,8 @@ object MavenDependency{
}
// FIXME: take MavenResolver instead of mavenCache and repositories separately
case class BoundMavenDependency(
- cbtLastModified: Long, mavenCache: File, mavenDependency: MavenDependency, repositories: Seq[URL]
+ cbtLastModified: Long, mavenCache: File, mavenDependency: MavenDependency, repositories: Seq[URL],
+ replace: MavenDependency => Seq[MavenDependency] => Seq[MavenDependency] = _ => (identity _)
)(
implicit val logger: Logger, val transientCache: java.util.Map[AnyRef,AnyRef], val classLoaderCache: ClassLoaderCache
) extends ArtifactInfo with DependencyImplementation{
@@ -302,8 +303,9 @@ case class BoundMavenDependency(
(parent \ "artifactId").text,
(parent \ "version").text
),
- repositories
- )
+ repositories,
+ replace
+ )(logger, transientCache, classLoaderCache)
}.flatMap(_.transitivePom) :+ this
}
@@ -330,37 +332,39 @@ case class BoundMavenDependency(
).toMap
def dependencies: Seq[BoundMavenDependency] = {
- if(classifier == Classifier.sources) Seq()
- else {
- lib.cacheOnDisk(
+ replace(mavenDependency)(
+ if(classifier == Classifier.sources) Seq()
+ else {
+ lib.cacheOnDisk(
cbtLastModified, mavenCache ++ basePath(true) ++ ".pom.dependencies"
- )( MavenDependency.deserialize )( _.serialize ){
- (pomXml \ "dependencies" \ "dependency").collect{
+ )( MavenDependency.deserialize )( _.serialize ){
+ (pomXml \ "dependencies" \ "dependency").collect{
case xml if ( (xml \ "scope").text == "" || (xml \ "scope").text == "compile" ) && (xml \ "optional").text != "true" =>
- val artifactId = lookup(xml,_ \ "artifactId").get
- val groupId =
- lookup(xml,_ \ "groupId").getOrElse(
- dependencyVersions
- .get(artifactId).map(_._1)
- .getOrElse(
- throw new Exception(s"$artifactId not found in \n$dependencyVersions")
- )
- )
- val version =
- lookup(xml,_ \ "version").getOrElse(
- dependencyVersions
- .get(artifactId).map(_._2)
- .getOrElse(
- throw new Exception(s"$artifactId not found in \n$dependencyVersions")
- )
- )
- val classifier = Classifier( Some( (xml \ "classifier").text ).filterNot(_ == "").filterNot(_ == null) )
- MavenDependency( groupId, artifactId, version, classifier )
- }.toVector
- }.map(
- BoundMavenDependency( cbtLastModified, mavenCache, _, repositories )
- ).to
- }
+ val artifactId = lookup(xml,_ \ "artifactId").get
+ val groupId =
+ lookup(xml,_ \ "groupId").getOrElse(
+ dependencyVersions
+ .get(artifactId).map(_._1)
+ .getOrElse(
+ throw new Exception(s"$artifactId not found in \n$dependencyVersions")
+ )
+ )
+ val version =
+ lookup(xml,_ \ "version").getOrElse(
+ dependencyVersions
+ .get(artifactId).map(_._2)
+ .getOrElse(
+ throw new Exception(s"$artifactId not found in \n$dependencyVersions")
+ )
+ )
+ val classifier = Classifier( Some( (xml \ "classifier").text ).filterNot(_ == "").filterNot(_ == null) )
+ MavenDependency( groupId, artifactId, version, classifier )
+ }.toVector
+ }
+ }
+ ).map(
+ BoundMavenDependency( cbtLastModified, mavenCache, _, repositories, replace )
+ ).to
}
def lookup( xml: Node, accessor: Node => NodeSeq ): Option[String] = {
// println("lookup in " + xml)
diff --git a/test/simple/build/build.scala b/test/simple/build/build.scala
index dd5f95b..3465ec3 100644
--- a/test/simple/build/build.scala
+++ b/test/simple/build/build.scala
@@ -15,7 +15,7 @@ class Build(val context: cbt.Context) extends BaseBuild{
// the below tests pom inheritance with variable substitution being parts of strings
MavenDependency("cc.factorie","factorie_2.11","1.2"),
// test recursive substitution. see https://github.com/cvogt/cbt/issues/434
- MavenDependency("com.amazonaws", "aws-java-sdk-s3", "1.11.86")
+ MavenDependency("com.amazonaws", "aws-java-sdk-s3", "1.11.86"),
// the dependency below uses a maven version range. Currently not supported.
// TODO: put in a proper error message for version range not supported
//MavenDependency("com.github.nikita-volkov", "sext", "0.2.4")
@@ -23,6 +23,19 @@ class Build(val context: cbt.Context) extends BaseBuild{
// org.apache.spark:spark-sql_2.11:1.6.1
// currently fails, let's see if because of a bug
// io.spray:spray-http:1.3.3
+ ScalaDependency( "com.lihaoyi", "scalatex-api", "0.3.6" ),
+ ScalaDependency( "com.lihaoyi", "scalatex-site", "0.3.6" )
+ ) ++
+ Resolver( mavenCentral, sonatypeReleases ).bind(
+ "org.scalameta" %% "scalameta" % "1.1.0"
+ ).map(
+ _.copy(
+ // without this .replace the ScalatexCrash will crash during macro expansion
+ replace = _ => _.map{
+ case MavenDependency("com.lihaoyi","scalaparse_2.11",_,_,_) => "com.lihaoyi" % "scalaparse_2.11" % "0.3.1"
+ case other => other
+ }
+ )
) ++
Resolver( new java.net.URL("http://maven.spikemark.net/roundeights") ).bind(
// Check that lower case checksums work
@@ -39,4 +52,17 @@ class Build(val context: cbt.Context) extends BaseBuild{
)
def printArgs = context.args.mkString(" ")
+
+ override def compile = {
+ val dummyScalatexFile = projectDirectory / "src_generated" / "ScalatexCrash.scalatex"
+ lib.write( dummyScalatexFile, "" )
+ lib.write(
+ projectDirectory / "src_generated" / "ScalatexCrash.scala",
+ s"""object ScalatexCrash{
+ import _root_.scalatags.Text.all._
+ val file = _root_.scalatex.twf("${dummyScalatexFile}")
+ }"""
+ )
+ super.compile
+ }
}
diff --git a/test/test.scala b/test/test.scala
index c49d1e5..6c629bb 100644
--- a/test/test.scala
+++ b/test/test.scala
@@ -92,6 +92,7 @@ object Main{
assert(res.out contains usageString, usageString + " not found in " ++ res.toString)
}
def compile(path: String)(implicit logger: Logger) = task("compile", path)
+ def run(path: String)(implicit logger: Logger) = task("run", path)
def task(name: String, path: String)(implicit logger: Logger) = {
val res = runCbt(path, Seq(name))
val debugToken = name ++ " " ++ path ++ " "
@@ -207,6 +208,7 @@ object Main{
clean("multi-build")
usage("simple")
compile("simple")
+ run("simple")
clean("simple")
if( compat ){
usage("simple-fixed")