Skip to content

Commit

Permalink
Fail publishing when artifacts to publish do not exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
harrah committed Sep 11, 2012
1 parent 2010ae7 commit b15fb72
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ivy/IvyActions.scala
Expand Up @@ -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.