api / org.gradle.plugins.signing / SigningExtension

SigningExtension

open class SigningExtension

The global signing configuration for a project.

Constructors

<init>

SigningExtension(project: Project)

Configures the signing settings for the given project.

Properties

DEFAULT_CONFIGURATION_NAME

static val DEFAULT_CONFIGURATION_NAME: String

The name of the configuration that all signature artifacts will be placed into ("signatures")

Functions

getConfiguration

open fun getConfiguration(): Configuration

The configuration that signature artifacts are added to.

getProject

fun getProject(): Project

getSignatories

open fun getSignatories(): SignatoryProvider<Signatory>

getSignatory

open fun getSignatory(): Signatory

The signatory that will be used for signing when an explicit signatory has not been specified.

Delegates to the signatory provider's default signatory.

getSignatureType

open fun getSignatureType(): SignatureType

The signature type that will be used for signing files when an explicit signature type has not been specified.

Delegates to the signature type provider's default type.

getSignatureTypes

open fun getSignatureTypes(): SignatureTypeProvider

isRequired

open fun isRequired(): Boolean

Whether or not this task should fail if no signatory or signature type are configured at generation time.

Defaults to true.

setConfiguration

open fun setConfiguration(configuration: Configuration): Unit

setRequired

open fun setRequired(required: Boolean): Unit

Whether or not this task should fail if no signatory or signature type are configured at generation time.

open fun setRequired(required: Any): Unit

Whether or not this task should fail if no signatory or signature type are configured at generation time. If required is a Callable, it will be stored and "called" on demand (i.e. when #isRequired() is called) and the return value will be interpreting according to the Groovy Truth. For example:

 signing { required = { gradle.taskGraph.hasTask("uploadArchives") } } 
Because the task graph is not known until Gradle starts executing, we must use defer the decision. We can do this via using a Closure (which is a Callable). For any other type, the value will be stored and evaluated on demand according to the Groovy Truth.
 signing { required = false } 

setSignatories

open fun setSignatories(signatories: SignatoryProvider<Signatory>): Unit

setSignatureTypes

open fun setSignatureTypes(signatureTypes: SignatureTypeProvider): Unit

sign

open fun sign(vararg tasks: Task): MutableList<Sign>

Creates signing tasks that depend on and sign the "archive" produced by the given tasks.

The created tasks will be named "sign<input task name capitalized>". That is, given a task with the name "jar" the created task will be named "signJar".

If the task is not an org.gradle.api.tasks.bundling.AbstractArchiveTask, an InvalidUserDataException will be thrown.

The signature artifact for the created task is added to the .

open fun sign(vararg configurations: Configuration): MutableList<Sign>

Creates signing tasks that sign all artifacts of the given configurations.

The created tasks will be named "sign<configuration name capitalized>". That is, given a configuration with the name "archives" the created task will be named "signArchives". The signature artifacts for the created tasks are added to the configuration for this settings object.

open fun sign(vararg publications: Publication): MutableList<Sign>

Creates signing tasks that sign all publishable artifacts of the given publications.

The created tasks will be named "sign<publication name capitalized>Publication". That is, given a publication with the name "mavenJava" the created task will be named "signMavenJavaPublication". The signature artifacts for the created tasks are added to the publishable artifacts of the given publications.

open fun sign(publications: DomainObjectCollection<Publication>): MutableList<Sign>

Creates signing tasks that sign all publishable artifacts of the given publication collection.

The created tasks will be named "sign<publication name capitalized>Publication". That is, given a publication with the name "mavenJava" the created task will be named "signMavenJavaPublication". The signature artifacts for the created tasks are added to the publishable artifacts of the given publications.

open fun sign(vararg publishArtifacts: PublishArtifact): SignOperation

Digitally signs the publish artifacts, generating signature files alongside them.

The project's default signatory and default signature type from the SigningExtension will be used to generate the signature. The returned SignOperation gives access to the created signature files.

If there is no configured default signatory available, the sign operation will fail.

open fun sign(vararg files: File): SignOperation
open fun sign(classifier: String, vararg files: File): SignOperation

Digitally signs the files, generating signature files alongside them.

The project's default signatory and default signature type from the SigningExtension will be used to generate the signature. The returned SignOperation gives access to the created signature files.

If there is no configured default signatory available, the sign operation will fail.

open fun sign(closure: Closure<Any>): SignOperation

Creates a new SignOperation using the given closure to configure it before executing it.

The project's default signatory and default signature type from the SigningExtension will be used to generate the signature. The returned SignOperation gives access to the created signature files.

If there is no configured default signatory available (and one is not explicitly specified in this operation's configuration), the sign operation will fail.

signPom

open fun signPom(mavenDeployment: MavenDeployment, closure: Closure<Any>): Signature
open fun signPom(mavenDeployment: MavenDeployment): Signature

Signs the POM artifact for the given Maven deployment.

You can use this method to sign the generated POM when publishing to a Maven repository with the Maven plugin.

 uploadArchives { repositories { mavenDeployer { beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } } } } 

You can optionally provide a configuration closure to fine tune the SignOperation for the POM.

If #isRequired() is false and the signature cannot be generated (e.g. no configured signatory), this method will silently do nothing. That is, a signature for the POM file will not be uploaded.

Note: Signing the generated POM file generated by the Maven Publishing plugin is currently not supported. Future versions of Gradle might add this functionality.

signatories

open fun signatories(closure: Closure<Any>): SignatoryProvider<Signatory>

Configures the signatory provider (delegating to its configure method).

useGpgCmd

open fun useGpgCmd(): Unit

Use GnuPG agent to perform signing work.

Extension Properties

ext

val SigningExtension.ext: ExtraPropertiesExtension

Retrieves the ext extension.

Extension Functions

ext

fun SigningExtension.ext(configure: ExtraPropertiesExtension.() -> Unit): Unit

Configures the ext extension.