Fail publishing when artifacts to publish do not exist.

This commit is contained in:
Mark Harrah 2012-09-11 11:37:41 -04:00
parent 2010ae7b3c
commit b15fb72727
3 changed files with 26 additions and 2 deletions

View File

@ -251,9 +251,11 @@ object IvyActions
}
def publish(module: ModuleDescriptor, artifacts: Seq[(IArtifact, File)], resolver: DependencyResolver, overwrite: Boolean): Unit =
{
checkFilesPresent(artifacts)
try {
resolver.beginPublishTransaction(module.getModuleRevisionId(), overwrite);
for( (artifact, file) <- artifacts) if(file.exists)
for( (artifact, file) <- artifacts)
resolver.publish(artifact, file, overwrite)
resolver.commitPublishTransaction()
} catch {
@ -261,6 +263,12 @@ object IvyActions
try { resolver.abortPublishTransaction() }
finally { throw e }
}
}
private[this] def checkFilesPresent(artifacts: Seq[(IArtifact, File)])
{
val missing = artifacts filter { case (a, file) => !file.exists }
if(missing.nonEmpty)
error("Missing files for publishing:\n\t" + missing.map(_._2.getAbsolutePath).mkString("\n\t"))
}
}
final class ResolveException(val messages: Seq[String], val failed: Seq[ModuleID]) extends RuntimeException(messages.mkString("\n"))

View File

@ -0,0 +1,12 @@
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache")))
organization := "org.example"
name := "publish-missing-test"
autoScalaLibrary := false
addArtifact(
name { n => Artifact(n, "txt", "txt") },
baseDirectory map { _ / "topublish.txt" }
)

View File

@ -0,0 +1,4 @@
-> publish-local
$ touch topublish.txt
> publish-local