diff options
Diffstat (limited to 'stage2')
-rw-r--r-- | stage2/BasicBuild.scala | 11 | ||||
-rw-r--r-- | stage2/BuildBuild.scala | 1 | ||||
-rw-r--r-- | stage2/Lib.scala | 13 | ||||
-rw-r--r-- | stage2/PackageJars.scala | 1 | ||||
-rw-r--r-- | stage2/Publish.scala | 34 |
5 files changed, 23 insertions, 37 deletions
diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala index bcc3646..98deddc 100644 --- a/stage2/BasicBuild.scala +++ b/stage2/BasicBuild.scala @@ -136,8 +136,15 @@ trait BaseBuild extends DependencyImplementation with BuildInterface with Trigge ) } - def runClass: String = "Main" - def run: ExitCode = lib.runMainIfFound( runClass, context.args, classLoader(context.classLoaderCache) ) + + def mainClasses: Seq[Class[_]] = compile.toSeq.flatMap( lib.mainClasses( _, classLoader(classLoaderCache) ) ) + + def runClass: Option[String] = lib.runClass( mainClasses ).map( _.getName ) + + def run: ExitCode = runClass.map( lib.runMain( _, context.args, classLoader(context.classLoaderCache) ) ).getOrElse{ + logger.task( "No main class found for " ++ projectDirectory.string ) + ExitCode.Success + } def clean = { lib.clean( diff --git a/stage2/BuildBuild.scala b/stage2/BuildBuild.scala index f444803..b183745 100644 --- a/stage2/BuildBuild.scala +++ b/stage2/BuildBuild.scala @@ -15,6 +15,7 @@ trait BuildBuild extends BaseBuild{ final lazy val scalafmt = DirectoryDependency( managedContext.cbtHome ++ "/plugins/scalafmt" ) final lazy val wartremover = DirectoryDependency( managedContext.cbtHome ++ "/plugins/wartremover" ) final lazy val uberJar = DirectoryDependency( managedContext.cbtHome ++ "/plugins/uber-jar" ) + final lazy val sonatypeRelease = DirectoryDependency( managedContext.cbtHome ++ "/plugins/sonatype-release" ) } override def dependencies = diff --git a/stage2/Lib.scala b/stage2/Lib.scala index 46fecf7..25183a3 100644 --- a/stage2/Lib.scala +++ b/stage2/Lib.scala @@ -201,7 +201,7 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ def consoleOrFail(msg: String) = { Option(System.console).getOrElse( - throw new Exception(msg + ". java.io.Console == null. See https://github.com/cvogt/cbt/issues/236") + throw new Exception(msg + ". System.console() == null. See https://github.com/cvogt/cbt/issues/236") ) } @@ -272,6 +272,7 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ } yield file } + // FIXME: for some reason it includes full path in docs def jarFile( jarFile: File, files: Seq[File], mainClass: Option[String] = None ): Option[File] = { Files.deleteIfExists(jarFile.toPath) if( files.isEmpty ){ @@ -430,11 +431,9 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ } } - def publishSigned( sourceFiles: Seq[File], artifacts: Seq[File], url: URL, credentials: Option[String] = None ): Unit = { + def publishSigned( 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 ) - } + publish( artifacts ++ artifacts.map(sign), url, credentials ) } private def publish(artifacts: Seq[File], url: URL, credentials: Option[String]): Unit = { @@ -450,12 +449,12 @@ final class Lib(logger: Logger) extends Stage1Lib(logger) with Scaffold{ } def uploadAll(url: URL, nameAndContents: Seq[(String, Array[Byte])], credentials: Option[String] = None ): Unit = - nameAndContents.map{ case(name, content) => upload(name, content, url, credentials ) } + nameAndContents.foreach { case (name, content) => upload(name, content, url, credentials ) } def upload(fileName: String, fileContents: Array[Byte], baseUrl: URL, credentials: Option[String] = None): Unit = { import java.net._ import java.io._ - val url = baseUrl ++ fileName + val url = baseUrl ++ "/" ++ fileName System.err.println(blue("uploading ") ++ url.toString) val httpCon = Stage0Lib.openConnectionConsideringProxy(url) httpCon.setDoOutput(true) diff --git a/stage2/PackageJars.scala b/stage2/PackageJars.scala index 10e4c3a..a101993 100644 --- a/stage2/PackageJars.scala +++ b/stage2/PackageJars.scala @@ -1,5 +1,6 @@ package cbt import java.io.File + // would love to call this just `Package` but that conflicts with scala package objects. trait PackageJars extends BaseBuild with ArtifactInfo{ def name: String diff --git a/stage2/Publish.scala b/stage2/Publish.scala index 96e856b..7e00620 100644 --- a/stage2/Publish.scala +++ b/stage2/Publish.scala @@ -35,37 +35,15 @@ trait Publish extends PackageJars{ ) // ========== publish ========== - final protected val releaseFolder = s"/${groupId.replace(".","/")}/${artifactId}_$scalaMajorVersion/$version/" - private def snapshotUrl = new URL("https://oss.sonatype.org/content/repositories/snapshots") - private def releaseUrl = new URL("https://oss.sonatype.org/service/local/staging/deploy/maven2") - def publishUrl = if(version.endsWith("-SNAPSHOT")) snapshotUrl else releaseUrl - override def copy(context: Context) = super.copy(context).asInstanceOf[Publish] - - protected def sonatypeCredentials: Option[String] = { - // FIXME: this should probably not use cbtHome, but some reference to the system's host cbt - Some(new String(readAllBytes((context.cbtRootHome ++ "/sonatype.login").toPath)).trim) - } - - def publishSnapshot: Unit = { - copy( context.copy(version = Some(version+"-SNAPSHOT")) ).publishUnsigned - } + private val releaseFolder = s"/${groupId.replace(".","/")}/${artifactId}_$scalaMajorVersion/$version/" - def publishLocal: Unit = { + def publishLocal: Unit = lib.publishLocal( sourceFiles, `package` :+ pom, context.paths.mavenCache, releaseFolder ) - } - def publishSnapshotLocal: Unit = { + def publishSnapshotLocal: Unit = copy( context.copy(version = Some(version+"-SNAPSHOT")) ).publishLocal - } - def publishUnsigned: Unit = { - lib.publishUnsigned( - sourceFiles, `package` :+ pom, publishUrl ++ releaseFolder, sonatypeCredentials - ) - } - def publishSigned: Unit = { - lib.publishSigned( - sourceFiles, `package` :+ pom, publishUrl ++ releaseFolder, sonatypeCredentials - ) - } + def isSnapshot: Boolean = version.endsWith("-SNAPSHOT") + + override def copy(context: Context) = super.copy(context).asInstanceOf[Publish] } |