* Fix 'reload' behavior with respect to sbt.version

* Add test for artifacts
This commit is contained in:
Mark Harrah 2010-01-12 18:50:47 -05:00
parent 1474afb680
commit e02afb36c8
6 changed files with 69 additions and 2 deletions

View File

@ -170,7 +170,8 @@ trait ManagedProject extends ClasspathProject
* so that the Ivy 'extends' mechanism is not required. That way, the jars are only copied to one configuration.*/
def managedClasspath(config: Configuration): PathFinder = configurationClasspath(config)
/** All dependencies in the given configuration. */
final def configurationClasspath(config: Configuration): PathFinder = descendents(configurationPath(config), "*.jar")
final def configurationClasspath(config: Configuration): PathFinder = descendents(configurationPath(config), classpathFilter)
def classpathFilter: FileFilter = "*.jar"
/** The base path to which dependencies in configuration 'config' are downloaded.*/
def configurationPath(config: Configuration): Path = managedDependencyPath / config.toString

View File

@ -151,7 +151,7 @@ class xMain extends xsbti.AppMain
{
case "" :: tail => continue(project, tail, failAction)
case (ExitCommand | QuitCommand) :: _ => result( Exit(NormalExitCode) )
case RebootCommand :: tail => result( Reboot(project.defScalaVersion.value, rememberCurrent(tail), configuration) )
case RebootCommand :: tail => throw new xsbti.FullReload(rememberCurrent(tail).toArray)
case InteractiveCommand :: _ => continue(project, prompt(baseProject, project) :: arguments, interactiveContinue)
case SpecificBuild(version, action) :: tail =>
if(Some(version) != baseProject.info.buildScalaVersion)

View File

@ -0,0 +1,2 @@
project.name=Test
project.version=1.0

View File

@ -0,0 +1,42 @@
import sbt._
class ArtifactTest(info: ProjectInfo) extends DefaultProject(info)
{
// use cache specific to this test
def ivyCacheDirectory = outputPath / "ivy-cache"
override def updateOptions = CacheDirectory(ivyCacheDirectory) :: super.updateOptions.toList
// define a test repository to publish to
override def managedStyle = ManagedStyle.Maven
val publishTo = Resolver.file("Test Repo", ("test-repo") asFile)
// define strings for defining the artifact
override def artifactID = "test"
def ext = "test2"
def classifier = "test3"
def tpe = "test1"
def vers = "1.1"
def org = "test"
// define the jar
override def jarPath = outputPath / (artifactID + "-" + vers + "-" + classifier + "." + ext)
def artifact = Artifact(artifactID, tpe, ext, classifier)
// define the IDs to use for publishing and retrieving
def publishedID = org % artifactID % vers artifacts(artifact)
def retrieveID = org % "test-retrieve" % "2.0"
override def projectID = if(retrieve) retrieveID else publishedID
override def libraryDependencies = if(retrieve) Set(publishedID) else super.libraryDependencies
// switches between publish and retrieve mode
def retrieve = "retrieve".asFile.exists
// needed to add a jar with a different extension to the classpath
override def classpathFilter = "*." + ext
// check that the test class is on the compile classpath, either because it was compiled or because it was properly retrieved
lazy val check = task { check0 }
def check0 =
try { Class.forName("test.Test", false, loader); None }
catch { case _: ClassNotFoundException | _: NoClassDefFoundError => Some("Dependency not retrieved properly") }
def loader = new java.net.URLClassLoader(compileClasspath.get.map(_.asURL).toSeq.toArray, buildScalaInstance.loader)
}

View File

@ -0,0 +1,2 @@
package test
class Test

View File

@ -0,0 +1,20 @@
# verify that check fails when test class is not present
-> check
# compile and jar test class
> package
# verify that check succeeds
> check
# publish test jar to test repository
>publish
# delete test jar and verify check fails again
> clean
-> check
# tell project definition to switch to retrieve mode
$ touch retrieve
# verify that artifact with extension, type, and classifier can be retreieved
> update
> check