-
Notifications
You must be signed in to change notification settings - Fork 56
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
13 changed files
with
208 additions
and
76 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
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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package sbt | ||
package sbtpgp | ||
|
||
import sbt.{ librarymanagement => lm } | ||
import sbt.internal.{ librarymanagement => ilm } | ||
import Keys._ | ||
import com.jsuereth.sbtpgp.PgpKeys._ | ||
import com.jsuereth.sbtpgp.gpgExtension | ||
|
||
object Compat { | ||
val IvyActions = ilm.IvyActions | ||
type IvySbt = ilm.IvySbt | ||
type IvyScala = lm.ScalaModuleInfo | ||
type UpdateConfiguration = lm.UpdateConfiguration | ||
val defaultProgress = EvaluateTask.defaultProgress() | ||
type UnresolvedWarning = lm.UnresolvedWarning | ||
type UnresolvedWarningConfiguration = lm.UnresolvedWarningConfiguration | ||
val UnresolvedWarningConfiguration = lm.UnresolvedWarningConfiguration | ||
val CommandLineUIServices = sbt.CommandLineUIService | ||
type PublishConfiguration = lm.PublishConfiguration | ||
type ConfigRef = lm.ConfigRef | ||
val ConfigRef = lm.ConfigRef | ||
|
||
val ivyScala = Keys.scalaModuleInfo | ||
|
||
def pgpRequires: Plugins = sbt.plugins.IvyPlugin | ||
|
||
def subConfiguration(m: ModuleID, confs: Boolean): ModuleID = | ||
m.withConfigurations( | ||
if (confs) m.configurations | ||
else None | ||
) | ||
|
||
def subExplicitArtifacts(m: ModuleID, artifacts: Vector[Artifact]): ModuleID = | ||
m.withExplicitArtifacts(artifacts) | ||
|
||
def subExtension(art: Artifact, ext: String): Artifact = | ||
art.withExtension(ext) | ||
|
||
def subMissingOk(c: UpdateConfiguration, ok: Boolean): UpdateConfiguration = | ||
c.withMissingOk(ok) | ||
|
||
def mkInlineConfiguration( | ||
base: ModuleID, | ||
deps: Vector[ModuleID], | ||
ivyScala: Option[IvyScala], | ||
confs: Vector[Configuration] | ||
): InlineConfiguration = | ||
ModuleDescriptorConfiguration(base, ModuleInfo(base.name)) | ||
.withDependencies(deps) | ||
.withScalaModuleInfo(ivyScala) | ||
.withConfigurations(confs) | ||
|
||
def updateEither( | ||
module: IvySbt#Module, | ||
configuration: UpdateConfiguration, | ||
uwconfig: UnresolvedWarningConfiguration, | ||
logicalClock: LogicalClock, | ||
depDir: Option[File], | ||
log: Logger | ||
): Either[UnresolvedWarning, UpdateReport] = | ||
IvyActions.updateEither(module, configuration, uwconfig, log) | ||
|
||
val signedArtifacts = taskKey[Map[Artifact, xsbti.HashedVirtualFileRef]]( | ||
"Packages all artifacts for publishing and maps the Artifact definition to the generated file." | ||
) | ||
|
||
private val pgpMakeIvy = TaskKey[Option[File]]("pgpMakeIvy", "Generates the Ivy file.") | ||
|
||
def deliverPattern(outputPath: File): String = | ||
(outputPath / "[artifact]-[revision](-[classifier]).[ext]").absolutePath | ||
|
||
def signingSettings0: Seq[Setting[_]] = Seq( | ||
signedArtifacts := { | ||
val artifacts = packagedArtifacts.value | ||
val r = pgpSigner.value | ||
val skipZ = (pgpSigner / skip).value | ||
val s = streams.value | ||
if (!skipZ) { | ||
val c = fileConverter.value | ||
artifacts.flatMap { | ||
case (art, file) => | ||
val p = c.toPath(file) | ||
val signed = c.toVirtualFile( | ||
r.sign(p.toFile(), new File(p.toFile().getAbsolutePath + gpgExtension), s).toPath() | ||
) | ||
// r.sign(p.toFile(), new File(p.toFile().getAbsolutePath + gpgExtension) | ||
Seq( | ||
art -> file, | ||
subExtension(art, art.extension + gpgExtension) -> signed | ||
) | ||
} | ||
} else artifacts | ||
} | ||
) | ||
|
||
def toFile(vf: xsbti.HashedVirtualFileRef, c: xsbti.FileConverter): File = { | ||
c.toPath(vf).toFile() | ||
} | ||
} |
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
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,6 +1,6 @@ | ||
package com.jsuereth.sbtpgp | ||
|
||
import sbt._ | ||
import sbt.{ given, * } | ||
import sbt.sbtpgp.Compat._ | ||
|
||
/** | ||
|
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
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,4 +1,4 @@ | ||
> show pgpPassphrase | ||
> show pgpSigner | ||
> signedArtifacts | ||
$ exists target/scala-2.13/test_2.13-1.0.jar.asc | ||
> check |
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,11 +1,22 @@ | ||
lazy val root = (project in file(".")) | ||
.settings( | ||
credentials in GlobalScope := Seq(Credentials("", "pgp", "", "test password")), | ||
pgpSecretRing := baseDirectory.value / "secring.pgp", | ||
pgpPublicRing := baseDirectory.value / "pubring.pgp", | ||
scalaVersion := "2.13.2", | ||
name := "test", | ||
organization := "test", | ||
version := "1.0", | ||
skip in publish := true | ||
) | ||
Global / credentials := Seq(Credentials("", "pgp", "", "test password")) | ||
|
||
pgpSecretRing := baseDirectory.value / "secring.pgp" | ||
pgpPublicRing := baseDirectory.value / "pubring.pgp" | ||
scalaVersion := "2.13.2" | ||
name := "test" | ||
organization := "test" | ||
version := "1.0" | ||
publish / skip := true | ||
|
||
TaskKey[Unit]("check") := { | ||
val sbtV = sbtBinaryVersion.value | ||
if (sbtV == "1.0") { | ||
val x = target.value / "scala-2.13" / "test_2.13-1.0.jar.asc" | ||
assert(!x.exists()) | ||
} else { | ||
import xsbti.VirtualFileRef | ||
val conv = fileConverter.value | ||
val p = conv.toPath(VirtualFileRef.of("${OUT}/jvm/scala-2.13.2/test/test_2.13-1.0.jar.asc")) | ||
assert(!p.toFile.exists()) | ||
} | ||
} |
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,2 +1,2 @@ | ||
> publishSigned | ||
-$ exists target/scala-2.13/test_2.13-1.0.jar.asc | ||
> check |