Permalink
Browse files

Fail publishing when artifacts to publish do not exist.

  • Loading branch information...
1 parent 2010ae7 commit b15fb727272794cdf39dfba0d46b5f2a9850dc2c @harrah committed Sep 11, 2012
View
@@ -251,16 +251,24 @@ 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 {
case e =>
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"))
@@ -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

0 comments on commit b15fb72

Please sign in to comment.