-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
33 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// DO NOT EDIT. Generated by Gradle task "generateBuildKt" | ||
object Build { | ||
const val version = "0.3.0" | ||
const val version = "0.4.0" | ||
const val date = "2022-10-21" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,13 @@ | |
**/ | ||
|
||
import com.github.ajalt.clikt.core.* | ||
import com.github.ajalt.clikt.parameters.arguments.argument | ||
import com.github.ajalt.clikt.parameters.options.* | ||
import kotlinx.coroutines.runBlocking | ||
import maven.* | ||
import stages.build.* | ||
import stages.sign.* | ||
import stages.upload.* | ||
import tools.rethrowingState | ||
import java.nio.file.* | ||
import kotlin.io.path.absolute | ||
|
||
|
@@ -24,7 +24,7 @@ class Cli : NoOpCliktCommand( | |
init { | ||
versionOption(Build.version) { | ||
"$commandName $it (${Build.date})\n" + | ||
"MIT (c) Artsiom iG <[email protected]>\n" + | ||
"ISC (c) Artsiom iG <[email protected]>\n" + | ||
"http://github.com/rtmigo/mavence" | ||
} | ||
} | ||
|
@@ -41,24 +41,47 @@ private suspend fun gaa(): GroupArtifact { | |
|
||
data class CliConfig(val trace: Boolean) | ||
|
||
open class CheckCentral : CliktCommand( | ||
help = "Check that environment is set for publishing to Maven Central") { | ||
override fun run() = catchingCommand(this) { | ||
fun checkVar(k: String) = rethrowingState( | ||
{ "Environment variable $k is not set." }, | ||
{ check(System.getenv(k).isNotBlank()) }) | ||
checkVar(EnvVarNames.MAVEN_GPG_KEY) | ||
checkVar(EnvVarNames.MAVEN_GPG_PASSWORD) | ||
checkVar(EnvVarNames.SONATYPE_USERNAME) | ||
checkVar(EnvVarNames.SONATYPE_PASSWORD) | ||
System.err.println("At first glance, everything is OK.") | ||
} | ||
} | ||
|
||
open class Local(help: String = "Build, publish to $m2str") : CliktCommand(help = help) { | ||
override fun run() = catchingCommand(this) { | ||
cmdLocal(gaa(), isFinal = true) | ||
Unit | ||
} | ||
} | ||
|
||
object EnvVarNames { | ||
const val MAVEN_GPG_KEY = "MAVEN_GPG_KEY" | ||
const val MAVEN_GPG_PASSWORD = "MAVEN_GPG_PASSWORD" | ||
const val SONATYPE_USERNAME = "SONATYPE_USERNAME" | ||
const val SONATYPE_PASSWORD = "SONATYPE_PASSWORD" | ||
} | ||
|
||
|
||
|
||
open class Stage(help: String = "Build, sign, publish to OSSRH Staging") : | ||
Local(help = help) { | ||
val gpgKey by option("--gpg-key", envvar = "MAVEN_GPG_KEY").required() | ||
val gpgPwd by option("--gpg-password", envvar = "MAVEN_GPG_PASSWORD").required() | ||
val gpgKey by option("--gpg-key", envvar = EnvVarNames.MAVEN_GPG_KEY).required() | ||
val gpgPwd by option("--gpg-password", envvar = EnvVarNames.MAVEN_GPG_PASSWORD).required() | ||
|
||
protected val sonatypeUser by option( | ||
"--sonatype-username", | ||
envvar = "SONATYPE_USERNAME").required() | ||
envvar = EnvVarNames.SONATYPE_USERNAME).required() | ||
protected val sonatypePassword by option( | ||
"--sonatype-password", | ||
envvar = "SONATYPE_PASSWORD").required() | ||
envvar = EnvVarNames.SONATYPE_PASSWORD).required() | ||
|
||
override fun run() = catchingCommand(this) { | ||
cmdSign( | ||
|
@@ -102,13 +125,13 @@ fun catchingCommand(cmd: CliktCommand, block: suspend () -> Unit) { | |
e.printStackTrace() | ||
else | ||
System.err.println("ERROR: $e") | ||
System.err.println("Run with --trace to see full stack trace.") | ||
System.err.println("Run with --trace to see full stack trace.") | ||
} | ||
|
||
} | ||
|
||
fun main(args: Array<String>) { | ||
Cli() | ||
.subcommands(Local(), Stage(), Central()) | ||
.subcommands(Local(), Stage(), Central(), CheckCentral()) | ||
.main(args) | ||
} |