Backport style changes in scripted tests and Defaults.scala (#2715)

* Backport style changes in tests and Defaults.scala

This backports the scripted tests and Defaults.scala style changes to
use `build.sbt` and `:=`.
This commit is contained in:
eugene yokota 2016-08-29 15:14:39 -04:00 committed by Dale Wijnand
parent d0ce0cef49
commit cd216a2758
163 changed files with 1426 additions and 1458 deletions

View File

@ -107,7 +107,7 @@ object Defaults extends BuildCommon {
scalaOrganization :== ScalaArtifacts.Organization,
sbtResolver := { if (sbtVersion.value endsWith "-SNAPSHOT") Classpaths.typesafeSnapshots else Classpaths.typesafeReleases },
crossVersion :== CrossVersion.Disabled,
buildDependencies <<= Classpaths.constructBuildDependencies,
buildDependencies := Classpaths.constructBuildDependencies.value,
version :== "0.1-SNAPSHOT",
classpathTypes :== Set("jar", "bundle") ++ CustomPomParser.JarPackagings,
artifactClassifier :== None,
@ -146,9 +146,9 @@ object Defaults extends BuildCommon {
skip :== false,
taskTemporaryDirectory := { val dir = IO.createTemporaryDirectory; dir.deleteOnExit(); dir },
onComplete := { val dir = taskTemporaryDirectory.value; () => { IO.delete(dir); IO.createDirectory(dir) } },
Previous.cache <<= Previous.cacheSetting,
Previous.cache := Previous.cacheSetting.value,
Previous.references :== new Previous.References,
concurrentRestrictions <<= defaultRestrictions,
concurrentRestrictions := defaultRestrictions.value,
parallelExecution :== true,
pollInterval :== 500,
logBuffered :== false,
@ -172,12 +172,12 @@ object Defaults extends BuildCommon {
def projectCore: Seq[Setting[_]] = Seq(
name := thisProject.value.id,
logManager := LogManager.defaults(extraLoggers.value, StandardMain.console),
onLoadMessage <<= onLoadMessage or (name, thisProjectRef)("Set current project to " + _ + " (in build " + _.build + ")")
onLoadMessage := (onLoadMessage or (name, thisProjectRef)("Set current project to " + _ + " (in build " + _.build + ")")).value
)
def paths = Seq(
baseDirectory := thisProject.value.base,
target := baseDirectory.value / "target",
historyPath <<= historyPath or target(t => Some(t / ".history")),
historyPath := (historyPath or target(t => Option(t / ".history"))).value,
sourceDirectory := baseDirectory.value / "src",
sourceManaged := crossTarget.value / "src_managed",
resourceManaged := crossTarget.value / "resource_managed",
@ -186,31 +186,31 @@ object Defaults extends BuildCommon {
lazy val configPaths = sourceConfigPaths ++ resourceConfigPaths ++ outputConfigPaths
lazy val sourceConfigPaths = Seq(
sourceDirectory <<= configSrcSub(sourceDirectory),
sourceManaged <<= configSrcSub(sourceManaged),
sourceDirectory := configSrcSub(sourceDirectory).value,
sourceManaged := configSrcSub(sourceManaged).value,
scalaSource := sourceDirectory.value / "scala",
javaSource := sourceDirectory.value / "java",
unmanagedSourceDirectories := makeCrossSources(scalaSource.value, javaSource.value, scalaBinaryVersion.value, crossPaths.value),
unmanagedSources <<= collectFiles(unmanagedSourceDirectories, includeFilter in unmanagedSources, excludeFilter in unmanagedSources),
watchSources in ConfigGlobal <++= unmanagedSources,
unmanagedSources := collectFiles(unmanagedSourceDirectories, includeFilter in unmanagedSources, excludeFilter in unmanagedSources).value,
watchSources in ConfigGlobal ++= unmanagedSources.value,
managedSourceDirectories := Seq(sourceManaged.value),
managedSources <<= generate(sourceGenerators),
managedSources := generate(sourceGenerators).value,
sourceGenerators :== Nil,
sourceDirectories <<= Classpaths.concatSettings(unmanagedSourceDirectories, managedSourceDirectories),
sources <<= Classpaths.concat(unmanagedSources, managedSources)
sourceDirectories := Classpaths.concatSettings(unmanagedSourceDirectories, managedSourceDirectories).value,
sources := Classpaths.concat(unmanagedSources, managedSources).value
)
lazy val resourceConfigPaths = Seq(
resourceDirectory := sourceDirectory.value / "resources",
resourceManaged <<= configSrcSub(resourceManaged),
resourceManaged := configSrcSub(resourceManaged).value,
unmanagedResourceDirectories := Seq(resourceDirectory.value),
managedResourceDirectories := Seq(resourceManaged.value),
resourceDirectories <<= Classpaths.concatSettings(unmanagedResourceDirectories, managedResourceDirectories),
unmanagedResources <<= collectFiles(unmanagedResourceDirectories, includeFilter in unmanagedResources, excludeFilter in unmanagedResources),
resourceDirectories := Classpaths.concatSettings(unmanagedResourceDirectories, managedResourceDirectories).value,
unmanagedResources := collectFiles(unmanagedResourceDirectories, includeFilter in unmanagedResources, excludeFilter in unmanagedResources).value,
watchSources in ConfigGlobal ++= unmanagedResources.value,
resourceGenerators :== Nil,
resourceGenerators <+= (discoveredSbtPlugins, resourceManaged) map PluginDiscovery.writeDescriptors,
managedResources <<= generate(resourceGenerators),
resources <<= Classpaths.concat(managedResources, unmanagedResources)
resourceGenerators += ((discoveredSbtPlugins, resourceManaged) map PluginDiscovery.writeDescriptors).taskValue,
managedResources := generate(resourceGenerators).value,
resources := Classpaths.concat(managedResources, unmanagedResources).value
)
lazy val outputConfigPaths = Seq(
cacheDirectory := crossTarget.value / CacheDirectoryName / thisProject.value.id / configuration.value.name,
@ -229,7 +229,7 @@ object Defaults extends BuildCommon {
def compileBase = inTask(console)(compilersSetting :: Nil) ++ compileBaseGlobal ++ Seq(
incOptions := incOptions.value.withNewClassfileManager(
sbt.inc.ClassfileManager.transactional(crossTarget.value / "classes.bak", sbt.Logger.Null)),
scalaInstance <<= scalaInstanceTask,
scalaInstance := scalaInstanceTask.value,
crossVersion := (if (crossPaths.value) CrossVersion.binary else CrossVersion.Disabled),
crossTarget := makeCrossTarget(target.value, scalaBinaryVersion.value, sbtBinaryVersion.value, sbtPlugin.value, crossPaths.value),
clean := {
@ -269,10 +269,10 @@ object Defaults extends BuildCommon {
bootIvyConfiguration.value, scalaCompilerBridgeSource.value)(appConfiguration.value, streams.value.log)
lazy val configTasks = docTaskSettings(doc) ++ inTask(compile)(compileInputsSettings) ++ configGlobal ++ compileAnalysisSettings ++ Seq(
compile <<= compileTask,
compile := compileTask.value,
manipulateBytecode := compileIncremental.value,
compileIncremental <<= compileIncrementalTask tag (Tags.Compile, Tags.CPU),
printWarnings <<= printWarningsTask,
compileIncremental := (compileIncrementalTask tag (Tags.Compile, Tags.CPU)).value,
printWarnings := printWarningsTask.value,
compileAnalysisFilename := {
// Here, if the user wants cross-scala-versioning, we also append it
// to the analysis cache, so we keep the scala versions separated.
@ -281,19 +281,18 @@ object Defaults extends BuildCommon {
else ""
s"inc_compile${extra}"
},
compileIncSetup <<= compileIncSetupTask,
console <<= consoleTask,
consoleQuick <<= consoleQuickTask,
discoveredMainClasses <<= compile map discoverMainClasses storeAs discoveredMainClasses triggeredBy compile,
definedSbtPlugins <<= discoverPlugins,
discoveredSbtPlugins <<= discoverSbtPluginNames,
compileIncSetup := compileIncSetupTask.value,
console := consoleTask.value,
consoleQuick := consoleQuickTask.value,
discoveredMainClasses := (compile map discoverMainClasses storeAs discoveredMainClasses triggeredBy compile).value,
discoveredSbtPlugins := discoverSbtPluginNames.value,
inTask(run)(runnerTask :: Nil).head,
selectMainClass := mainClass.value orElse askForMainClass(discoveredMainClasses.value),
mainClass in run := (selectMainClass in run).value,
mainClass := pickMainClassOrWarn(discoveredMainClasses.value, streams.value.log),
run <<= runTask(fullClasspath, mainClass in run, runner in run),
runMain <<= runMainTask(fullClasspath, runner in run),
copyResources <<= copyResourcesTask
run := runTask(fullClasspath, mainClass in run, runner in run).evaluated,
runMain := runMainTask(fullClasspath, runner in run).evaluated,
copyResources := copyResourcesTask.value
)
private[this] lazy val configGlobal = globalDefaults(Seq(
initialCommands :== "",
@ -304,9 +303,9 @@ object Defaults extends BuildCommon {
cleanFiles := Seq(managedDirectory.value, target.value),
cleanKeepFiles := historyPath.value.toList,
clean := doClean(cleanFiles.value, cleanKeepFiles.value),
consoleProject <<= consoleProjectTask,
watchTransitiveSources <<= watchTransitiveSourcesTask,
watch <<= watchSetting
consoleProject := consoleProjectTask.value,
watchTransitiveSources := watchTransitiveSourcesTask.value,
watch := watchSetting.value
)
def generate(generators: SettingKey[Seq[Task[Seq[File]]]]): Initialize[Task[Seq[File]]] = generators { _.join.map(_.flatten) }
@ -419,18 +418,18 @@ object Defaults extends BuildCommon {
lazy val testTasks: Seq[Setting[_]] = testTaskOptions(test) ++ testTaskOptions(testOnly) ++ testTaskOptions(testQuick) ++ testDefaults ++ Seq(
testLoader := TestFramework.createTestLoader(data(fullClasspath.value), scalaInstance.value, IO.createUniqueDirectory(taskTemporaryDirectory.value)),
loadedTestFrameworks := testFrameworks.value.flatMap(f => f.create(testLoader.value, streams.value.log).map(x => (f, x)).toIterable).toMap,
definedTests <<= detectTests,
definedTestNames <<= definedTests map (_.map(_.name).distinct) storeAs definedTestNames triggeredBy compile,
testFilter in testQuick <<= testQuickFilter,
executeTests <<= (streams in test, loadedTestFrameworks, testLoader, testGrouping in test, testExecution in test, fullClasspath in test, javaHome in test, testForkedParallel, javaOptions in test) flatMap allTestGroupsTask,
definedTests := detectTests.value,
definedTestNames := (definedTests map (_.map(_.name).distinct) storeAs definedTestNames triggeredBy compile).value,
testFilter in testQuick := testQuickFilter.value,
executeTests := ((streams in test, loadedTestFrameworks, testLoader, testGrouping in test, testExecution in test, fullClasspath in test, javaHome in test, testForkedParallel, javaOptions in test) flatMap allTestGroupsTask).value,
testResultLogger in (Test, test) :== TestResultLogger.SilentWhenNoTests, // https://github.com/sbt/sbt/issues/1185
test := {
val trl = (testResultLogger in (Test, test)).value
val taskName = Project.showContextKey(state.value)(resolvedScoped.value)
trl.run(streams.value.log, executeTests.value, taskName)
},
testOnly <<= inputTests(testOnly),
testQuick <<= inputTests(testQuick)
testOnly := inputTests(testOnly).evaluated,
testQuick := inputTests(testQuick).evaluated
)
lazy val TaskGlobal: Scope = ThisScope.copy(task = Global)
lazy val ConfigGlobal: Scope = ThisScope.copy(config = Global)
@ -441,9 +440,9 @@ object Defaults extends BuildCommon {
testListeners.in(TaskGlobal).value
},
testOptions := Tests.Listeners(testListeners.value) +: (testOptions in TaskGlobal).value,
testExecution <<= testExecutionTask(key)
testExecution := testExecutionTask(key).value
)) ++ inScope(GlobalScope)(Seq(
derive(testGrouping <<= singleTestGroupDefault)
derive(testGrouping := singleTestGroupDefault.value)
))
@deprecated("Doesn't provide for closing the underlying resources.", "0.13.1")
def testLogger(manager: Streams, baseKey: Scoped)(tdef: TestDefinition): Logger =
@ -620,7 +619,18 @@ object Defaults extends BuildCommon {
lazy val packageConfig: Seq[Setting[_]] =
inTask(packageBin)(Seq(
packageOptions <<= (name, version, homepage, organization, organizationName, mainClass, packageOptions) map { (name, ver, h, org, orgName, main, p) => Package.addSpecManifestAttributes(name, ver, orgName) +: Package.addImplManifestAttributes(name, ver, h, org, orgName) +: main.map(Package.MainClass.apply) ++: p })) ++
packageOptions := {
val n = name.value
val ver = version.value
val org = organization.value
val orgName = organizationName.value
val main = mainClass.value
val old = packageOptions.value
Package.addSpecManifestAttributes(n, ver, orgName) +:
Package.addImplManifestAttributes(n, ver, homepage.value, org, orgName) +:
main.map(Package.MainClass.apply) ++: old
}
)) ++
inTask(packageSrc)(Seq(
packageOptions := Package.addSpecManifestAttributes(name.value, version.value, organizationName.value) +: packageOptions.value)) ++
packageTaskSettings(packageBin, packageBinMappings) ++
@ -690,12 +700,12 @@ object Defaults extends BuildCommon {
def packageTasks(key: TaskKey[File], mappingsTask: Initialize[Task[Seq[(File, String)]]]) = packageTaskSettings(key, mappingsTask)
def packageTaskSettings(key: TaskKey[File], mappingsTask: Initialize[Task[Seq[(File, String)]]]) =
inTask(key)(Seq(
key in TaskGlobal <<= packageTask,
packageConfiguration <<= packageConfigurationTask,
mappings <<= mappingsTask,
key in TaskGlobal := packageTask.value,
packageConfiguration := packageConfigurationTask.value,
mappings := mappingsTask.value,
packagedArtifact := (artifact.value -> key.value),
artifact <<= artifactSetting,
artifactPath <<= artifactPathSetting(artifact)
artifact := artifactSetting.value,
artifactPath := artifactPathSetting(artifact).value
))
def packageTask: Initialize[Task[File]] =
(packageConfiguration, streams) map { (config, s) =>
@ -752,7 +762,7 @@ object Defaults extends BuildCommon {
}
}
def runnerTask = runner <<= runnerInit
def runnerTask = runner := runnerInit.value
def runnerInit: Initialize[Task[ScalaRun]] = Def.task {
val tmp = taskTemporaryDirectory.value
val resolvedScope = resolvedScoped.value.scope
@ -806,8 +816,8 @@ object Defaults extends BuildCommon {
}
))
def mainRunTask = run <<= runTask(fullClasspath in Runtime, mainClass in run, runner in run)
def mainRunMainTask = runMain <<= runMainTask(fullClasspath in Runtime, runner in run)
def mainRunTask = run := runTask(fullClasspath in Runtime, mainClass in run, runner in run).evaluated
def mainRunMainTask = runMain := runMainTask(fullClasspath in Runtime, runner in run).evaluated
def discoverMainClasses(analysis: inc.Analysis): Seq[String] =
Discovery.applications(Tests.allDefs(analysis)).collect({ case (definition, discovered) if discovered.hasMain => definition.name }).sorted
@ -1026,20 +1036,20 @@ object Classpaths {
def concatSettings[T](a: SettingKey[Seq[T]], b: SettingKey[Seq[T]]): Initialize[Seq[T]] = (a, b)(_ ++ _)
lazy val configSettings: Seq[Setting[_]] = classpaths ++ Seq(
products <<= makeProducts,
products := makeProducts.value,
productDirectories := classDirectory.value :: Nil,
classpathConfiguration := findClasspathConfig(internalConfigurationMap.value, configuration.value, classpathConfiguration.?.value, update.value)
)
private[this] def classpaths: Seq[Setting[_]] = Seq(
externalDependencyClasspath <<= concat(unmanagedClasspath, managedClasspath),
dependencyClasspath <<= concat(internalDependencyClasspath, externalDependencyClasspath),
fullClasspath <<= concatDistinct(exportedProducts, dependencyClasspath),
internalDependencyClasspath <<= internalDependencies,
unmanagedClasspath <<= unmanagedDependencies,
externalDependencyClasspath := concat(unmanagedClasspath, managedClasspath).value,
dependencyClasspath := concat(internalDependencyClasspath, externalDependencyClasspath).value,
fullClasspath := concatDistinct(exportedProducts, dependencyClasspath).value,
internalDependencyClasspath := internalDependencies.value,
unmanagedClasspath := unmanagedDependencies.value,
managedClasspath := managedJars(classpathConfiguration.value, classpathTypes.value, update.value),
exportedProducts <<= trackedExportedProducts(TrackLevel.TrackAlways),
exportedProductsIfMissing <<= trackedExportedProducts(TrackLevel.TrackIfMissing),
exportedProductsNoTracking <<= trackedExportedProducts(TrackLevel.NoTracking),
exportedProducts := trackedExportedProducts(TrackLevel.TrackAlways).value,
exportedProductsIfMissing := trackedExportedProducts(TrackLevel.TrackIfMissing).value,
exportedProductsNoTracking := trackedExportedProducts(TrackLevel.NoTracking).value,
unmanagedJars := findUnmanagedJars(configuration.value, unmanagedBase.value, includeFilter in unmanagedJars value, excludeFilter in unmanagedJars value)
).map(exportClasspath)
@ -1083,8 +1093,8 @@ object Classpaths {
))
val jvmPublishSettings: Seq[Setting[_]] = Seq(
artifacts <<= artifactDefs(defaultArtifactTasks),
packagedArtifacts <<= packaged(defaultArtifactTasks)
artifacts := artifactDefs(defaultArtifactTasks).value,
packagedArtifacts := packaged(defaultArtifactTasks).value
)
val ivyPublishSettings: Seq[Setting[_]] = publishGlobalDefaults ++ Seq(
@ -1093,11 +1103,11 @@ object Classpaths {
crossTarget := target.value,
makePom := { val config = makePomConfiguration.value; IvyActions.makePom(ivyModule.value, config, streams.value.log); config.file },
packagedArtifact in makePom := ((artifact in makePom).value -> makePom.value),
deliver <<= deliverTask(deliverConfiguration),
deliverLocal <<= deliverTask(deliverLocalConfiguration),
publish <<= publishTask(publishConfiguration, deliver),
publishLocal <<= publishTask(publishLocalConfiguration, deliverLocal),
publishM2 <<= publishTask(publishM2Configuration, deliverLocal)
deliver := deliverTask(deliverConfiguration).value,
deliverLocal := deliverTask(deliverLocalConfiguration).value,
publish := publishTask(publishConfiguration, deliver).value,
publishLocal := publishTask(publishLocalConfiguration, deliverLocal).value,
publishM2 := publishTask(publishM2Configuration, deliverLocal).value
)
@deprecated("This has been split into jvmPublishSettings and ivyPublishSettings.", "0.13.2")
val publishSettings: Seq[Setting[_]] = ivyPublishSettings ++ jvmPublishSettings
@ -1139,18 +1149,18 @@ object Classpaths {
conflictWarning := conflictWarning.value.copy(label = Reference.display(thisProjectRef.value)),
unmanagedBase := baseDirectory.value / "lib",
normalizedName := Project.normalizeModuleID(name.value),
isSnapshot <<= isSnapshot or version(_ endsWith "-SNAPSHOT"),
description <<= description or name,
organization <<= organization or normalizedName,
organizationName <<= organizationName or organization,
organizationHomepage <<= organizationHomepage or homepage,
projectInfo <<= (name, description, homepage, startYear, licenses, organizationName, organizationHomepage, scmInfo, developers) apply ModuleInfo,
overrideBuildResolvers <<= appConfiguration(isOverrideRepositories),
externalResolvers <<= (externalResolvers.task.?, resolvers, appResolvers, useJCenter) {
isSnapshot := (isSnapshot or version(_ endsWith "-SNAPSHOT")).value,
description := (description or name).value,
organization := (organization or normalizedName).value,
organizationName := (organizationName or organization).value,
organizationHomepage := (organizationHomepage or homepage).value,
projectInfo := ((name, description, homepage, startYear, licenses, organizationName, organizationHomepage, scmInfo, developers) apply ModuleInfo).value,
overrideBuildResolvers := appConfiguration(isOverrideRepositories).value,
externalResolvers := ((externalResolvers.?.value, resolvers.value, appResolvers.value, useJCenter.value) match {
case (Some(delegated), Seq(), _, _) => delegated
case (_, rs, Some(ars), uj) => task { ars ++ rs }
case (_, rs, _, uj) => task { Resolver.withDefaultResolvers(rs, uj, mavenCentral = true) }
},
case (_, rs, Some(ars), uj) => ars ++ rs
case (_, rs, _, uj) => Resolver.withDefaultResolvers(rs, uj, mavenCentral = true)
}),
appResolvers := {
val ac = appConfiguration.value
val uj = useJCenter.value
@ -1159,64 +1169,65 @@ object Classpaths {
Resolver.reorganizeAppResolvers(ars, uj, useMavenCentral)
}
},
bootResolvers <<= appConfiguration map bootRepositories,
fullResolvers <<= (projectResolver, externalResolvers, sbtPlugin, sbtResolver, bootResolvers, overrideBuildResolvers) map { (proj, rs, isPlugin, sbtr, boot, overrideFlag) =>
bootResolvers := (appConfiguration map bootRepositories).value,
fullResolvers := ((projectResolver, externalResolvers, sbtPlugin, sbtResolver, bootResolvers, overrideBuildResolvers) map { (proj, rs, isPlugin, sbtr, boot, overrideFlag) =>
boot match {
case Some(repos) if overrideFlag => proj +: repos
case _ =>
val base = if (isPlugin) sbtr +: sbtPluginReleases +: rs else rs
proj +: base
}
},
moduleName <<= normalizedName,
}).value,
moduleName := normalizedName.value,
ivyPaths := new IvyPaths(baseDirectory.value, bootIvyHome(appConfiguration.value)),
dependencyCacheDirectory := {
val st = state.value
BuildPaths.getDependencyDirectory(st, BuildPaths.getGlobalBase(st))
},
otherResolvers := Resolver.publishMavenLocal :: publishTo.value.toList,
projectResolver <<= projectResolverTask,
projectDependencies <<= projectDependenciesTask,
projectResolver := projectResolverTask.value,
projectDependencies := projectDependenciesTask.value,
// TODO - Is this the appropriate split? Ivy defines this simply as
// just project + library, while the JVM plugin will define it as
// having the additional sbtPlugin + autoScala magikz.
allDependencies := {
projectDependencies.value ++ libraryDependencies.value
},
ivyScala <<= ivyScala or (scalaHome, scalaVersion in update, scalaBinaryVersion in update, scalaOrganization, sbtPlugin) { (sh, fv, bv, so, plugin) =>
Some(new IvyScala(fv, bv, Nil, filterImplicit = false, checkExplicit = true, overrideScalaVersion = true, scalaOrganization = so))
},
artifactPath in makePom <<= artifactPathSetting(artifact in makePom),
ivyScala :=
(ivyScala or ((scalaHome, scalaVersion in update, scalaBinaryVersion in update, scalaOrganization, sbtPlugin) { (sh, fv, bv, so, plugin) =>
Option(new IvyScala(fv, bv, Nil, filterImplicit = false, checkExplicit = true, overrideScalaVersion = true, scalaOrganization = so))
})).value,
artifactPath in makePom := artifactPathSetting(artifact in makePom).value,
publishArtifact in makePom := publishMavenStyle.value && publishArtifact.value,
artifact in makePom := Artifact.pom(moduleName.value),
projectID <<= defaultProjectID,
projectID <<= pluginProjectID,
projectDescriptors <<= depMap,
projectID := defaultProjectID.value,
projectID := pluginProjectID.value,
projectDescriptors := depMap.value,
updateConfiguration := new UpdateConfiguration(retrieveConfiguration.value, false, ivyLoggingLevel.value),
updateOptions := (updateOptions in Global).value,
retrieveConfiguration := { if (retrieveManaged.value) Some(new RetrieveConfiguration(managedDirectory.value, retrievePattern.value, retrieveManagedSync.value, configurationsToRetrieve.value)) else None },
ivyConfiguration <<= mkIvyConfiguration,
ivyConfiguration := mkIvyConfiguration.value,
ivyConfigurations := {
val confs = thisProject.value.configurations
(confs ++ confs.map(internalConfigurationMap.value) ++ (if (autoCompilerPlugins.value) CompilerPlugin :: Nil else Nil)).distinct
},
ivyConfigurations ++= Configurations.auxiliary,
ivyConfigurations ++= { if (managedScalaInstance.value && scalaHome.value.isEmpty) Configurations.ScalaTool :: Nil else Nil },
moduleSettings <<= moduleSettings0,
moduleSettings := moduleSettings0.value,
makePomConfiguration := new MakePomConfiguration(artifactPath in makePom value, projectInfo.value, None, pomExtra.value, pomPostProcess.value, pomIncludeRepository.value, pomAllRepositories.value),
deliverLocalConfiguration := deliverConfig(crossTarget.value, status = if (isSnapshot.value) "integration" else "release", logging = ivyLoggingLevel.value),
deliverConfiguration <<= deliverLocalConfiguration,
deliverConfiguration := deliverLocalConfiguration.value,
publishConfiguration := publishConfig(packagedArtifacts.in(publish).value, if (publishMavenStyle.value) None else Some(deliver.value), resolverName = getPublishTo(publishTo.value).name, checksums = checksums.in(publish).value, logging = ivyLoggingLevel.value, overwrite = isSnapshot.value),
publishLocalConfiguration := publishConfig(packagedArtifacts.in(publishLocal).value, Some(deliverLocal.value), checksums.in(publishLocal).value, logging = ivyLoggingLevel.value, overwrite = isSnapshot.value),
publishM2Configuration := publishConfig(packagedArtifacts.in(publishM2).value, None, resolverName = Resolver.publishMavenLocal.name, checksums = checksums.in(publishM2).value, logging = ivyLoggingLevel.value, overwrite = isSnapshot.value),
ivySbt <<= ivySbt0,
ivySbt := ivySbt0.value,
ivyModule := { val is = ivySbt.value; new is.Module(moduleSettings.value) },
transitiveUpdate <<= transitiveUpdateTask,
transitiveUpdate := transitiveUpdateTask.value,
updateCacheName := "update_cache" + (if (crossPaths.value) s"_${scalaBinaryVersion.value}" else ""),
evictionWarningOptions in update := EvictionWarningOptions.default,
dependencyPositions <<= dependencyPositionsTask,
dependencyPositions := dependencyPositionsTask.value,
unresolvedWarningConfiguration in update := UnresolvedWarningConfiguration(dependencyPositions.value),
update <<= updateTask tag (Tags.Update, Tags.Network),
update := (updateTask tag (Tags.Update, Tags.Network)).value,
update := {
val report = update.value
val log = streams.value.log
@ -1240,7 +1251,7 @@ object Classpaths {
val externalModules = update.value.allModules.filterNot(m => projectDeps contains key(m))
GetClassifiersModule(projectID.value, externalModules, ivyConfigurations.in(updateClassifiers).value, transitiveClassifiers.in(updateClassifiers).value)
},
updateClassifiers <<= Def.task {
updateClassifiers := (Def.task {
val s = streams.value
val is = ivySbt.value
val mod = (classifiersModule in updateClassifiers).value
@ -1256,7 +1267,7 @@ object Classpaths {
val artifacts = update.value.toSeq.toVector
IvyActions.updateClassifiers(is, GetClassifiersConfiguration(mod, excludes, c, ivyScala.value), uwConfig, LogicalClock(state.value.hashCode), Some(depDir), artifacts, s.log)
}
} tag (Tags.Update, Tags.Network)
} tag (Tags.Update, Tags.Network)).value
)
val jvmBaseSettings: Seq[Setting[_]] = Seq(
@ -1316,13 +1327,13 @@ object Classpaths {
},
ivyConfiguration := new InlineIvyConfiguration(ivyPaths.value, externalResolvers.value, Nil, Nil, offline.value, Option(lock(appConfiguration.value)),
checksums.value, Some(target.value / "resolution-cache"), UpdateOptions(), streams.value.log),
ivySbt <<= ivySbt0,
classifiersModule <<= (projectID, sbtDependency, transitiveClassifiers, loadedBuild, thisProjectRef) map { (pid, sbtDep, classifiers, lb, ref) =>
ivySbt := ivySbt0.value,
classifiersModule := ((projectID, sbtDependency, transitiveClassifiers, loadedBuild, thisProjectRef) map { (pid, sbtDep, classifiers, lb, ref) =>
val pluginClasspath = lb.units(ref.build).unit.plugins.fullClasspath
val pluginJars = pluginClasspath.filter(_.data.isFile) // exclude directories: an approximation to whether they've been published
val pluginIDs: Seq[ModuleID] = pluginJars.flatMap(_ get moduleID.key)
GetClassifiersModule(pid, sbtDep +: pluginIDs, Configurations.Default :: Nil, classifiers)
},
}).value,
// Redefine scalaVersion and scalaBinaryVersion specifically for the dependency graph used for updateSbtClassifiers task.
// to fix https://github.com/sbt/sbt/issues/2686
scalaVersion := appConfiguration.value.provider.scalaProvider.version,
@ -1331,7 +1342,7 @@ object Classpaths {
Some(new IvyScala(scalaVersion.value, scalaBinaryVersion.value, Nil, filterImplicit = false, checkExplicit = false,
overrideScalaVersion = true, scalaOrganization = scalaOrganization.value))
},
updateSbtClassifiers in TaskGlobal <<= Def.task {
updateSbtClassifiers in TaskGlobal := (Def.task {
val s = streams.value
val is = ivySbt.value
val mod = classifiersModule.value
@ -1344,7 +1355,7 @@ object Classpaths {
val noExplicitCheck = ivyScala.value
IvyActions.transitiveScratch(is, "sbt", GetClassifiersConfiguration(mod, excludes, c, noExplicitCheck), uwConfig, LogicalClock(state.value.hashCode), Some(depDir), s.log)
}
} tag (Tags.Update, Tags.Network)
} tag (Tags.Update, Tags.Network)).value
)) ++ Seq(bootIvyConfiguration := (ivyConfiguration in updateSbtClassifiers).value)
def deliverTask(config: TaskKey[DeliverConfiguration]): Initialize[Task[File]] =
@ -1796,7 +1807,7 @@ object Classpaths {
else
Nil
def addUnmanagedLibrary: Seq[Setting[_]] = Seq(
unmanagedJars in Compile <++= unmanagedScalaLibrary
unmanagedJars in Compile ++= unmanagedScalaLibrary.value
)
def unmanagedScalaLibrary: Initialize[Task[Seq[File]]] =
Def.taskDyn {
@ -1956,14 +1967,21 @@ trait BuildExtra extends BuildCommon with DefExtra {
* Typically, use the default value for this version instead of specifying it explicitly.
*/
def addSbtPlugin(dependency: ModuleID, sbtVersion: String): Setting[Seq[ModuleID]] =
libraryDependencies <+= (scalaBinaryVersion in update) { scalaV => sbtPluginExtra(dependency, sbtVersion, scalaV) }
libraryDependencies += {
val scalaV = (scalaBinaryVersion in update).value
sbtPluginExtra(dependency, sbtVersion, scalaV)
}
/**
* Adds `dependency` as an sbt plugin for the sbt and Scala versions configured by
* `sbtBinaryVersion` and `scalaBinaryVersion` scoped to `update`.
*/
def addSbtPlugin(dependency: ModuleID): Setting[Seq[ModuleID]] =
libraryDependencies <+= (sbtBinaryVersion in update, scalaBinaryVersion in update) { (sbtV, scalaV) => sbtPluginExtra(dependency, sbtV, scalaV) }
libraryDependencies += {
val sbtV = (sbtBinaryVersion in update).value
val scalaV = (scalaBinaryVersion in update).value
sbtPluginExtra(dependency, sbtV, scalaV)
}
/** Transforms `dependency` to be in the auto-compiler plugin configuration. */
def compilerPlugin(dependency: ModuleID): ModuleID =
@ -2000,14 +2018,14 @@ trait BuildExtra extends BuildCommon with DefExtra {
def externalIvySettingsURI(uri: Initialize[URI], addMultiResolver: Boolean = true): Setting[Task[IvyConfiguration]] =
{
val other = (baseDirectory, appConfiguration, projectResolver, updateOptions, streams).identityMap
ivyConfiguration <<= (uri zipWith other) {
ivyConfiguration := ((uri zipWith other) {
case (u, otherTask) =>
otherTask map {
case (base, app, pr, uo, s) =>
val extraResolvers = if (addMultiResolver) pr :: Nil else Nil
new ExternalIvyConfiguration(base, u, Option(lock(app)), extraResolvers, uo, s.log)
}
}
}).value
}
private[this] def inBase(name: String): Initialize[File] = Def.setting { baseDirectory.value / name }
@ -2028,22 +2046,22 @@ trait BuildExtra extends BuildCommon with DefExtra {
}
def fullRunInputTask(scoped: InputKey[Unit], config: Configuration, mainClass: String, baseArguments: String*): Setting[InputTask[Unit]] =
scoped <<= inputTask { result =>
scoped := (inputTask { result =>
(initScoped(scoped.scopedKey, runnerInit) zipWith (fullClasspath in config, streams, result).identityMap) { (rTask, t) =>
(t, rTask) map {
case ((cp, s, args), r) =>
toError(r.run(mainClass, data(cp), baseArguments ++ args, s.log))
}
}
}
}).evaluated
def fullRunTask(scoped: TaskKey[Unit], config: Configuration, mainClass: String, arguments: String*): Setting[Task[Unit]] =
scoped <<= (initScoped(scoped.scopedKey, runnerInit) zipWith (fullClasspath in config, streams).identityMap) {
scoped := ((initScoped(scoped.scopedKey, runnerInit) zipWith (fullClasspath in config, streams).identityMap) {
case (rTask, t) =>
(t, rTask) map {
case ((cp, s), r) =>
toError(r.run(mainClass, data(cp), arguments, s.log))
}
}
}).value
def initScoped[T](sk: ScopedKey[_], i: Initialize[T]): Initialize[T] = initScope(fillTaskAxis(sk.scope, sk.key), i)
def initScope[T](s: Scope, i: Initialize[T]): Initialize[T] = i mapReferenced Project.mapScope(Scope.replaceThis(s))
@ -2051,7 +2069,8 @@ trait BuildExtra extends BuildCommon with DefExtra {
* Disables post-compilation hook for determining tests for tab-completion (such as for 'test-only').
* This is useful for reducing test:compile time when not running test.
*/
def noTestCompletion(config: Configuration = Test): Setting[_] = inConfig(config)(Seq(definedTests <<= detectTests)).head
def noTestCompletion(config: Configuration = Test): Setting[_] =
inConfig(config)(Seq(definedTests := detectTests.value)).head
def filterKeys(ss: Seq[Setting[_]], transitive: Boolean = false)(f: ScopedKey[_] => Boolean): Seq[Setting[_]] =
ss filter (s => f(s.key) && (!transitive || s.dependencies.forall(f)))

View File

@ -433,10 +433,12 @@ object EvaluateTask {
// if the return type Seq[Setting[_]] is not explicitly given, scalac hangs
val injectStreams: ScopedKey[_] => Seq[Setting[_]] = scoped =>
if (scoped.key == streams.key)
Seq(streams in scoped.scope <<= streamsManager map { mgr =>
val stream = mgr(scoped)
stream.open()
stream
Seq(streams in scoped.scope := {
(streamsManager map { mgr =>
val stream = mgr(scoped)
stream.open()
stream
}).value
})
else
Nil

View File

@ -17,7 +17,10 @@ object GlobalPlugin {
Seq[Setting[_]](
projectDescriptors ~= { _ ++ gp.descriptors },
projectDependencies ++= gp.projectID +: gp.dependencies,
resolvers <<= resolvers { rs => (rs ++ gp.resolvers).distinct },
resolvers := {
val rs = resolvers.value
(rs ++ gp.resolvers).distinct
},
globalPluginUpdate := gp.updateReport,
// TODO: these shouldn't be required (but are): the project* settings above should take care of this
injectInternalClasspath(Runtime, gp.internalClasspath),
@ -73,7 +76,7 @@ object GlobalPlugin {
}
val globalPluginSettings = Project.inScope(Scope.GlobalScope in LocalRootProject)(Seq(
organization := SbtArtifacts.Organization,
onLoadMessage <<= Keys.baseDirectory("Loading global plugins from " + _),
onLoadMessage := Keys.baseDirectory("Loading global plugins from " + _).value,
name := "global-plugin",
sbtPlugin := true,
version := "0.0"

View File

@ -52,14 +52,14 @@ object DefaultOptions {
def pluginResolvers(plugin: Boolean, snapshot: Boolean): Seq[Resolver] = {
if (plugin && snapshot) Seq(Classpaths.typesafeSnapshots, Classpaths.sbtPluginSnapshots) else Nil
}
def addResolvers: Setting[_] = Keys.resolvers <++= Keys.isSnapshot apply resolvers
def addPluginResolvers: Setting[_] = Keys.resolvers <++= (Keys.sbtPlugin, Keys.isSnapshot) apply pluginResolvers
def addResolvers: Setting[_] = Keys.resolvers ++= { resolvers(Keys.isSnapshot.value) }
@deprecated("Use `credentials(State)` instead to make use of configuration path dynamically configured via `Keys.globalSettingsDirectory`; relying on ~/.ivy2 is not recommended anymore.", "0.12.0")
def credentials: Credentials = Credentials(userHome / ".ivy2" / ".credentials")
def credentials(state: State): Credentials = Credentials(getGlobalSettingsDirectory(state, getGlobalBase(state)) / ".credentials")
def addCredentials: Setting[_] = Keys.credentials <+= Keys.state map credentials
def addCredentials: Setting[_] = Keys.credentials += { credentials(Keys.state.value) }
def shellPrompt(version: String): State => String = s => "%s:%s:%s> ".format(s.configuration.provider.id.name, extract(s).currentProject.id, version)
def setupShellPrompt: Setting[_] = Keys.shellPrompt <<= Keys.version apply shellPrompt
def shellPrompt(version: String): State => String =
s => "%s:%s:%s> ".format(s.configuration.provider.id.name, extract(s).currentProject.id, version)
def setupShellPrompt: Setting[_] = Keys.shellPrompt := { shellPrompt(Keys.version.value) }
}

View File

@ -37,7 +37,7 @@ private[sbt] object SettingCompletions {
val globalSetting = resolve(Def.setting(global, setting.init, setting.pos))
globalSetting ++ allDefs.flatMap { d =>
if (d.key == akey)
Seq(SettingKey(akey) in d.scope <<= global)
Seq(SettingKey(akey) in d.scope := { global.value })
else
Nil
}

View File

@ -11,7 +11,5 @@ k3 := {
k4 := { }; k5 := ()
k1 <<= k1 map {_ => sys.error("k1")}
k4 := { val x = k4.value; () }

View File

@ -10,6 +10,3 @@ k3 := {
}
k4 := (); k5 := ()
k1 <<= k1 map {_ => sys.error("k1")}

View File

@ -3,7 +3,7 @@
$ absent ran
# single project, 'mark' defined
> set Mark <<= mark
> set Mark := mark.value
> mark
$ exists ran
$ delete ran
@ -26,14 +26,14 @@ $ mkdir sub sub/sub
> reload
# define in root project only
> set Mark <<= mark
> set Mark := mark.value
> mark
$ exists ran
$ absent sub/ran
$ delete ran
# define in sub project, but shouldn't run without aggregation
> set Mark in sub <<= mark(sub)
> set Mark in sub := mark(sub).value
> mark
$ exists ran
$ absent sub/ran
@ -55,8 +55,8 @@ $ touch aggregate
> reload
# add tasks to each subproject
> set Mark in sub <<= mark(sub)
> set Mark in sub2 <<= mark(sub2)
> set Mark in sub := mark(sub).value
> set Mark in sub2 := mark(sub2).value
# check that aggregation works when root project has no task
> mark
@ -71,7 +71,7 @@ $ absent ran
$ delete sub/ran sub/sub/ran
# add task to root project
> set Mark <<= mark
> set Mark := mark.value
# disable aggregation for sub/mark so that sub2/mark doesn't run
> set aggregate in (sub,Mark) := false

View File

@ -1,5 +1,5 @@
-> compile
> 'set sources in (Compile, compile) <<= sources in (Compile, compile) map { _.filterNot(_.getName contains "C") }'
> 'set sources in (Compile, compile) := { val src = (sources in (Compile, compile)).value; src.filterNot(_.getName contains "C") }'
> compile

View File

@ -2,17 +2,19 @@ scalaVersion in ThisBuild := "2.7.7"
scalaVersion := "2.9.1"
scalaVersion in update <<= scalaVersion {
case "2.9.1" => "2.9.0-1"
case "2.8.2" => "2.8.1"
case x => x
scalaVersion in update := {
scalaVersion.value match {
case "2.9.1" => "2.9.0-1"
case "2.8.2" => "2.8.1"
case x => x
}
}
InputKey[Unit]("check") <<= inputTask { argsT =>
InputKey[Unit]("check") := (inputTask { argsT =>
(argsT, scalaVersion in ThisBuild, scalaVersion, scalaVersion in update) map { (args, svTB, svP, svU) =>
def check(label: String, i: Int, actual: String) = assert(args(i) == actual, "Expected " + label + "='" + args(i) + "' got '" + actual + "'")
check("scalaVersion in ThisBuild", 0, svTB)
check("scalaVersion", 1, svP)
check("scalaVersion in update", 2, svU)
}
}
}).evaluated

View File

@ -0,0 +1,25 @@
// tests that errors are properly propagated for dependsOn, map, and flatMap
lazy val root = (project in file(".")).
settings(
a := (baseDirectory map (b => if ((b / "succeed").exists) () else sys.error("fail"))).value,
b := (a.task(at => nop dependsOn(at))).value,
c := (a map { _ => () }).value,
d := (a flatMap { _ => task { () } }).value
)
lazy val a = taskKey[Unit]("")
lazy val b = taskKey[Unit]("")
lazy val c = taskKey[Unit]("")
lazy val d = taskKey[Unit]("")
lazy val input = (project in file("input")).
settings(
f := (inputTask { _ map { args => if (args(0) == "succeed") () else sys.error("fail") } }).evaluated,
j := sys.error("j"),
g := (f dependsOn(j)).evaluated,
h := (f map { _ => IO.touch(file("h")) }).evaluated
)
lazy val f = inputKey[Unit]("")
lazy val g = inputKey[Unit]("")
lazy val h = inputKey[Unit]("")
lazy val j = taskKey[Unit]("")

View File

@ -1,28 +0,0 @@
import sbt._
import Keys._
// tests that errors are properly propagated for dependsOn, map, and flatMap
object B extends Build
{
lazy val root = Project("root", file(".")) settings(
a <<= baseDirectory map (b => if( (b / "succeed").exists) () else sys.error("fail")),
b <<= a.task(at => nop dependsOn(at) ),
c <<= a map { _ => () },
d <<= a flatMap { _ => task { () } }
)
lazy val a = TaskKey[Unit]("a")
lazy val b = TaskKey[Unit]("b")
lazy val c = TaskKey[Unit]("c")
lazy val d = TaskKey[Unit]("d")
lazy val input = Project("input", file("input")) settings(
f <<= inputTask { _ map { args => if(args(0) == "succeed") () else sys.error("fail") } },
j := sys.error("j"),
g <<= f dependsOn(j),
h <<= f map { _ => IO.touch(file("h")) }
)
lazy val f = InputKey[Unit]("f")
lazy val g = InputKey[Unit]("g")
lazy val h = InputKey[Unit]("h")
lazy val j = TaskKey[Unit]("j")
}

View File

@ -4,7 +4,7 @@
-> doc
> 'set sources in (Compile, doc) <<= sources in Compile map { _.filterNot(_.getName contains "B") }'
> 'set sources in (Compile, doc) := { val src = (sources in Compile).value; src.filterNot(_.getName contains "B") }'
# hybrid project, only scaladoc run
> doc
@ -12,7 +12,7 @@ $ exists "target/api/index.js"
$ absent "target/api/scala"
$ absent "target/api/java"
> 'set sources in (Compile, doc) <<= sources in (Compile, doc) map { _.filterNot(_.getName endsWith ".java") }'
> 'set sources in (Compile, doc) := { val src = (sources in (Compile, doc)).value; src.filterNot(_.getName endsWith ".java") }'
# compile task is superfluous. Since doc task preceded by compile task has been problematic due to scala
# compiler's way of handling empty classpath. We have it here to test that our workaround works.
@ -24,7 +24,7 @@ $ absent "target/api/package-list"
$ absent "target/api/scala"
$ absent "target/api/java"
> 'set sources in (Compile, doc) <<= sources in Compile map { _.filter(_.getName endsWith ".java") }'
> 'set sources in (Compile, doc) := { val src = (sources in Compile).value; src.filter(_.getName endsWith ".java") }'
> ; clean ; doc

View File

@ -0,0 +1,47 @@
import complete.Parser
import complete.DefaultParsers._
import sbinary.DefaultProtocol._
import Def.Initialize
val keep = taskKey[Int]("")
val persist = taskKey[Int]("")
val checkKeep = inputKey[Unit]("")
val checkPersist = inputKey[Unit]("")
val updateDemo = taskKey[Int]("")
val check = inputKey[Unit]("")
val sample = AttributeKey[Int]("demo-key")
def updateDemoInit = state map { s => (s get sample getOrElse 9) + 1 }
lazy val root = (project in file(".")).
settings(
updateDemo := (updateDemoInit updateState demoState).value,
check := checkInit.evaluated,
inMemorySetting,
persistedSetting,
inMemoryCheck,
persistedCheck
)
def demoState(s: State, i: Int): State = s put (sample, i + 1)
def checkInit: Initialize[InputTask[Unit]] = InputTask( (_: State) => token(Space ~> IntBasic) ~ token(Space ~> IntBasic).?) { key =>
(key, updateDemo, state) map { case ((curExpected, prevExpected), value, s) =>
val prev = s get sample
assert(value == curExpected, "Expected current value to be " + curExpected + ", got " + value)
assert(prev == prevExpected, "Expected previous value to be " + prevExpected + ", got " + prev)
}
}
def inMemorySetting = keep := (getPrevious(keep) map { case None => 3; case Some(x) => x + 1} keepAs(keep)).value
def persistedSetting = persist := (loadPrevious(persist) map { case None => 17; case Some(x) => x + 1} storeAs(persist)).value
def inMemoryCheck = checkKeep := (inputCheck( (ctx, s) => Space ~> str( getFromContext( keep, ctx, s)) )).evaluated
def persistedCheck = checkPersist := (inputCheck( (ctx, s) => Space ~> str(loadFromContext(persist, ctx, s)) )).evaluated
def inputCheck[T](f: (ScopedKey[_], State) => Parser[T]): Initialize[InputTask[Unit]] =
InputTask( resolvedScoped(ctx => (s: State) => f(ctx, s)) )( dummyTask )
def dummyTask = (key: Any) => maxErrors map { _ => () }
def str(o: Option[Int]) = o match { case None => "blue"; case Some(i) => i.toString }

View File

@ -1,50 +0,0 @@
import sbt._
import Keys._
import complete.Parser
import complete.DefaultParsers._
import sbinary.DefaultProtocol._
import Project.Initialize
object MyBuild extends Build
{
val keep = TaskKey[Int]("keep")
val persisted = TaskKey[Int]("persist")
val checkKeep = InputKey[Unit]("check-keep")
val checkPersisted = InputKey[Unit]("check-persist")
val updateDemo = TaskKey[Int]("demo")
val check = InputKey[Unit]("check")
val sample = AttributeKey[Int]("demo-key")
def updateDemoInit = state map { s => (s get sample getOrElse 9) + 1 }
lazy val root = Project("root", file(".")) settings(
updateDemo <<= updateDemoInit updateState demoState,
check <<= checkInit,
inMemorySetting,
persistedSetting,
inMemoryCheck,
persistedCheck
)
def demoState(s: State, i: Int): State = s put (sample, i + 1)
def checkInit: Initialize[InputTask[Unit]] = InputTask( (_: State) => token(Space ~> IntBasic) ~ token(Space ~> IntBasic).?) { key =>
(key, updateDemo, state) map { case ((curExpected, prevExpected), value, s) =>
val prev = s get sample
assert(value == curExpected, "Expected current value to be " + curExpected + ", got " + value)
assert(prev == prevExpected, "Expected previous value to be " + prevExpected + ", got " + prev)
}
}
def inMemorySetting = keep <<= getPrevious(keep) map { case None => 3; case Some(x) => x + 1} keepAs(keep)
def persistedSetting = persisted <<= loadPrevious(persisted) map { case None => 17; case Some(x) => x + 1} storeAs(persisted)
def inMemoryCheck = checkKeep <<= inputCheck( (ctx, s) => Space ~> str(getFromContext(keep, ctx, s)) )
def persistedCheck = checkPersisted <<= inputCheck( (ctx, s) => Space ~> str(loadFromContext(persisted, ctx, s)) )
def inputCheck[T](f: (ScopedKey[_], State) => Parser[T]): Initialize[InputTask[Unit]] =
InputTask( resolvedScoped(ctx => (s: State) => f(ctx, s)) )( dummyTask )
def dummyTask = (key: Any) => maxErrors map { _ => () }
def str(o: Option[Int]) = o match { case None => "blue"; case Some(i) => i.toString }
}

View File

@ -5,35 +5,35 @@
> check 16 15
-> check-keep 3
> check-keep blue
-> checkKeep 3
> checkKeep blue
> keep
> check-keep 3
-> check-keep 4
> check-keep 3
> checkKeep 3
-> checkKeep 4
> checkKeep 3
> keep
-> check-keep 3
> check-keep 4
> check-keep 4
-> checkKeep 3
> checkKeep 4
> checkKeep 4
> reload
> check-keep blue
> checkKeep blue
> keep
> check-keep 3
> checkKeep 3
-> check-persist 17
> check-persist blue
-> checkPersist 17
> checkPersist blue
> persist
> check-persist 17
-> check-persist blue
> checkPersist 17
-> checkPersist blue
> persist
> check-persist 18
> checkPersist 18
> reload
> check-persist 18
> checkPersist 18
> persist
> check-persist 19
> checkPersist 19

View File

@ -0,0 +1,30 @@
lazy val akey = AttributeKey[Int]("TestKey")
lazy val testTask = taskKey[String]("")
lazy val check = inputKey[Unit]("")
lazy val root = (project in file(".")).
aggregate(a, b).
settings(
check := checkState(checkParser.parsed, state.value)
)
lazy val a = project.
settings(
testTask := sys.error("Failing")
)
lazy val b = project.
settings(
testTask := Def.task("").updateState(updater).value
)
def checkState(runs: Int, s: State): Unit = {
val stored = s.get(akey).getOrElse(0)
assert(stored == runs, "Expected " + runs + ", got " + stored)
}
def updater(s: State, a: AnyRef): State = s.update(akey)(_.getOrElse(0) + 1)
import complete.DefaultParsers._
lazy val checkParser = token(Space ~> IntBasic)

View File

@ -1,27 +0,0 @@
import sbt._
import Keys._
object TestBuild extends Build
{
lazy val akey = AttributeKey[Int]("TestKey")
lazy val t = TaskKey[String]("test-task")
lazy val check = InputKey[Unit]("check")
lazy val root = Project("root", file(".")).aggregate(a, b).settings(
check := checkState(checkParser.parsed, state.value)
)
lazy val a = Project("a", file("a")).settings(t := sys.error("Failing"))
lazy val b = Project("b", file("b")).settings(t <<= Def.task("").updateState(updater))
def checkState(runs: Int, s: State): Unit = {
val stored = s.get(akey).getOrElse(0)
assert(stored == runs, "Expected " + runs + ", got " + stored)
}
def updater(s: State, a: AnyRef): State = s.update(akey)(_.getOrElse(0) + 1)
import complete.DefaultParsers._
lazy val checkParser = token(Space ~> IntBasic)
}

View File

@ -1,9 +1,9 @@
> check 0
-> test-task
-> testTask
> check 1
-> test-task
-> testTask
> check 2
> b/test-task
> b/testTask
> check 3
-> a/testTask
> check 3
-> a/test-task
> check 3

View File

@ -41,14 +41,14 @@ def testInputTask[T](name: String, expected: String, task: InputKey[T], arg: Str
}
}
myInputTask <<= argFunction(_.toUpperCase(Locale.ENGLISH))
myInputTask := argFunction(_.toUpperCase(Locale.ENGLISH)).evaluated
testInputTask("testRunInputTaskRoot", "FOO", myInputTask, "foo")
myInputTask in Compile <<= argFunction(_.toLowerCase(Locale.ENGLISH))
myInputTask in Compile := argFunction(_.toLowerCase(Locale.ENGLISH)).evaluated
testInputTask("testRunInputTaskRootCompile", "foo", myInputTask in Compile, "FOO")
myInputTask in sub <<= argFunction(_.head.toString)
myInputTask in sub := argFunction(_.head.toString).evaluated
testInputTask("testRunInputTaskSub", "f", myInputTask in sub, "foo")
myInputTask in (sub, Compile) <<= argFunction(_.tail)
myInputTask in (sub, Compile) := argFunction(_.tail).evaluated
testInputTask("testRunInputTaskSubCompile", "oo", myInputTask in (sub, Compile), "foo")

View File

@ -1,8 +1,13 @@
import sbt.inc.Analysis
logLevel := Level.Debug
incOptions ~= { _.copy(apiDebug = true) }
incOptions ~= { _.withApiDebug(true) }
TaskKey[Unit]("show-apis") <<= (compile in Compile, scalaSource in Compile, javaSource in Compile) map { (a: sbt.inc.Analysis, scalaSrc: java.io.File, javaSrc: java.io.File) =>
TaskKey[Unit]("show-apis") := {
val a = (compile in Compile).value match { case a: Analysis => a }
val scalaSrc = (scalaSource in Compile).value
val javaSrc = (javaSource in Compile).value
val aApi = a.apis.internalAPI(scalaSrc / "A.scala").api
val jApi = a.apis.internalAPI(javaSrc / "test/J.java").api
import xsbt.api.DefaultShowAPI

View File

@ -1,4 +1,4 @@
# test case for http://github.com/sbt/sbt/issues/676
> compile
# fails with StackOverflowException
> show-apis
> showApis

View File

@ -1,10 +1,12 @@
import sbt.inc.Analysis
// checks number of compilation iterations performed since last `clean` run
InputKey[Unit]("check-number-of-compiler-iterations") <<= inputTask { (argTask: TaskKey[Seq[String]]) =>
(argTask, compile in Compile) map { (args: Seq[String], a: sbt.inc.Analysis) =>
InputKey[Unit]("check-number-of-compiler-iterations") := (inputTask { (argTask: TaskKey[Seq[String]]) =>
(argTask, compile in Compile) map { case (args: Seq[String], a: Analysis) =>
assert(args.size == 1)
val expectedIterationsNumber = args(0).toInt
val allCompilationsSize = a.compilations.allCompilations.size
assert(allCompilationsSize == expectedIterationsNumber,
"allCompilationsSize == %d (expected %d)".format(allCompilationsSize, expectedIterationsNumber))
}
}
}).evaluated

View File

@ -9,4 +9,4 @@ $ copy-file changes/Foo1.scala src/main/scala/Foo.scala
# second iteration
> compile
# check if there are only two compile iterations being performed
> check-number-of-compiler-iterations 2
> checkNumberOfCompilerIterations 2

View File

@ -1,6 +1,10 @@
TaskKey[Unit]("verify-binary-deps") <<= (compile in Compile, classDirectory in Compile, baseDirectory) map {
(a: sbt.inc.Analysis, classDir: java.io.File, base: java.io.File) =>
val nestedPkgClass = classDir / "test/nested.class"
val fooSrc = base / "src/main/scala/test/nested/Foo.scala"
assert(!a.relations.binaryDeps(fooSrc).contains(nestedPkgClass), a.relations.toString)
import sbt.inc.Analysis
TaskKey[Unit]("verify-binary-deps") := {
val a = (compile in Compile).value match { case a: Analysis => a }
val classDir = (classDirectory in Compile).value
val base = baseDirectory.value
val nestedPkgClass = classDir / "test/nested.class"
val fooSrc = base / "src/main/scala/test/nested/Foo.scala"
assert(!a.relations.binaryDeps(fooSrc).contains(nestedPkgClass), a.relations.toString)
}

View File

@ -4,4 +4,4 @@
> compile
# verifies that there's no dependency on a class file corresponding
# to a package
> verify-binary-deps
> verifyBinaryDeps

View File

@ -1,10 +1,12 @@
import sbt.inc.Analysis
logLevel := Level.Debug
// dumps analysis into target/analysis-dump.txt file
InputKey[Unit]("check-number-of-compiler-iterations") <<= inputTask { (argTask: TaskKey[Seq[String]]) =>
(argTask, compile in Compile) map { (args: Seq[String], a: sbt.inc.Analysis) =>
InputKey[Unit]("check-number-of-compiler-iterations") := (inputTask { (argTask: TaskKey[Seq[String]]) =>
(argTask, compile in Compile) map { case (args: Seq[String], a: Analysis) =>
assert(args.size == 1)
val expectedIterationsNumber = args(0).toInt
assert(a.compilations.allCompilations.size == expectedIterationsNumber, "a.compilations.allCompilations.size = %d (expected %d)".format(a.compilations.allCompilations.size, expectedIterationsNumber))
}
}
}).evaluated

View File

@ -9,4 +9,4 @@ $ copy-file changes/B1.scala src/main/scala/B.scala
# second iteration
> compile
# check if there are only two compile iterations being performed
> check-number-of-compiler-iterations 2
> checkNumberOfCompilerIterations 2

View File

@ -1,7 +1,9 @@
InputKey[Unit]("check-number-of-compiler-iterations") <<= inputTask { (argTask: TaskKey[Seq[String]]) =>
(argTask, compile in Compile) map { (args: Seq[String], a: sbt.inc.Analysis) =>
import sbt.inc.Analysis
InputKey[Unit]("check-number-of-compiler-iterations") := (inputTask { (argTask: TaskKey[Seq[String]]) =>
(argTask, compile in Compile) map { case (args: Seq[String], a: Analysis) =>
assert(args.size == 1)
val expectedIterationsNumber = args(0).toInt
assert(a.compilations.allCompilations.size == expectedIterationsNumber, "a.compilations.allCompilations.size = %d (expected %d)".format(a.compilations.allCompilations.size, expectedIterationsNumber))
}
}
}).evaluated

View File

@ -11,4 +11,4 @@ $ copy-file changes/Impl1.scala src/main/scala/Impl.scala
# second iteration
> compile
# check if there are only two compile iterations performed
> check-number-of-compiler-iterations 2
> checkNumberOfCompilerIterations 2

View File

@ -4,21 +4,21 @@
ivyConfigurations += config("macro").hide.extend(Compile)
// add the compiler as a dependency for src/macro/
libraryDependencies <+=
scalaVersion("org.scala-lang" % "scala-compiler" % _ % "macro")
libraryDependencies +=
scalaVersion("org.scala-lang" % "scala-compiler" % _ % "macro").value
// adds standard compile, console, package tasks for src/macro/
inConfig(config("macro"))(Defaults.configSettings)
// puts the compiled macro on the classpath for the main sources
unmanagedClasspath in Compile <++=
fullClasspath in config("macro")
unmanagedClasspath in Compile ++=
(fullClasspath in config("macro")).value
// includes sources in src/macro/ in the main source package
mappings in (Compile, packageSrc) <++=
mappings in (config("macro"), packageSrc)
mappings in (Compile, packageSrc) ++=
(mappings in (config("macro"), packageSrc)).value
// Includes classes compiled from src/macro/ in the main binary
// This can be omitted if the classes in src/macro/ aren't used at runtime
mappings in (Compile, packageBin) <++=
mappings in (config("macro"), packageBin)
mappings in (Compile, packageBin) ++=
(mappings in (config("macro"), packageBin)).value

View File

@ -3,4 +3,4 @@ libraryDependencies ++= Seq(
"junit" % "junit" % "4.8" % "test"
)
libraryDependencies <+= scalaVersion("org.scala-lang" % "scala-compiler" % _ )
libraryDependencies += scalaVersion("org.scala-lang" % "scala-compiler" % _ ).value

View File

@ -0,0 +1,42 @@
import sbt.classpath.ClasspathUtilities
lazy val checkFull = taskKey[Unit]("")
lazy val check = taskKey[Unit]("")
lazy val root = (project in file(".")).
settings(
ivyPaths := ((baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache")))).value,
publishTo := Some(Resolver.file("Test Publish Repo", file("test-repo"))),
resolvers += (baseDirectory { base => "Test Repo" at (base / "test-repo").toURI.toString }).value,
moduleName := artifactID,
projectID := (baseDirectory { base => (if(base / "retrieve" exists) retrieveID else publishedID) }).value,
artifact in (Compile, packageBin) := mainArtifact,
libraryDependencies := ((libraryDependencies, baseDirectory) { (deps, base) =>
deps ++ (if(base / "retrieve" exists) publishedID :: Nil else Nil) }).value,
// needed to add a jar with a different type to the managed classpath
unmanagedClasspath in Compile += scalaInstance.map(_.libraryJar).value,
classpathTypes := Set(tpe),
check := checkTask(dependencyClasspath).value,
checkFull := checkTask(fullClasspath).value
)
// define strings for defining the artifact
def artifactID = "test"
def ext = "test2"
def classifier = "test3"
def tpe = "test1"
def vers = "1.1"
def org = "test"
def mainArtifact = Artifact(artifactID, tpe, ext, classifier)
// define the IDs to use for publishing and retrieving
def publishedID = org % artifactID % vers artifacts(mainArtifact)
def retrieveID = org % "test-retrieve" % "2.0"
// check that the test class is on the compile classpath, either because it was compiled or because it was properly retrieved
def checkTask(classpath: TaskKey[Classpath]) = (classpath in Compile, scalaInstance) map { (cp, si) =>
val loader = ClasspathUtilities.toLoader(cp.files, si.loader)
try { Class.forName("test.Test", false, loader); () }
catch { case _: ClassNotFoundException | _: NoClassDefFoundError => sys.error("Dependency not retrieved properly") }
}

View File

@ -1,44 +0,0 @@
import sbt._
import Keys._
object ArtifactTest extends Build
{
lazy val root = Project("root", file(".")) settings(
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))),
publishTo := Some(Resolver.file("Test Publish Repo", file("test-repo"))),
resolvers <+= baseDirectory { base => "Test Repo" at (base / "test-repo").toURI.toString },
moduleName := artifactID,
projectID <<= baseDirectory { base => (if(base / "retrieve" exists) retrieveID else publishedID) },
artifact in (Compile, packageBin) := mainArtifact,
libraryDependencies <<= (libraryDependencies, baseDirectory) { (deps, base) => deps ++ (if(base / "retrieve" exists) publishedID :: Nil else Nil) },
// needed to add a jar with a different type to the managed classpath
unmanagedClasspath in Compile <+= scalaInstance.map(_.libraryJar),
classpathTypes := Set(tpe),
check <<= checkTask(dependencyClasspath),
checkFull <<= checkTask(fullClasspath)
)
lazy val checkFull = TaskKey[Unit]("check-full")
lazy val check = TaskKey[Unit]("check")
// define strings for defining the artifact
def artifactID = "test"
def ext = "test2"
def classifier = "test3"
def tpe = "test1"
def vers = "1.1"
def org = "test"
def mainArtifact = Artifact(artifactID, tpe, ext, classifier)
// define the IDs to use for publishing and retrieving
def publishedID = org % artifactID % vers artifacts(mainArtifact)
def retrieveID = org % "test-retrieve" % "2.0"
// check that the test class is on the compile classpath, either because it was compiled or because it was properly retrieved
def checkTask(classpath: TaskKey[Classpath]) = (classpath in Compile, scalaInstance) map { (cp, si) =>
val loader = sbt.classpath.ClasspathUtilities.toLoader(cp.files, si.loader)
try { Class.forName("test.Test", false, loader); () }
catch { case _: ClassNotFoundException | _: NoClassDefFoundError => sys.error("Dependency not retrieved properly") }
}
}

View File

@ -2,7 +2,7 @@
-> check
# verify that check-full succeeds
> check-full
> checkFull
# publish test jar to test repository
> publish
@ -16,4 +16,4 @@ $ touch retrieve
> reload
# verify that artifact with extension, type, and classifier can be retreieved
> check
> check

View File

@ -1 +1 @@
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / ".ivy2")))
ivyPaths := { new IvyPaths(baseDirectory.value, Some(target.value / ".ivy2")) }

View File

@ -1,5 +1,5 @@
publishTo <<= baseDirectory(base => Some(Resolver.file("filesys-publish", base / "repo")) )
publishTo := baseDirectory(base => Some(Resolver.file("filesys-publish", base / "repo")) ).value
resolvers <+= baseDirectory(base => "filesys" at (base / "repo").toURI.toString)
resolvers += baseDirectory(base => "filesys" at (base / "repo").toURI.toString).value

View File

@ -1,3 +1,3 @@
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache")))
ivyPaths := (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))).value
libraryDependencies += "org.testng" % "testng" % "5.7" classifier "jdk15"

View File

@ -1,7 +1,7 @@
// the default, but make it explicit
publishMavenStyle := true
publishTo <<= baseDirectory(bd => Some( MavenRepository("test-repo", (bd / "repo").toURI.toASCIIString )) )
publishTo := baseDirectory(bd => Some( MavenRepository("test-repo", (bd / "repo").toURI.toASCIIString )) ).value
name := "test"

View File

@ -1,8 +1,8 @@
publishMavenStyle := false
publishTo <<= baseDirectory { base =>
publishTo := (baseDirectory { base =>
Some( Resolver.file("test-repo", base / "repo")(Patterns(false, Resolver.mavenStyleBasePattern)) )
}
}).value
name := "test-ivy"

View File

@ -1,8 +1,8 @@
publishMavenStyle := false
resolvers <<= baseDirectory { base =>
resolvers := (baseDirectory { base =>
Resolver.file("test-repo", base / "repo")(Patterns(false, Resolver.mavenStyleBasePattern)) :: Nil
}
}).value
libraryDependencies ++= Seq(
"org.example" %% "test-ivy" % "1.0",

View File

@ -1,6 +1,6 @@
resolvers <<= baseDirectory { base =>
resolvers := (baseDirectory { base =>
Resolver.file("test-repo", base / "repo") :: Nil
}
}).value
libraryDependencies ++= Seq(
"org.example" %% "test" % "1.0",

View File

@ -1,4 +1,5 @@
TaskKey[Unit]("check") <<= update map { report =>
val compatJetty = report.allModules.filter(mod => mod.name == "atmosphere-compat-jetty")
assert(compatJetty.isEmpty, "Expected dependencies to be excluded: " + compatJetty.mkString(", "))
TaskKey[Unit]("check") := {
val report = update.value
val compatJetty = report.allModules.filter(mod => mod.name == "atmosphere-compat-jetty")
assert(compatJetty.isEmpty, "Expected dependencies to be excluded: " + compatJetty.mkString(", "))
}

View File

@ -0,0 +1,24 @@
import sbt.classpath.ClasspathUtilities
lazy val scalaOverride = taskKey[Unit]("Check that the proper version of Scala is on the classpath.")
lazy val root = (project in file(".")).
settings(
libraryDependencies ++= baseDirectory(dependencies).value,
scalaVersion := "2.9.2",
ivyScala := { ivyScala.value map {_.copy(overrideScalaVersion = sbtPlugin.value)} },
autoScalaLibrary := baseDirectory(base => !(base / "noscala").exists ).value,
scalaOverride := check("scala.App").value
)
def check(className: String): Def.Initialize[Task[Unit]] = fullClasspath in Compile map { cp =>
val existing = cp.files.filter(_.getName contains "scala-library")
println("Full classpath: " + cp.mkString("\n\t", "\n\t", ""))
println("scala-library.jar: " + existing.mkString("\n\t", "\n\t", ""))
val loader = ClasspathUtilities.toLoader(existing)
Class.forName(className, false, loader)
}
def dependencies(base: File) =
if( ( base / "stm").exists ) ("org.scala-tools" % "scala-stm_2.8.2" % "0.6") :: Nil
else Nil

View File

@ -1,28 +0,0 @@
import sbt._
import Keys._
object ExcludeScala extends Build
{
lazy val root = Project("root", file(".")) settings(
libraryDependencies <++= baseDirectory(dependencies),
scalaVersion := "2.9.2",
ivyScala := { ivyScala.value map {_.copy(overrideScalaVersion = sbtPlugin.value)} },
autoScalaLibrary <<= baseDirectory(base => !(base / "noscala").exists ),
scalaOverride <<= check("scala.App")
)
def check(className: String): Def.Initialize[Task[Unit]] = fullClasspath in Compile map { cp =>
val existing = cp.files.filter(_.getName contains "scala-library")
println("Full classpath: " + cp.mkString("\n\t", "\n\t", ""))
println("scala-library.jar: " + existing.mkString("\n\t", "\n\t", ""))
val loader = classpath.ClasspathUtilities.toLoader(existing)
Class.forName(className, false, loader)
}
lazy val scalaOverride = taskKey[Unit]("Check that the proper version of Scala is on the classpath.")
def dependencies(base: File) =
if( ( base / "stm").exists )
("org.scala-tools" % "scala-stm_2.8.2" % "0.6") :: Nil
else
Nil
}

View File

@ -0,0 +1,24 @@
lazy val root = (project in file(".")).
settings(
ivyPaths := (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))).value,
libraryDependencies += baseDirectory(transitive("javax.mail" % "mail" % "1.4.1")).value,
TaskKey[Unit]("checkTransitive") := check(true).value,
TaskKey[Unit]("checkIntransitive") := check(false).value
)
def transitive(dep: ModuleID)(base: File) =
if((base / "transitive").exists) dep else dep.intransitive()
def check(transitive: Boolean) =
(dependencyClasspath in Compile) map { downloaded =>
val jars = downloaded.size
if(transitive) {
if (jars <= 2)
sys.error(s"Transitive dependencies not downloaded, found:\n * ${downloaded.mkString("\n * ")}")
else ()
} else {
if (jars > 2)
sys.error(s"Transitive dependencies not downloaded, found:\n * ${downloaded.mkString("\n * ")}")
else ()
}
}

View File

@ -1,29 +0,0 @@
import sbt._
import Keys._
object TestProject extends Build
{
lazy val root = Project("root", file(".")) settings(
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))),
libraryDependencies <+= baseDirectory(transitive("javax.mail" % "mail" % "1.4.1")),
TaskKey[Unit]("check-transitive") <<= check(true),
TaskKey[Unit]("check-intransitive") <<= check(false)
)
def transitive(dep: ModuleID)(base: File) =
if((base / "transitive").exists) dep else dep.intransitive()
private def check(transitive: Boolean) =
(dependencyClasspath in Compile) map { downloaded =>
val jars = downloaded.size
if(transitive) {
if (jars <= 2)
sys.error(s"Transitive dependencies not downloaded, found:\n * ${downloaded.mkString("\n * ")}")
else ()
} else {
if (jars > 2)
sys.error(s"Transitive dependencies not downloaded, found:\n * ${downloaded.mkString("\n * ")}")
else ()
}
}
}

View File

@ -8,8 +8,8 @@ $ touch transitive
> reload
#$ pause
> check-transitive
-> check-intransitive
> checkTransitive
-> checkIntransitive
# load the project definition with transitive dependencies disabled
@ -19,5 +19,5 @@ $ delete ivy-cache
$ delete transitive
> reload
-> check-transitive
> check-intransitive
-> checkTransitive
> checkIntransitive

View File

@ -1,12 +1,12 @@
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache")))
ivyPaths := (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))).value
publishMavenStyle := false
publishTo <<= baseDirectory { base =>
publishTo := (baseDirectory { base =>
Some(Resolver.file("test-repo", base / "repo" / "test")(Resolver.defaultIvyPatterns))
}
}).value
projectID <<= projectID { _.extra("e:color" -> "red") }
projectID := (projectID { _.extra("e:color" -> "red") }).value
organization := "org.scala-sbt"

View File

@ -1,16 +1,16 @@
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache")) )
ivyPaths := (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache")) ).value
publishMavenStyle := false
resolvers <<= baseDirectory( base =>
resolvers := baseDirectory( base =>
Resolver.file("test-repo", base / "repo" / "test")(Resolver.defaultIvyPatterns) :: Nil
)
).value
libraryDependencies <<= baseDirectory { base =>
libraryDependencies := (baseDirectory { base =>
val color = IO.read(base / "color")
val dep = "org.scala-sbt" %% "define-color" % "1.0" extra("e:color" -> color)
dep :: Nil
}
}).value
organization := "org.example"

View File

@ -2,7 +2,7 @@ libraryDependencies += "log4j" % "log4j" % "1.2.16" % "compile"
autoScalaLibrary := false
TaskKey[Unit]("check-last-update-time") <<= streams map { (s) =>
TaskKey[Unit]("check-last-update-time") := (streams map { (s) =>
val fullUpdateOutput = s.cacheDirectory / "out"
val timeDiff = System.currentTimeMillis()-fullUpdateOutput.lastModified()
val exists = fullUpdateOutput.exists()
@ -10,4 +10,4 @@ TaskKey[Unit]("check-last-update-time") <<= streams map { (s) =>
if (exists && timeDiff > 5000) {
sys.error("Full update not perfomed")
}
}
}).value

View File

@ -0,0 +1,21 @@
lazy val root = (project in file(".")).
settings(
ivyPaths := (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))).value,
libraryDependencies ++= baseDirectory (libraryDeps).value,
TaskKey[Unit]("checkForced") := check("1.2.14").value,
TaskKey[Unit]("checkDepend") := check("1.2.13").value
)
def libraryDeps(base: File) = {
val slf4j = Seq("org.slf4j" % "slf4j-log4j12" % "1.1.0") // Uses log4j 1.2.13
if ((base / "force").exists) slf4j :+ ("log4j" % "log4j" % "1.2.14" force()) else slf4j
}
def check(ver: String) =
(dependencyClasspath in Compile) map { jars =>
val log4j = jars map (_.data) collect {
case f if f.getName contains "log4j-" => f.getName
}
if (log4j.size != 1 || !log4j.head.contains(ver))
error("Did not download the correct jar.")
}

View File

@ -1,26 +0,0 @@
import sbt._
import Keys._
object TestProject extends Build
{
lazy val root = Project("root", file(".")) settings(
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))),
libraryDependencies <++= baseDirectory (libraryDeps),
TaskKey[Unit]("check-forced") <<= check("1.2.14"),
TaskKey[Unit]("check-depend") <<= check("1.2.13")
)
def libraryDeps(base: File) = {
val slf4j = Seq("org.slf4j" % "slf4j-log4j12" % "1.1.0") // Uses log4j 1.2.13
if ((base / "force").exists) slf4j :+ ("log4j" % "log4j" % "1.2.14" force()) else slf4j
}
def check(ver: String) =
(dependencyClasspath in Compile) map { jars =>
val log4j = jars map (_.data) collect {
case f if f.getName contains "log4j-" => f.getName
}
if (log4j.size != 1 || !log4j.head.contains(ver))
error("Did not download the correct jar.")
}
}

View File

@ -2,11 +2,11 @@ $ touch force
> reload
> check-forced
-> check-depend
> checkForced
-> checkDepend
$ delete force
> reload
-> check-forced
> check-depend
-> checkForced
> checkDepend

View File

@ -0,0 +1,40 @@
import scala.xml._
lazy val root = (project in file(".")).
settings(
ivyPaths := (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))).value,
ivyXML := ((customInfo, organization, moduleName, version) apply inlineXML).value,
scalaVersion := "2.9.1",
projectID ~= (_ cross false),
customInfo := (baseDirectory{_ / "info" exists }).value,
TaskKey[Unit]("check-download") := checkDownload.value,
delivered := (deliverLocal map XML.loadFile).value,
TaskKey[Unit]("check-info") := checkInfo.value
)
lazy val delivered = taskKey[NodeSeq]("")
lazy val customInfo = settingKey[Boolean]("")
def inlineXML(addInfo: Boolean, organization: String, moduleID: String, version: String): NodeSeq =
if(addInfo)
(<info organisation={organization} module={moduleID} revision={version}>
<license name="Two-clause BSD-style" url="http://github.com/szeiger/scala-query/blob/master/LICENSE.txt" />
<description homepage="http://github.com/szeiger/scala-query/">
ScalaQuery is a type-safe database query API for Scala.
</description>
</info>
<dependency org="org.scala-tools.testing" name="scalacheck_2.9.1" rev="1.9"/>)
else
<dependency org="org.scala-tools.testing" name="scalacheck_2.9.1" rev="1.9"/>
def checkDownload = (dependencyClasspath in Compile) map { cp => if(cp.isEmpty) sys.error("Dependency not downloaded"); () }
def checkInfo = (customInfo, delivered) map { (addInfo, d) =>
if((d \ "info").isEmpty)
sys.error("No info tag generated")
else if(addInfo) {
if( !deliveredWithCustom(d) ) sys.error("Expected 'license' and 'description' tags in info tag, got: \n" + (d \ "info")) else ()
} else
if( deliveredWithCustom(d) ) sys.error("Expected empty 'info' tag, got: \n" + (d \ "info")) else ()
}
def deliveredWithCustom(d: NodeSeq) = (d \ "info" \ "license").nonEmpty && (d \ "info" \ "description").nonEmpty

View File

@ -1,42 +0,0 @@
import sbt._
import Keys._
import scala.xml._
object InfoTest extends Build
{
lazy val root = Project("root", file(".")) settings(
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))),
ivyXML <<= (customInfo, organization, moduleName, version) apply inlineXML,
scalaVersion := "2.9.1",
projectID ~= (_ cross false),
customInfo <<= baseDirectory{_ / "info" exists },
TaskKey[Unit]("check-download") <<= checkDownload,
delivered <<= deliverLocal map XML.loadFile,
TaskKey[Unit]("check-info") <<= checkInfo
)
lazy val delivered = TaskKey[NodeSeq]("delivered")
lazy val customInfo = SettingKey[Boolean]("custom-info")
def inlineXML(addInfo: Boolean, organization: String, moduleID: String, version: String): NodeSeq =
if(addInfo)
(<info organisation={organization} module={moduleID} revision={version}>
<license name="Two-clause BSD-style" url="http://github.com/szeiger/scala-query/blob/master/LICENSE.txt" />
<description homepage="http://github.com/szeiger/scala-query/">
ScalaQuery is a type-safe database query API for Scala.
</description>
</info>
<dependency org="org.scala-tools.testing" name="scalacheck_2.9.1" rev="1.9"/>)
else
<dependency org="org.scala-tools.testing" name="scalacheck_2.9.1" rev="1.9"/>
def checkDownload = (dependencyClasspath in Compile) map { cp => if(cp.isEmpty) sys.error("Dependency not downloaded"); () }
def checkInfo = (customInfo, delivered) map { (addInfo, d) =>
if((d \ "info").isEmpty)
sys.error("No info tag generated")
else if(addInfo) {
if( !deliveredWithCustom(d) ) sys.error("Expected 'license' and 'description' tags in info tag, got: \n" + (d \ "info")) else ()
} else
if( deliveredWithCustom(d) ) sys.error("Expected empty 'info' tag, got: \n" + (d \ "info")) else ()
}
def deliveredWithCustom(d: NodeSeq) = (d \ "info" \ "license").nonEmpty && (d \ "info" \ "description").nonEmpty
}

View File

@ -1,11 +1,11 @@
> check-download
> check-info
> checkDownload
> checkInfo
> clean
$ touch info
> reload
> show custom-info
> check-download
> show custom-info
> check-info
> show customInfo
> checkDownload
> show customInfo
> checkInfo

View File

@ -1,8 +1,9 @@
libraryDependencies += "org.scalacheck" % "scalacheck" % "1.5"
ivyPaths <<= baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy-home")))
ivyPaths := baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy-home"))).value
TaskKey[Unit]("check") <<= update map { report =>
TaskKey[Unit]("check") := {
val report = update.value
val files = report.matching( moduleFilter(organization = "org.scalacheck", name = "scalacheck", revision = "1.5") )
assert(files.nonEmpty, "ScalaCheck module not found in update report")
val missing = files.filter(! _.exists)

View File

@ -2,7 +2,9 @@ externalIvySettings()
libraryDependencies += "org.scalacheck" % "scalacheck" % "1.5"
TaskKey[Unit]("check") <<= (baseDirectory, update) map { (base, report) =>
TaskKey[Unit]("check") := {
val base = baseDirectory.value
val report = update.value
val files = report.matching( moduleFilter(organization = "org.scalacheck", name = "scalacheck", revision = "1.5") )
assert(files.nonEmpty, "ScalaCheck module not found in update report")
}
}

View File

@ -0,0 +1,32 @@
lazy val commonSettings = Seq(
autoScalaLibrary := false,
ivyScala := None,
unmanagedJars in Compile ++= (scalaInstance map (_.allJars.toSeq)).value,
publishArtifact in packageSrc := false,
publishArtifact in packageDoc := false,
publishMavenStyle := false
)
lazy val dep = project.
settings(
commonSettings,
organization := "org.example",
version := "1.0",
publishTo := (baseDirectory in ThisBuild apply { base =>
Some(Resolver.file("file", base / "repo")(Resolver.ivyStylePatterns))
}).value
)
lazy val use = project.
settings(
commonSettings,
libraryDependencies += "org.example" %% "dep" % "1.0",
externalIvySettings(),
publishTo := (baseDirectory { base =>
Some(Resolver.file("file", base / "repo")(Resolver.ivyStylePatterns))
}).value,
TaskKey[Unit]("check") := (baseDirectory map {base =>
val inCache = ( (base / "target" / "use-cache") ** "*.jar").get
assert(inCache.isEmpty, "Cache contained jars: " + inCache)
}).value
)

View File

@ -1,32 +0,0 @@
import sbt._
import Keys._
object B extends Build
{
lazy val dep = Project("dep", file("dep")) settings( baseSettings : _*) settings(
organization := "org.example",
version := "1.0",
publishTo <<= baseDirectory in ThisBuild apply { base =>
Some(Resolver.file("file", base / "repo")(Resolver.ivyStylePatterns))
}
)
lazy val use = Project("use", file("use")) settings(baseSettings : _*) settings(
libraryDependencies += "org.example" %% "dep" % "1.0",
externalIvySettings(),
publishTo <<= baseDirectory { base =>
Some(Resolver.file("file", base / "repo")(Resolver.ivyStylePatterns))
},
TaskKey[Unit]("check") <<= baseDirectory map {base =>
val inCache = ( (base / "target" / "use-cache") ** "*.jar").get
assert(inCache.isEmpty, "Cache contained jars: " + inCache)
}
)
lazy val baseSettings = Seq(
autoScalaLibrary := false,
ivyScala := None,
unmanagedJars in Compile <++= scalaInstance map (_.jars),
publishArtifact in packageSrc := false,
publishArtifact in packageDoc := false,
publishMavenStyle := false
)
}

View File

@ -0,0 +1,19 @@
lazy val commonSettings = Seq(
autoScalaLibrary := false,
unmanagedJars in Compile ++= (scalaInstance map (_.allJars.toSeq)).value
)
lazy val dep = project.
settings(
commonSettings,
organization := "org.example",
version := "1.0"
)
lazy val use = project.
dependsOn(dep).
settings(
commonSettings,
libraryDependencies += "junit" % "junit" % "4.5",
externalIvySettings()
)

View File

@ -1,18 +0,0 @@
import sbt._
import Keys._
object B extends Build
{
lazy val dep = Project("dep", file("dep")) settings( baseSettings : _*) settings(
organization := "org.example",
version := "1.0"
)
lazy val use = Project("use", file("use")) dependsOn(dep) settings(baseSettings : _*) settings(
libraryDependencies += "junit" % "junit" % "4.5",
externalIvySettings()
)
lazy val baseSettings = Seq(
autoScalaLibrary := false,
unmanagedJars in Compile <++= scalaInstance map (_.jars)
)
}

View File

@ -0,0 +1,46 @@
lazy val p1 = (project in file("p1")).
settings(
checkTask(expectedMongo),
libraryDependencies += "org.mongodb" %% "casbah" % "2.4.1" pomOnly(),
inThisBuild(List(
organization := "org.example",
version := "1.0",
scalaVersion := "2.9.2",
autoScalaLibrary := false
))
)
lazy val p2 = (project in file("p2")).
dependsOn(p1).
settings(
checkTask(expectedInter)
)
lazy val expectedMongo =
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>casbah_2.9.2</artifactId>
<version>2.4.1</version>
<type>pom</type>
</dependency>
lazy val expectedInter =
<dependency>
<groupId>org.example</groupId>
<artifactId>p1_2.9.2</artifactId>
<version>1.0</version>
</dependency>
def checkTask(expectedDep: xml.Elem) = TaskKey[Unit]("checkPom") := {
val file = makePom.value
val pom = xml.XML.loadFile(file)
val actual = pom \\ "dependencies"
val expected = <d>
{expectedDep}
</d>
def dropTopElem(s:String): String = s.split("""\n""").drop(1).dropRight(1).mkString("\n")
val pp = new xml.PrettyPrinter(Int.MaxValue, 0)
val expectedString = dropTopElem(pp.format(expected))
val actualString = dropTopElem(pp.formatNodes(actual))
assert(expectedString == actualString, "Expected dependencies section:\n" + expectedString + "\n\nActual:\n" + actualString)
}

View File

@ -1,49 +0,0 @@
import sbt._
import Keys._
object build extends Build {
override def settings = super.settings ++ Seq(
organization := "org.example",
version := "1.0",
scalaVersion := "2.9.2",
autoScalaLibrary := false
)
lazy val p1 = Project("p1",file("p1")) settings(
checkTask(expectedMongo),
libraryDependencies += "org.mongodb" %% "casbah" % "2.4.1" pomOnly()
)
lazy val p2 = Project("p2", file("p2")) dependsOn(p1) settings(
checkTask(expectedInter)
)
lazy val expectedMongo =
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>casbah_2.9.2</artifactId>
<version>2.4.1</version>
<type>pom</type>
</dependency>
lazy val expectedInter =
<dependency>
<groupId>org.example</groupId>
<artifactId>p1_2.9.2</artifactId>
<version>1.0</version>
</dependency>
def checkTask(expectedDep: xml.Elem) = TaskKey[Unit]("check-pom") <<= makePom map { file =>
val pom = xml.XML.loadFile(file)
val actual = pom \\ "dependencies"
val expected = <d>
{expectedDep}
</d>
def dropTopElem(s:String): String = s.split("""\n""").drop(1).dropRight(1).mkString("\n")
val pp = new xml.PrettyPrinter(Int.MaxValue, 0)
val expectedString = dropTopElem(pp.format(expected))
val actualString = dropTopElem(pp.formatNodes(actual))
assert(expectedString == actualString, "Expected dependencies section:\n" + expectedString + "\n\nActual:\n" + actualString)
}
}

View File

@ -1,2 +1,2 @@
> p1/check-pom
> p2/check-pom
> p1/checkPom
> p2/checkPom

View File

@ -0,0 +1,72 @@
import scala.xml._
lazy val root = (project in file(".")).
settings(
readPom := (makePom map XML.loadFile).value,
TaskKey[Unit]("checkPom") := checkPom.value,
TaskKey[Unit]("checkExtra") := checkExtra.value,
TaskKey[Unit]("checkVersionPlusMapping") := checkVersionPlusMapping.value,
resolvers += Resolver.sonatypeRepo("snapshots"),
makePomConfiguration ~= { _.copy(extra = <extra-tag/>) },
libraryDependencies += "com.google.code.findbugs" % "jsr305" % "1.3.+"
)
val readPom = TaskKey[Elem]("read-pom")
val fakeName = "fake"
val fakeURL = "http://example.org"
val fakeRepo = fakeName at fakeURL
def extraTagName = "extra-tag"
def checkProject(pom: Elem) = if(pom.label != "project") sys.error("Top level element was not 'project': " + pom.label)
def withRepositories[T](pomXML: Elem)(f: NodeSeq => T) =
{
val repositoriesElement = pomXML \ "repositories"
if(repositoriesElement.size == 1) f(repositoriesElement) else sys.error("'repositories' element not found in generated pom")
}
lazy val checkExtra = readPom map { pomXML =>
checkProject(pomXML)
val extra = pomXML \ extraTagName
if(extra.isEmpty) sys.error("'" + extraTagName + "' not found in generated pom.xml.") else ()
}
lazy val checkVersionPlusMapping = (readPom) map { (pomXml) =>
var found = false
for {
dep <- pomXml \ "dependencies" \ "dependency"
if (dep \ "artifactId").text == "jsr305"
// TODO - Ignore space here.
if (dep \ "version").text != "[1.3,1.4)"
} sys.error(s"Found dependency with invalid maven version: $dep")
()
}
lazy val checkPom = (readPom, fullResolvers) map { (pomXML, ivyRepositories) =>
checkProject(pomXML)
withRepositories(pomXML) { repositoriesElement =>
val repositories = repositoriesElement \ "repository"
val writtenRepositories = repositories.map(read).distinct
val mavenStyleRepositories = ivyRepositories.collect {
case x: MavenRepository if (x.name != "public") && (x.name != "jcenter") => normalize(x)
} distinct;
lazy val explain = (("Written:" +: writtenRepositories) ++ ("Declared:" +: mavenStyleRepositories)).mkString("\n\t")
if( writtenRepositories != mavenStyleRepositories )
sys.error("Written repositories did not match declared repositories.\n\t" + explain)
else
()
}
}
def read(repository: xml.Node): MavenRepository =
(repository \ "name").text at normalize((repository \ "url").text)
def normalize(url: String): String =
{
val base = uri( url ).normalize.toString
if(base.endsWith("/")) base else (base + "/")
}
def normalize(repo: MavenRepository): MavenRepository = new MavenRepository(repo.name, normalize(repo.root))

View File

@ -1,76 +0,0 @@
import sbt.{Node =>_,_}
import Keys._
import scala.xml._
object MakePomTest extends Build
{
lazy val root = Project("root", file(".")) settings(
readPom <<= makePom map XML.loadFile,
TaskKey[Unit]("check-pom") <<= checkPom,
TaskKey[Unit]("check-extra") <<= checkExtra,
TaskKey[Unit]("check-version-plus-mapping") <<= checkVersionPlusMapping,
resolvers += Resolver.sonatypeRepo("snapshots"),
makePomConfiguration ~= { _.copy(extra = <extra-tag/>) },
libraryDependencies += "com.google.code.findbugs" % "jsr305" % "1.3.+"
)
val readPom = TaskKey[Elem]("read-pom")
val fakeName = "fake"
val fakeURL = "http://example.org"
val fakeRepo = fakeName at fakeURL
def extraTagName = "extra-tag"
def checkProject(pom: Elem) = if(pom.label != "project") sys.error("Top level element was not 'project': " + pom.label)
def withRepositories[T](pomXML: Elem)(f: NodeSeq => T) =
{
val repositoriesElement = pomXML \ "repositories"
if(repositoriesElement.size == 1) f(repositoriesElement) else sys.error("'repositories' element not found in generated pom")
}
lazy val checkExtra = readPom map { pomXML =>
checkProject(pomXML)
val extra = pomXML \ extraTagName
if(extra.isEmpty) sys.error("'" + extraTagName + "' not found in generated pom.xml.") else ()
}
lazy val checkVersionPlusMapping = (readPom) map { (pomXml) =>
var found = false
for {
dep <- pomXml \ "dependencies" \ "dependency"
if (dep \ "artifactId").text == "jsr305"
// TODO - Ignore space here.
if (dep \ "version").text != "[1.3,1.4)"
} sys.error(s"Found dependency with invalid maven version: $dep")
()
}
lazy val checkPom = (readPom, fullResolvers) map { (pomXML, ivyRepositories) =>
checkProject(pomXML)
withRepositories(pomXML) { repositoriesElement =>
val repositories = repositoriesElement \ "repository"
val writtenRepositories = repositories.map(read).distinct
val mavenStyleRepositories = ivyRepositories.collect {
case x: MavenRepository if (x.name != "public") && (x.name != "jcenter") => normalize(x)
} distinct;
lazy val explain = (("Written:" +: writtenRepositories) ++ ("Declared:" +: mavenStyleRepositories)).mkString("\n\t")
if( writtenRepositories != mavenStyleRepositories )
sys.error("Written repositories did not match declared repositories.\n\t" + explain)
else
()
}
}
def read(repository: Node): MavenRepository =
(repository \ "name").text at normalize((repository \ "url").text)
def normalize(url: String): String =
{
val base = uri( url ).normalize.toString
if(base.endsWith("/")) base else (base + "/")
}
def normalize(repo: MavenRepository): MavenRepository = new MavenRepository(repo.name, normalize(repo.root))
}

View File

@ -1,3 +1,3 @@
> check-pom
> check-extra
> check-version-plus-mapping
> checkPom
> checkExtra
> checkVersionPlusMapping

View File

@ -1,4 +1,4 @@
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / ".ivy2")))
ivyPaths := (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / ".ivy2"))).value
// not in the default repositories
libraryDependencies += "com.sun.jmx" % "jmxri" % "1.2.1"

View File

@ -1,9 +1,9 @@
ivyScala ~= { (is: Option[IvyScala]) => is.map(_.copy(checkExplicit = false, overrideScalaVersion = false, filterImplicit = false)) }
ivyPaths <<= baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy-home")))
ivyPaths := baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy-home"))).value
libraryDependencies += "junit" % "junit" % "4.8"
autoScalaLibrary := false
cleanFiles <+= baseDirectory(_ / "ivy-home")
cleanFiles += baseDirectory(_ / "ivy-home").value

View File

@ -4,8 +4,8 @@ moduleName := "asdf"
crossPaths := false
TaskKey[Unit]("check-name") <<= (moduleName, name, packageBin in Compile) map { (module, n, f) =>
TaskKey[Unit]("checkName") := ((moduleName, name, packageBin in Compile) map { (module, n, f) =>
val path = f.getAbsolutePath
assert(path contains module, "Path " + path + " did not contain module name " + module)
assert(!path.contains(n), "Path " + path + " contained " + n)
}
}).value

View File

@ -1 +1 @@
> check-name
> checkName

View File

@ -4,11 +4,12 @@ libraryDependencies ++= Seq("natives-windows", "natives-linux", "natives-osx") m
autoScalaLibrary := false
TaskKey[Unit]("check") <<= dependencyClasspath in Compile map { cp =>
TaskKey[Unit]("check") := (dependencyClasspath in Compile map { cp =>
assert(cp.size == 3, "Expected 3 jars, got: " + cp.files.mkString("(", ", ", ")"))
}
}).value
TaskKey[Unit]("check-pom") <<= makePom map { file =>
TaskKey[Unit]("checkPom") := {
val file = makePom.value
val pom = xml.XML.loadFile(file)
val actual = pom \\ "dependencies"
def depSection(classifier: String) =

View File

@ -4,10 +4,11 @@ libraryDependencies ++= Seq(
autoScalaLibrary := false
TaskKey[Unit]("check") <<= (externalDependencyClasspath in Compile, externalDependencyClasspath in Test) map { (cp, tcp) =>
TaskKey[Unit]("check") := {
val cp = (externalDependencyClasspath in Compile).value
val tcp = (externalDependencyClasspath in Test).value
assert(cp.size == 2, "Expected 2 jars on compile classpath, got: " + cp.files.mkString("(", ", ", ")"))
// this should really be 1 because of intransitive(), but Ivy doesn't handle this.
// So, this test can only check that the assertion reported in #582 isn't triggered.
assert(tcp.size == 2, "Expected 2 jar on test classpath, got: " + tcp.files.mkString("(", ", ", ")"))
}

View File

@ -1,6 +1,6 @@
> check
> check-pom
> checkPom
$ delete build.sbt
$ copy-file changes/non-mergeable.sbt build.sbt

View File

@ -1,4 +1,4 @@
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache")))
ivyPaths := (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))).value
organization := "org.example"

View File

@ -1,16 +1,16 @@
autoScalaLibrary := false
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache")))
ivyPaths := (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))).value
ivyScala <<= (scalaVersion in update, scalaBinaryVersion in update) { (fv, bv) =>
ivyScala := ((scalaVersion in update, scalaBinaryVersion in update) { (fv, bv) =>
Some(new IvyScala(fv, bv, Nil, filterImplicit = false, checkExplicit = false, overrideScalaVersion = false))
}
}).value
InputKey[Unit]("check") <<= inputTask { args =>
InputKey[Unit]("check") := (inputTask { args =>
(update, args) map {
case (report, Seq(expected, _*)) =>
report.allModules.forall(_.revision == expected)
}
}
}).evaluated
scalaVersion := "2.9.1"

View File

@ -0,0 +1,33 @@
import complete.DefaultParsers._
lazy val root = (project in file(".")).
settings(
resolvers ++= Seq(local, Resolver.sonatypeRepo("releases"), Resolver.sonatypeRepo("snapshots")),
InputKey[Unit]("checkPom") := (InputTask(_ => spaceDelimited("<args>")) { result => (makePom, result, streams) map checkPomRepositories }).evaluated,
makePomConfiguration := ((makePomConfiguration, baseDirectory) { (conf, base) =>
conf.copy(filterRepositories = pomIncludeRepository(base, conf.filterRepositories) )
}).value,
ivyPaths := baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy-home"))).value
)
val local = "local-maven-repo" at "file://" + (Path.userHome / ".m2" /"repository").absolutePath
def pomIncludeRepository(base: File, prev: MavenRepository => Boolean) = (r: MavenRepository) =>
if(base / "repo.none" exists) false else if(base / "repo.all" exists) true else prev(r)
def addSlash(s: String): String =
s match {
case s if s endsWith "/" => s
case _ => s + "/"
}
def checkPomRepositories(file: File, args: Seq[String], s: TaskStreams)
{
val repositories = scala.xml.XML.loadFile(file) \\ "repository"
val extracted = repositories.map { repo => MavenRepository(repo \ "name" text, addSlash(repo \ "url" text)) }
val expected = args.map(GlobFilter.apply)
s.log.info("Extracted: " + extracted.mkString("\n\t", "\n\t", "\n"))
s.log.info("Expected: " + args.mkString("\n\t", "\n\t", "\n"))
extracted.find { e => !expected.exists(_.accept(e.root)) } map { "Repository should not be exported: " + _ } orElse
(expected.find { e => !extracted.exists(r => e.accept(r.root)) } map { "Repository should be exported: " + _ } ) foreach error
}

View File

@ -1,37 +0,0 @@
import sbt._
import Keys._
import complete.DefaultParsers._
object PomRepoTest extends Build
{
lazy val root = Project("root", file(".")) settings(
resolvers ++= Seq(local, Resolver.sonatypeRepo("releases"), Resolver.sonatypeRepo("snapshots")),
InputKey[Unit]("check-pom") <<= InputTask(_ => spaceDelimited("<args>")) { result => (makePom, result, streams) map checkPomRepositories },
makePomConfiguration <<= (makePomConfiguration, baseDirectory) { (conf, base) =>
conf.copy(filterRepositories = pomIncludeRepository(base, conf.filterRepositories) )
},
ivyPaths <<= baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy-home")))
)
val local = "local-maven-repo" at "file://" + (Path.userHome / ".m2" /"repository").absolutePath
def pomIncludeRepository(base: File, prev: MavenRepository => Boolean) = (r: MavenRepository) =>
if(base / "repo.none" exists) false else if(base / "repo.all" exists) true else prev(r)
def addSlash(s: String): String =
s match {
case s if s endsWith "/" => s
case _ => s + "/"
}
def checkPomRepositories(file: File, args: Seq[String], s: TaskStreams)
{
val repositories = scala.xml.XML.loadFile(file) \\ "repository"
val extracted = repositories.map { repo => MavenRepository(repo \ "name" text, addSlash(repo \ "url" text)) }
val expected = args.map(GlobFilter.apply)
s.log.info("Extracted: " + extracted.mkString("\n\t", "\n\t", "\n"))
s.log.info("Expected: " + args.mkString("\n\t", "\n\t", "\n"))
extracted.find { e => !expected.exists(_.accept(e.root)) } map { "Repository should not be exported: " + _ } orElse
(expected.find { e => !extracted.exists(r => e.accept(r.root)) } map { "Repository should be exported: " + _ } ) foreach error
}
}

View File

@ -1,11 +1,11 @@
# write the default pom. The only repositories should be Scala Tools Releases and Snapshots
> check-pom https://oss.sonatype.org/content/repositories/releases/ https://oss.sonatype.org/content/repositories/snapshots/
> checkPom https://oss.sonatype.org/content/repositories/releases/ https://oss.sonatype.org/content/repositories/snapshots/
# include file:// repositories. The generated repositories section should include the local Maven repository as well
$ touch repo.all
> check-pom https://oss.sonatype.org/content/repositories/releases/ https://oss.sonatype.org/content/repositories/snapshots/ file://*.m2/repository/
> checkPom https://oss.sonatype.org/content/repositories/releases/ https://oss.sonatype.org/content/repositories/snapshots/ file://*.m2/repository/
# include file:// repositories. The generated repositories section should include the local Maven repository as well
$ delete repo.all
$ touch repo.none
> check-pom
> checkPom

View File

@ -0,0 +1,34 @@
import complete._
import complete.DefaultParsers._
lazy val root = (project in file(".")).
settings(
externalPom(),
scalaVersion := "2.9.0-1",
check := checkTask.evaluated,
managedClasspath in Provided := ((classpathTypes, update) map { (cpts, report) => Classpaths.managedJars(Provided, cpts, report) }).value
)
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")

View File

@ -1,37 +0,0 @@
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")
}

View File

@ -0,0 +1,42 @@
lazy val custom = config("custom")
lazy val root = (project in file(".")).
configs(custom).
settings(
TaskKey[Unit]("checkPom") := checkPom.value,
libraryDependencies ++= Seq(
"a" % "a" % "1.0",
"b" % "b" % "1.0" % "runtime,optional",
"c" % "c" % "1.0" % "optional",
"d" % "d" % "1.0" % "test",
"e" % "e" % "1.0" % "custom",
"f" % "f" % "1.0" % "custom,optional,runtime",
"g" % "g" % "1.0" % "custom,runtime" classifier "foo",
"h" % "h" % "1.0" % "custom,optional,runtime" classifier "foo"
)
)
def checkPom = makePom map { pom =>
val expected = Seq(
("a", None, false, None),
("b", Some("runtime"), true, None),
("c", None, true, None),
("d", Some("test"), false, None),
("e", None, false, None),
("f", Some("runtime"), true, None),
("g", Some("runtime"), false, Some("foo")),
("h", Some("runtime"), true, Some("foo"))
)
val loaded = xml.XML.loadFile(pom)
val deps = loaded \\ "dependency"
expected foreach { case (id, scope, opt, classifier) =>
val dep = deps.find(d => (d \ "artifactId").text == id).getOrElse( sys.error("Dependency '" + id + "' not written to pom:\n" + loaded))
val actualOpt = java.lang.Boolean.parseBoolean( (dep \\ "optional").text )
assert(opt == actualOpt, "Invalid 'optional' section '" + (dep \\ "optional") + "' for " + id + ", expected optional=" + opt)
val actualScope = (dep \\ "scope") match { case Seq() => None; case x => Some(x.text) }
val actualClassifier = (dep \\ "classifier") match { case Seq() => None; case x => Some(x.text) }
assert(actualScope == scope, "Invalid 'scope' section '" + (dep \\ "scope") + "' for " + id + ", expected scope=" + scope)
assert(actualClassifier == classifier, "Invalid 'classifier' section '" + (dep \\ "classifier") + "' for " + id + ", expected classifier=" + classifier)
}
}

View File

@ -1,47 +0,0 @@
import sbt._
import Keys._
object PomTest extends Build
{
lazy val custom = config("custom")
lazy val root = Project("root", file("root")) configs(custom) settings(
TaskKey[Unit]("check-pom") <<= checkPom,
libraryDependencies ++= Seq(
"a" % "a" % "1.0",
"b" % "b" % "1.0" % "runtime,optional",
"c" % "c" % "1.0" % "optional",
"d" % "d" % "1.0" % "test",
"e" % "e" % "1.0" % "custom",
"f" % "f" % "1.0" % "custom,optional,runtime",
"g" % "g" % "1.0" % "custom,runtime" classifier "foo",
"h" % "h" % "1.0" % "custom,optional,runtime" classifier "foo"
)
)
def checkPom = makePom map { pom =>
val expected = Seq(
("a", None, false, None),
("b", Some("runtime"), true, None),
("c", None, true, None),
("d", Some("test"), false, None),
("e", None, false, None),
("f", Some("runtime"), true, None),
("g", Some("runtime"), false, Some("foo")),
("h", Some("runtime"), true, Some("foo"))
)
val loaded = xml.XML.loadFile(pom)
val deps = loaded \\ "dependency"
expected foreach { case (id, scope, opt, classifier) =>
val dep = deps.find(d => (d \ "artifactId").text == id).getOrElse( sys.error("Dependency '" + id + "' not written to pom:\n" + loaded))
val actualOpt = java.lang.Boolean.parseBoolean( (dep \\ "optional").text )
assert(opt == actualOpt, "Invalid 'optional' section '" + (dep \\ "optional") + "' for " + id + ", expected optional=" + opt)
val actualScope = (dep \\ "scope") match { case Seq() => None; case x => Some(x.text) }
val actualClassifier = (dep \\ "classifier") match { case Seq() => None; case x => Some(x.text) }
assert(actualScope == scope, "Invalid 'scope' section '" + (dep \\ "scope") + "' for " + id + ", expected scope=" + scope)
assert(actualClassifier == classifier, "Invalid 'classifier' section '" + (dep \\ "classifier") + "' for " + id + ", expected classifier=" + classifier)
}
}
}

View File

@ -1 +1 @@
> check-pom
> checkPom

View File

@ -1,23 +0,0 @@
import sbt._
import Keys._
object P extends Build
{
override def settings = super.settings ++ Seq(
scalaBinaryVersion in update := "2.9.0"
)
def configIvyScala =
ivyScala ~= { _.map(_.copy(checkExplicit = false)) }
val declared = SettingKey[Boolean]("declared")
lazy val a = Project("A", file("a")) settings(
libraryDependencies += "org.scala-tools.sbinary" %% "sbinary" % "0.4.0" % "provided",
configIvyScala
)
lazy val b = Project("B", file("b")) dependsOn(a) settings(
libraryDependencies <<= declared(d => if(d) Seq("org.scala-tools.sbinary" %% "sbinary" % "0.4.0" % "provided") else Nil),
declared <<= baseDirectory(_ / "declare.lib" exists),
configIvyScala
)
}

View File

@ -0,0 +1,19 @@
def configIvyScala =
ivyScala ~= { _.map(_.copy(checkExplicit = false)) }
val declared = SettingKey[Boolean]("declared")
lazy val a = project.
settings(
libraryDependencies += "org.scala-tools.sbinary" %% "sbinary" % "0.4.0" % "provided",
configIvyScala,
scalaBinaryVersion in update := "2.9.0"
)
lazy val b = project.
dependsOn(a).
settings(
libraryDependencies := declared(d => if(d) Seq("org.scala-tools.sbinary" %% "sbinary" % "0.4.0" % "provided") else Nil).value,
declared := baseDirectory(_ / "declare.lib" exists).value,
configIvyScala,
scalaBinaryVersion in update := "2.9.0"
)

View File

@ -1,11 +1,11 @@
$ copy-file changes/P.scala project/P.scala
$ copy-file changes/p.sbt p.sbt
$ copy-file changes/A.scala a/src/main/scala/A.scala
$ copy-file changes/B.scala b/src/main/scala/B.scala
> reload
> A/compile
-> B/compile
> a/compile
-> b/compile
$ touch b/declare.lib
> reload
> compile
> compile

View File

@ -0,0 +1,30 @@
import complete.DefaultParsers._
val provided = SettingKey[Boolean]("provided")
val check = InputKey[Unit]("check")
lazy val root = (project in file(".")).
settings(
provided := baseDirectory(_ / "useProvided" exists).value,
configuration := provided(p => if(p) Provided else Compile).value,
libraryDependencies += configuration(c => "javax.servlet" % "servlet-api" % "2.5" % c.name).value,
managedClasspath in Provided := ((classpathTypes, update) map { (cpts, report) => Classpaths.managedJars(Provided, cpts, report) }).value,
check := (InputTask(_ => Space ~> token(Compile.name.id | Runtime.name | Provided.name | Test.name) ~ token(Space ~> Bool)) { result =>
(result, managedClasspath in Provided, fullClasspath in Runtime, fullClasspath in Compile, fullClasspath in Test) map { case ((conf, expected), p, r, c, t) =>
val cp = if(conf == Compile.name) c else if(conf == Runtime.name) r else if(conf == Provided.name) p else if(conf == Test.name) t else sys.error("Invalid config: " + conf)
checkServletAPI(cp.files, expected, conf)
}
}).evaluated
)
def checkServletAPI(paths: Seq[File], shouldBeIncluded: Boolean, label: String) =
{
val servletAPI = paths.find(_.getName contains "servlet-api")
if(shouldBeIncluded)
{
if(servletAPI.isEmpty)
sys.error("Servlet API should have been included in " + label + ".")
}
else
servletAPI.foreach(s => sys.error(s + " incorrectly included in " + label + "."))
}

View File

@ -1,34 +0,0 @@
import sbt._
import Keys._
import complete.DefaultParsers._
object TestProject extends Build
{
val provided = SettingKey[Boolean]("provided")
val check = InputKey[Unit]("check")
lazy val root = Project("root", file(".")) settings(
provided <<= baseDirectory(_ / "useProvided" exists),
configuration <<= provided(p => if(p) Provided else Compile),
libraryDependencies <+= configuration(c => "javax.servlet" % "servlet-api" % "2.5" % c.name),
managedClasspath in Provided <<= (classpathTypes, update) map { (cpts, report) => Classpaths.managedJars(Provided, cpts, report) },
check <<= InputTask(_ => Space ~> token(Compile.name.id | Runtime.name | Provided.name | Test.name) ~ token(Space ~> Bool)) { result =>
(result, managedClasspath in Provided, fullClasspath in Runtime, fullClasspath in Compile, fullClasspath in Test) map { case ((conf, expected), p, r, c, t) =>
val cp = if(conf == Compile.name) c else if(conf == Runtime.name) r else if(conf == Provided.name) p else if(conf == Test.name) t else sys.error("Invalid config: " + conf)
checkServletAPI(cp.files, expected, conf)
}
}
)
private def checkServletAPI(paths: Seq[File], shouldBeIncluded: Boolean, label: String) =
{
val servletAPI = paths.find(_.getName contains "servlet-api")
if(shouldBeIncluded)
{
if(servletAPI.isEmpty)
sys.error("Servlet API should have been included in " + label + ".")
}
else
servletAPI.foreach(s => sys.error(s + " incorrectly included in " + label + "."))
}
}

View File

@ -0,0 +1,24 @@
lazy val root = (project in file(".")).
dependsOn(sub).
aggregate(sub).
settings(inThisBuild(List(
organization := "A",
version := "1.0",
ivyPaths := baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy" / "cache")) ).value,
externalResolvers := (baseDirectory map { base => Resolver.file("local", base / "ivy" / "local" asFile)(Resolver.ivyStylePatterns) :: Nil }).value
)),
mavenStyle,
interProject,
name := "Publish Test"
)
lazy val sub = project.
settings(
mavenStyle,
name := "Sub Project"
)
lazy val mavenStyle = publishMavenStyle := (baseDirectory { base => (base / "mavenStyle") exists }).value
def interProject =
projectDependencies := ((publishMavenStyle, publishMavenStyle in sub, projectDependencies) map { (style, subStyle, pd) => if(style == subStyle) pd else Nil }).value

View File

@ -0,0 +1,20 @@
lazy val root = (project in file(".")).
settings(inThisBuild(List(
organization := "A",
version := "1.0",
ivyPaths := baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy" / "cache")) ).value,
externalResolvers := (baseDirectory map { base => Resolver.file("local", base / "ivy" / "local" asFile)(Resolver.ivyStylePatterns) :: Nil }).value
)),
mavenStyle,
name := "Retrieve Test",
libraryDependencies := (publishMavenStyle { style => if(style) mavenStyleDependencies else ivyStyleDependencies }).value
)
lazy val mavenStyle = publishMavenStyle := (baseDirectory { base => (base / "mavenStyle") exists }).value
def ivyStyleDependencies = parentDep("A") :: subDep("A") :: subDep("B") ::parentDep("D") :: Nil
def mavenStyleDependencies = parentDep("B") :: parentDep("C") :: subDep("C") :: subDep("D") :: Nil
def parentDep(org: String) = org %% "publish-test" % "1.0"
def subDep(org: String) = org %% "sub-project" % "1.0"

View File

@ -1,26 +0,0 @@
import sbt._
import Keys._
object MultiPublishTest extends Build
{
override lazy val settings = super.settings ++ Seq(
organization := "A",
version := "1.0",
ivyPaths <<= baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy" / "cache")) ),
externalResolvers <<= baseDirectory map { base => Resolver.file("local", base / "ivy" / "local" asFile)(Resolver.ivyStylePatterns) :: Nil }
)
lazy val root = Project("root", file(".")) settings(
name := "Retrieve Test",
mavenStyle,
libraryDependencies <<= publishMavenStyle { style => if(style) mavenStyleDependencies else ivyStyleDependencies }
)
lazy val mavenStyle = publishMavenStyle <<= baseDirectory { base => (base / "mavenStyle") exists }
def ivyStyleDependencies = parentDep("A") :: subDep("A") :: subDep("B") ::parentDep("D") :: Nil
def mavenStyleDependencies = parentDep("B") :: parentDep("C") :: subDep("C") :: subDep("D") :: Nil
def parentDep(org: String) = org %% "publish-test" % "1.0"
def subDep(org: String) = org %% "sub-project" % "1.0"
}

View File

@ -1,21 +0,0 @@
import sbt._
import Keys._
object MultiPublishTest extends Build
{
override lazy val settings = super.settings ++ Seq(
organization := "A",
version := "1.0",
ivyPaths <<= baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy" / "cache")) ),
externalResolvers <<= baseDirectory map { base => Resolver.file("local", base / "ivy" / "local" asFile)(Resolver.ivyStylePatterns) :: Nil }
)
lazy val root = Project("root", file(".")) dependsOn(sub) aggregate(sub) settings( mavenStyle, interProject, name := "Publish Test" )
lazy val sub = Project("sub", file("sub")) settings( mavenStyle, name := "Sub Project" )
lazy val mavenStyle = publishMavenStyle <<= baseDirectory { base => (base / "mavenStyle") exists }
def interProject =
projectDependencies <<= (publishMavenStyle, publishMavenStyle in sub, projectDependencies) map { (style, subStyle, pd) => if(style == subStyle) pd else Nil }
}

View File

@ -0,0 +1,31 @@
// import sbt.internal.librarymanagement.syntax._
lazy val root = (project in file(".")).
settings(
libraryDependencies += "net.liftweb" % "lift-webkit" % "1.0" intransitive(),
libraryDependencies += "org.scalacheck" % "scalacheck" % "1.5" intransitive(),
autoScalaLibrary := false,
managedScalaInstance := false,
transitiveClassifiers := Seq("sources"),
TaskKey[Unit]("checkSources") := (updateClassifiers map checkSources).value,
TaskKey[Unit]("checkBinaries") := (update map checkBinaries).value
)
def getSources(report: UpdateReport) = report.matching(artifactFilter(`classifier` = "sources") )
def checkSources(report: UpdateReport): Unit =
{
val srcs = getSources(report)
if(srcs.isEmpty)
sys.error("No sources retrieved")
else if(srcs.size != 2)
sys.error("Incorrect sources retrieved:\n\t" + srcs.mkString("\n\t"))
else
()
}
def checkBinaries(report: UpdateReport): Unit =
{
val srcs = getSources(report)
if(srcs.nonEmpty) sys.error("Sources retrieved:\n\t" + srcs.mkString("\n\t"))
else ()
}

View File

@ -1,31 +0,0 @@
import sbt._
import Keys._
object Test extends Build
{
lazy val root = Project("root", file(".")) settings(
libraryDependencies += "net.liftweb" % "lift-webkit" % "1.0" intransitive(),
libraryDependencies += "org.scalacheck" % "scalacheck" % "1.5" intransitive(),
autoScalaLibrary := false,
managedScalaInstance := false,
transitiveClassifiers := Seq("sources"),
TaskKey[Unit]("check-sources") <<= updateClassifiers map checkSources,
TaskKey[Unit]("check-binaries") <<= update map checkBinaries
)
def getSources(report: UpdateReport) = report.matching(artifactFilter(`classifier` = "sources") )
def checkSources(report: UpdateReport): Unit =
{
val srcs = getSources(report)
if(srcs.isEmpty)
sys.error("No sources retrieved")
else if(srcs.size != 2)
sys.error("Incorrect sources retrieved:\n\t" + srcs.mkString("\n\t"))
else
()
}
def checkBinaries(report: UpdateReport): Unit =
{
val srcs = getSources(report)
if(srcs.nonEmpty) sys.error("Sources retrieved:\n\t" + srcs.mkString("\n\t")) else ()
}
}

View File

@ -1,3 +1,3 @@
> check-binaries
> show update-classifiers
> check-sources
> checkBinaries
> show updateClassifiers
> checkSources

View File

@ -1,23 +1,24 @@
autoScalaLibrary := false
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache")))
ivyPaths := (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))).value
libraryDependencies ++= Seq(
"org.sat4j" % "org.sat4j.pb" % "2.3.1",
"org.sat4j" % "org.sat4j.core" % "2.3.1"
)
TaskKey[Unit]("check-update") <<= update map { report =>
TaskKey[Unit]("checkUpdate") := {
val report = update.value
val mods = report.configuration(Compile.name).get.allModules.map(_.name).toSet
val expected = Set("org.sat4j.pb", "org.sat4j.core")
if(mods != expected)
error("Expected modules " + expected + ", got: " + mods)
}
TaskKey[Unit]("check-classpath") <<= dependencyClasspath in Compile map { cp =>
TaskKey[Unit]("checkClasspath") := (dependencyClasspath in Compile map { cp =>
val jars = cp.files.map(_.getName).toSet
// Note: pb depends on tests artifact in core for no good reason. Previously this was not correctly added to the classpath.
val expected = Set("org.sat4j.pb-2.3.1.jar", "org.sat4j.core-2.3.1.jar", "org.sat4j.core-2.3.1-tests.jar")
if(jars != expected)
error("Expected jars " + expected + ", got: " + jars)
}
}).value

View File

@ -1,2 +1,2 @@
> check-update
> check-classpath
> checkUpdate
> checkClasspath

Some files were not shown because too many files have changed in this diff Show More