Skip to content

Commit

Permalink
Merge pull request #442 from ethauvin/master
Browse files Browse the repository at this point in the history
Added support for configuring gpg's via local.properties
  • Loading branch information
cbeust authored May 8, 2017
2 parents 91bb1b9 + 3b56122 commit a95f8d9
Showing 1 changed file with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package com.beust.kobalt.maven

import com.beust.kobalt.OperatingSystem
import com.beust.kobalt.misc.LocalProperties
import com.beust.kobalt.misc.error
import com.beust.kobalt.misc.kobaltLog
import com.beust.kobalt.misc.warn
import com.google.inject.Inject
import com.google.inject.Singleton
import java.io.BufferedReader
import java.io.File
import java.io.InputStreamReader

@Singleton
class Gpg {
class Gpg @Inject constructor(val localProperties: LocalProperties) {
val COMMANDS = listOf("gpg", "gpg2")

fun findGpgCommand() : String? {
Expand Down Expand Up @@ -42,9 +44,30 @@ class Gpg {
ascFile.delete()
val allArgs = arrayListOf<String>()
allArgs.add(gpg)

val pwd = localProperties.getNoThrows("gpg.password")
if (! pwd.isNullOrBlank()) {
allArgs.add("--passphrase")
allArgs.add(pwd)
allArgs.add("--batch")
allArgs.add("--yes")
}

val keyId = localProperties.getNoThrows("gpg.keyId")
if (! keyId.isNullOrBlank()) {
allArgs.add("--local-user")
allArgs.add(keyId)
}

val keyRing = localProperties.getNoThrows("gpg.secretKeyRingFile")
if (! keyRing.isNullOrBlank()) {
allArgs.add("--secret-keyring")
allArgs.add("\"$keyRing\"")
}

allArgs.add("-ab")
allArgs.add(file.absolutePath)

val pb = ProcessBuilder(allArgs)
pb.directory(directory)
kobaltLog(2, "Signing file: " + allArgs.joinToString(" "))
Expand Down

0 comments on commit a95f8d9

Please sign in to comment.