diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-04 02:55:14 +0000 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-04 20:43:13 -0500 |
commit | 4bd0255f0a39d87652c032533ce45eb65e8f3b1e (patch) | |
tree | 48704575b2b337feeeb457f7ab985fc5912e9c33 /stage2 | |
parent | 8d4d1b0f0b984ea39a92094e775e82bbb2bd9863 (diff) | |
download | cbt-4bd0255f0a39d87652c032533ce45eb65e8f3b1e.tar.gz cbt-4bd0255f0a39d87652c032533ce45eb65e8f3b1e.tar.bz2 cbt-4bd0255f0a39d87652c032533ce45eb65e8f3b1e.zip |
handle trying to package / publish with no source files via exception
this saves us from having to do conditionals in several places
Diffstat (limited to 'stage2')
-rw-r--r-- | stage2/BasicBuild.scala | 4 | ||||
-rw-r--r-- | stage2/Lib.scala | 23 | ||||
-rw-r--r-- | stage2/PackageJars.scala | 3 | ||||
-rw-r--r-- | stage2/Publish.scala | 4 |
4 files changed, 16 insertions, 18 deletions
diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala index 7d36445..b6a2870 100644 --- a/stage2/BasicBuild.scala +++ b/stage2/BasicBuild.scala @@ -94,6 +94,10 @@ trait BaseBuild extends BuildInterface with DependencyImplementation with Trigge /** Absolute path names for all individual files found in sources directly or contained in directories. */ final def sourceFiles: Seq[File] = lib.sourceFiles(sources, sourceFileFilter) + final def nonEmptySourceFiles: Seq[File] = + if(sourceFiles.nonEmpty) { + throw new RuntimeException( "no source files found" ) + } else sourceFiles protected def logEmptySourceDirectories(): Unit = { val nonExisting = diff --git a/stage2/Lib.scala b/stage2/Lib.scala index a0b6605..dbcd06f 100644 --- a/stage2/Lib.scala +++ b/stage2/Lib.scala @@ -429,23 +429,18 @@ final class Lib(val logger: Logger) extends Stage1Lib(logger){ } } - def publishLocal( sourceFiles: Seq[File], artifacts: Seq[File], mavenCache: File, releaseFolder: String ): Unit = { - if(sourceFiles.nonEmpty){ - val targetDir = mavenCache ++ releaseFolder.stripSuffix("/") - targetDir.mkdirs - artifacts.foreach{ a => - val target = targetDir ++ ("/" ++ a.getName) - System.err.println(blue("publishing ") ++ target.getPath) - Files.copy( a.toPath, target.toPath, StandardCopyOption.REPLACE_EXISTING ) - } + def publishLocal( artifacts: Seq[File], mavenCache: File, releaseFolder: String ): Unit = { + val targetDir = mavenCache ++ releaseFolder.stripSuffix("/") + targetDir.mkdirs + artifacts.foreach{ a => + val target = targetDir ++ ("/" ++ a.getName) + System.err.println(blue("publishing ") ++ target.getPath) + Files.copy( a.toPath, target.toPath, StandardCopyOption.REPLACE_EXISTING ) } } - def publishSigned( sourceFiles: Seq[File], artifacts: Seq[File], url: URL, credentials: Option[String] = None ): Unit = { - // TODO: make concurrency configurable here - if(sourceFiles.nonEmpty){ - publish( artifacts ++ artifacts.map(sign), url, credentials ) - } + def publishSigned( artifacts: Seq[File], url: URL, credentials: Option[String] = None ): Unit = { + publish( artifacts ++ artifacts.map(sign), url, credentials ) } private def publish(artifacts: Seq[File], url: URL, credentials: Option[String]): Unit = { diff --git a/stage2/PackageJars.scala b/stage2/PackageJars.scala index 7b6e844..910741d 100644 --- a/stage2/PackageJars.scala +++ b/stage2/PackageJars.scala @@ -10,7 +10,6 @@ trait PackageJars extends BaseBuild with ArtifactInfo{ Seq(() => jar, () => docJar, () => srcJar) )( _() ).flatten - def jarFilePrefix = artifactId++"_"++scalaMajorVersion++"-"++version def jar: Option[File] = taskCache[PackageJars]("jar").memoize{ @@ -19,7 +18,7 @@ trait PackageJars extends BaseBuild with ArtifactInfo{ def srcJar: Option[File] = taskCache[PackageJars]("srcJar").memoize{ lib.createJar( - jarTarget / jarFilePrefix++"-sources.jar", sourceFiles, Some(projectDirectory) + jarTarget / jarFilePrefix++"-sources.jar", nonEmptySourceFiles, Some(projectDirectory) ) } diff --git a/stage2/Publish.scala b/stage2/Publish.scala index a46e543..e80471f 100644 --- a/stage2/Publish.scala +++ b/stage2/Publish.scala @@ -15,12 +15,12 @@ trait PublishMaven extends PackageJars{ def organization: Option[Organization] // ========== publish ========== - private val releaseFolder = s"/${groupId.replace(".","/")}/${artifactId}_$scalaMajorVersion/$version/" + protected def releaseFolder = s"/${groupId.replace(".","/")}/${artifactId}_$scalaMajorVersion/$version" def publishedArtifacts = `package` :+ pom def publishLocal: Unit = lib.publishLocal( - sourceFiles, publishedArtifacts, context.paths.mavenCache, releaseFolder + publishedArtifacts, context.paths.mavenCache, releaseFolder ) // ========== package ========== |