mirror of https://github.com/sbt/sbt.git
* Added InstallProject+DefaultInstallProject with 'install' task. It installs dependencies retrieved from the resolver assigned to 'resolveFrom' to the resolver given by 'publishTo'.
* Added simple runTask(mainClass: String) method git-svn-id: https://simple-build-tool.googlecode.com/svn/trunk@959 d89573ee-9141-11dd-94d4-bdf5e562f29c
This commit is contained in:
parent
97f252aaaf
commit
951bcc9a65
|
|
@ -78,7 +78,7 @@ trait ManagedProject extends ClasspathProject
|
|||
final case class CacheDirectory(dir: Path) extends ManagedOption
|
||||
final case class CheckScalaVersion(configs: Iterable[Configuration], checkExplicit: Boolean, filterImplicit: Boolean) extends ManagedOption
|
||||
|
||||
private def withConfigurations(outputPattern: String, managedDependencyPath: Path, options: Seq[ManagedOption])
|
||||
protected def withConfigurations(outputPattern: String, managedDependencyPath: Path, options: Seq[ManagedOption])
|
||||
(doWith: (IvyConfiguration, UpdateConfiguration) => Option[String]) =
|
||||
{
|
||||
var synchronize = false
|
||||
|
|
@ -117,7 +117,7 @@ trait ManagedProject extends ClasspathProject
|
|||
if(v.isEmpty) None
|
||||
else Some(v)
|
||||
}
|
||||
private def withIvyTask(doTask: => Option[String]) =
|
||||
protected def withIvyTask(doTask: => Option[String]) =
|
||||
task
|
||||
{
|
||||
try { doTask }
|
||||
|
|
@ -422,6 +422,28 @@ object BasicManagedProject
|
|||
"Deletes the cache of artifacts downloaded for automatically managed dependencies."
|
||||
}
|
||||
|
||||
class DefaultInstallProject(val info: ProjectInfo) extends InstallProject with MavenStyleScalaPaths with BasicDependencyProject
|
||||
{
|
||||
def fullUnmanagedClasspath(config: Configuration) = unmanagedClasspath
|
||||
def dependencies = info.dependencies
|
||||
}
|
||||
trait InstallProject extends BasicManagedProject
|
||||
{
|
||||
def installOptions: Seq[ManagedOption] = updateOptions
|
||||
override def filterScalaJars = false
|
||||
override def checkExplicitScalaDependencies = false
|
||||
lazy val install = installTask(updateOptions)
|
||||
def installTask(options: => Seq[ManagedOption]) =
|
||||
withIvyTask
|
||||
{
|
||||
withConfigurations("", managedDependencyPath, options) { (ivyConf, ignore) =>
|
||||
val toResolver = reflectiveRepositories.get("publish-to").getOrElse(error("No repository to publish to was specified"))
|
||||
val fromResolver = reflectiveRepositories.get("retrieve-from").getOrElse(error("No repository to retrieve from was specified"))
|
||||
ManageDependencies.install(ivyConf, fromResolver.name, toResolver.name, true, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trait BasicDependencyPaths extends ManagedProject
|
||||
{
|
||||
import BasicDependencyPaths._
|
||||
|
|
|
|||
|
|
@ -229,6 +229,8 @@ abstract class BasicScalaProject extends ScalaProject with BasicDependencyProjec
|
|||
}
|
||||
}
|
||||
|
||||
protected def runTask(mainClass: String): MethodTask = task { args => runTask(Some(mainClass), runClasspath, args) dependsOn(compile, copyResources) }
|
||||
|
||||
protected def compileAction = task { doCompile(mainCompileConditional) } describedAs MainCompileDescription
|
||||
protected def testCompileAction = task { doCompile(testCompileConditional) } dependsOn compile describedAs TestCompileDescription
|
||||
protected def cleanAction = cleanTask(outputPath, cleanOptions) describedAs CleanDescription
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import org.apache.ivy.{core, plugins, util, Ivy}
|
|||
import core.LogOptions
|
||||
import core.cache.DefaultRepositoryCacheManager
|
||||
import core.deliver.DeliverOptions
|
||||
import core.install.InstallOptions
|
||||
import core.module.descriptor.{DefaultArtifact, DefaultDependencyArtifactDescriptor, MDArtifact}
|
||||
import core.module.descriptor.{DefaultDependencyDescriptor, DefaultModuleDescriptor, DependencyDescriptor, ModuleDescriptor}
|
||||
import core.module.descriptor.{DefaultExcludeRule, ExcludeRule}
|
||||
|
|
@ -396,6 +397,24 @@ object ManageDependencies
|
|||
private def addConfigurations(configurations: Iterable[String], to: { def setConfs(c: Array[String]): AnyRef }): Unit =
|
||||
to.setConfs(configurations.toList.toArray)
|
||||
|
||||
def install(ivyConfig: IvyConfiguration, from: String, to: String, validate: Boolean, overwrite: Boolean) =
|
||||
{
|
||||
def doInstall(ivy: Ivy, md: ModuleDescriptor, default: String) =
|
||||
Control.trapUnit("Could not install: ", ivyConfig.log)
|
||||
{
|
||||
for(dependency <- md.getDependencies)
|
||||
{
|
||||
ivyConfig.log.info("Installing " + dependency)
|
||||
val options = new InstallOptions
|
||||
options.setOverwrite(overwrite)
|
||||
options.setValidate(validate)
|
||||
options.setTransitive(dependency.isTransitive)
|
||||
ivy.install(dependency.getDependencyRevisionId, from, to, options)
|
||||
}
|
||||
None
|
||||
}
|
||||
withIvy(ivyConfig)(doInstall)
|
||||
}
|
||||
def deliver(ivyConfig: IvyConfiguration, updateConfig: UpdateConfiguration, status: String, deliverIvyPattern: String, extraDependencies: Iterable[ModuleID], configurations: Option[Iterable[Configuration]]) =
|
||||
{
|
||||
def doDeliver(ivy: Ivy, md: ModuleDescriptor, default: String) =
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ object Project
|
|||
if(builderProjectPath.asFile.isDirectory)
|
||||
{
|
||||
val pluginProjectPath = info.builderPath / PluginProjectDirectoryName
|
||||
val additionalPaths = additional match { case u: URLClassLoader => u.getURLs.map(url => Path.fromFile(FileUtilities.toFile(url))); case _ => Nil }
|
||||
val additionalPaths = additional match { case u: URLClassLoader => u.getURLs.map(url => Path.fromFile(FileUtilities.toFile(url))); case _ => Array[Path]() }
|
||||
val builderProject = new BuilderProject(ProjectInfo(builderProjectPath.asFile, Nil, None)(buildLog), pluginProjectPath, additionalPaths, buildLog)
|
||||
builderProject.compile.run.toLeft(()).right.flatMap { ignore =>
|
||||
builderProject.projectDefinition.right.map {
|
||||
|
|
|
|||
|
|
@ -113,14 +113,14 @@ trait ScalaProject extends SimpleScalaProject with FileTasks with MultiTaskProje
|
|||
val Private = Value("private")
|
||||
}
|
||||
|
||||
def javapTask(classpath: PathFinder, conditional: CompileConditional, outputPath: Path) =
|
||||
def javapTask(classpath: PathFinder, conditional: CompileConditional, compilePath: Path) =
|
||||
task { args =>
|
||||
val cp = classpath +++ Path.fromFile(FileUtilities.scalaLibraryJar) +++ Path.fromFile(FileUtilities.scalaCompilerJar)
|
||||
execOut { Process("javap" :: "-classpath" :: Path.makeString(cp.get) :: args.toList) }
|
||||
} completeWith(classNames(conditional, outputPath))
|
||||
private def classNames(conditional: CompileConditional, outputPath: Path) =
|
||||
} completeWith(classNames(conditional, compilePath))
|
||||
private def classNames(conditional: CompileConditional, compilePath: Path) =
|
||||
{
|
||||
val classes = conditional.analysis.allProducts.flatMap(Path.relativize(outputPath, _))
|
||||
val classes = conditional.analysis.allProducts.flatMap(Path.relativize(compilePath, _))
|
||||
classes.map(_.relativePath.replace(java.io.File.separatorChar, '.').toList.dropRight(".class".length).mkString).toSeq
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,12 +48,7 @@ private final class IvyLogger(log: Logger) extends MessageLogger
|
|||
def debug(msg: String) = logImpl(msg, Debug)
|
||||
def verbose(msg: String) = debug(msg)
|
||||
def deprecated(msg: String) = warn(msg)
|
||||
def info(msg: String) =
|
||||
{
|
||||
if(msg contains ":: loading settings :: url =")
|
||||
Thread.dumpStack
|
||||
logImpl(msg, Info)
|
||||
}
|
||||
def info(msg: String) = logImpl(msg, Info)
|
||||
def rawinfo(msg: String) = info(msg)
|
||||
def warn(msg: String) = logImpl(msg, Warn)
|
||||
def error(msg: String) = logImpl(msg, Error)
|
||||
|
|
|
|||
Loading…
Reference in New Issue