mirror of https://github.com/sbt/sbt.git
Fail publishing when artifacts to publish do not exist.
This commit is contained in:
parent
2010ae7b3c
commit
b15fb72727
|
|
@ -251,9 +251,11 @@ object IvyActions
|
||||||
}
|
}
|
||||||
|
|
||||||
def publish(module: ModuleDescriptor, artifacts: Seq[(IArtifact, File)], resolver: DependencyResolver, overwrite: Boolean): Unit =
|
def publish(module: ModuleDescriptor, artifacts: Seq[(IArtifact, File)], resolver: DependencyResolver, overwrite: Boolean): Unit =
|
||||||
|
{
|
||||||
|
checkFilesPresent(artifacts)
|
||||||
try {
|
try {
|
||||||
resolver.beginPublishTransaction(module.getModuleRevisionId(), overwrite);
|
resolver.beginPublishTransaction(module.getModuleRevisionId(), overwrite);
|
||||||
for( (artifact, file) <- artifacts) if(file.exists)
|
for( (artifact, file) <- artifacts)
|
||||||
resolver.publish(artifact, file, overwrite)
|
resolver.publish(artifact, file, overwrite)
|
||||||
resolver.commitPublishTransaction()
|
resolver.commitPublishTransaction()
|
||||||
} catch {
|
} catch {
|
||||||
|
|
@ -261,6 +263,12 @@ object IvyActions
|
||||||
try { resolver.abortPublishTransaction() }
|
try { resolver.abortPublishTransaction() }
|
||||||
finally { throw e }
|
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"))
|
final class ResolveException(val messages: Seq[String], val failed: Seq[ModuleID]) extends RuntimeException(messages.mkString("\n"))
|
||||||
|
|
|
||||||
|
|
@ -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" }
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
-> publish-local
|
||||||
|
|
||||||
|
$ touch topublish.txt
|
||||||
|
> publish-local
|
||||||
Loading…
Reference in New Issue