mirror of https://github.com/sbt/sbt.git
inject internal configurations into pom ModuleDescriptor. fixes #59
This commit is contained in:
parent
f38d6aa7f4
commit
69fec711be
|
|
@ -142,7 +142,7 @@ final class IvySbt(val configuration: IvyConfiguration)
|
|||
{
|
||||
val mod = new DefaultModuleDescriptor(IvySbt.toID(module), "release", null, false)
|
||||
mod.setLastModified(System.currentTimeMillis)
|
||||
configurations.foreach(config => mod.addConfiguration(IvySbt.toIvyConfiguration(config)))
|
||||
IvySbt.addConfigurations(mod, configurations)
|
||||
IvySbt.addArtifacts(mod, module.explicitArtifacts)
|
||||
mod
|
||||
}
|
||||
|
|
@ -151,7 +151,9 @@ final class IvySbt(val configuration: IvyConfiguration)
|
|||
private def readPom(pomFile: File, validate: Boolean) =
|
||||
{
|
||||
val md = PomModuleDescriptorParser.getInstance.parseDescriptor(settings, toURL(pomFile), validate)
|
||||
(IvySbt.toDefaultModuleDescriptor(md), "compile")
|
||||
val dmd = IvySbt.toDefaultModuleDescriptor(md)
|
||||
IvySbt.addConfigurations(dmd, Configurations.defaultInternal)
|
||||
(dmd, "compile")
|
||||
}
|
||||
/** Parses the given Ivy file 'ivyFile'.*/
|
||||
private def readIvyFile(ivyFile: File, validate: Boolean) =
|
||||
|
|
@ -408,6 +410,8 @@ private object IvySbt
|
|||
def addArtifacts(moduleID: DefaultModuleDescriptor, artifacts: Iterable[Artifact]): Unit =
|
||||
for(art <- mapArtifacts(moduleID, artifacts.toSeq); c <- art.getConfigurations)
|
||||
moduleID.addArtifact(c, art)
|
||||
def addConfigurations(mod: DefaultModuleDescriptor, configurations: Iterable[Configuration]): Unit =
|
||||
configurations.foreach(config => mod.addConfiguration(toIvyConfiguration(config)))
|
||||
|
||||
def mapArtifacts(moduleID: ModuleDescriptor, artifacts: Seq[Artifact]): Seq[IArtifact] =
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,20 +17,20 @@ package object sbt extends sbt.std.TaskExtra with sbt.Types with sbt.ProcessExtr
|
|||
def file(s: String): File = new File(s)
|
||||
def url(s: String): URL = new URL(s)
|
||||
|
||||
def ThisScope = Scope.ThisScope
|
||||
def GlobalScope = Scope.GlobalScope
|
||||
final val ThisScope = Scope.ThisScope
|
||||
final val GlobalScope = Scope.GlobalScope
|
||||
|
||||
import sbt.{Configurations => C}
|
||||
def Compile = C.Compile
|
||||
def Test = C.Test
|
||||
def Runtime = C.Runtime
|
||||
def IntegrationTest = C.IntegrationTest
|
||||
def Default = C.Default
|
||||
def Docs = C.Docs
|
||||
def Sources = C.Sources
|
||||
def Provided = C.Provided
|
||||
final val Compile = C.Compile
|
||||
final val Test = C.Test
|
||||
final val Runtime = C.Runtime
|
||||
final val IntegrationTest = C.IntegrationTest
|
||||
final val Default = C.Default
|
||||
final val Docs = C.Docs
|
||||
final val Sources = C.Sources
|
||||
final val Provided = C.Provided
|
||||
// java.lang.System is more important, so don't alias this one
|
||||
// def System = C.System
|
||||
def Optional = C.Optional
|
||||
// final val System = C.System
|
||||
final val Optional = C.Optional
|
||||
def config(s: String): Configuration = Configurations.config(s)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>sbt-pom</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.scalatest</groupId>
|
||||
<artifactId>scalatest_2.9.0</artifactId>
|
||||
<version>1.6.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.scala-lang</groupId>
|
||||
<artifactId>scala-library</artifactId>
|
||||
<version>2.9.0-1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import complete._
|
||||
import complete.DefaultParsers._
|
||||
|
||||
object MyBuild extends Build
|
||||
{
|
||||
lazy val root = Project("root", file(".")) settings( externalPom() :_*) settings(
|
||||
scalaVersion := "2.9.0-1",
|
||||
check <<= checkTask,
|
||||
managedClasspath in Provided <<= (classpathTypes, update) map { (cpts, report) => Classpaths.managedJars(Provided, cpts, report) }
|
||||
)
|
||||
|
||||
def checkTask = InputTask(_ => parser ) { result =>
|
||||
(result, managedClasspath in Provided, fullClasspath in Compile, fullClasspath in Test, fullClasspath in Runtime) map { case ((conf, names), p, c, t, r) =>
|
||||
println("Checking: " + conf.name)
|
||||
checkClasspath(conf match {
|
||||
case Provided => p
|
||||
case Compile => c
|
||||
case Test => t
|
||||
case Runtime => r
|
||||
}, names.toSet)
|
||||
}
|
||||
}
|
||||
|
||||
lazy val check = InputKey[Unit]("check")
|
||||
def parser: Parser[(Configuration,Seq[String])] = (Space ~> token(cp(Compile) | cp(Runtime) | cp(Provided) | cp(Test))) ~ spaceDelimited("<module-names>")
|
||||
def cp(c: Configuration): Parser[Configuration] = c.name ^^^ c
|
||||
def checkClasspath(cp: Seq[Attributed[File]], names: Set[String]) =
|
||||
{
|
||||
val fs = cp.files filter { _.getName endsWith ".jar" }
|
||||
val intersect = fs filter { f => names exists { f.getName startsWith _ } }
|
||||
assert(intersect == fs, "Expected:" + seqStr(names.toSeq) + "Got: " + seqStr(fs))
|
||||
()
|
||||
}
|
||||
def seqStr(s: Seq[_]) = s.mkString("\n\t", "\n\t", "\n")
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
> check test scalatest scala-library.jar servlet-api
|
||||
> check runtime scala-library
|
||||
> check compile scala-library servlet-api
|
||||
Loading…
Reference in New Issue