Class SigningExtension
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The name of the configuration that all signature artifacts will be placed into ("signatures") -
Constructor Summary
ConstructorDescriptionSigningExtension
(Project project) Configures the signing settings for the given project. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Adds conventions to the given spec, using this settings object's default signatory and signature type as the default signatory and signature type for the spec.protected Object
addSignaturesToConfiguration
(Sign task, Configuration configuration) protected SignatoryProvider
Provides the signatory provider.protected SignatureTypeProvider
Provides the signature type provider.protected SignOperation
doSignOperation
(Closure setup) protected SignOperation
doSignOperation
(Action<SignOperation> setup) The configuration that signature artifacts are added to.protected Configuration
Provides the configuration that signature artifacts are added to.final Project
The signatory that will be used for signing when an explicit signatory has not been specified.The signature type that will be used for signing files when an explicit signature type has not been specified.boolean
Whether or not this task should fail if no signatory or signature type are configured at generation time.void
setConfiguration
(Configuration configuration) void
setRequired
(boolean required) Whether or not this task should fail if no signatory or signature type are configured at generation time.void
setRequired
(Object required) Whether or not this task should fail if no signatory or signature type are configured at generation time.void
setSignatories
(SignatoryProvider signatories) void
setSignatureTypes
(SignatureTypeProvider signatureTypes) Creates a newsign operation
using the given closure to configure it before executing it.Digitally signs the files, generating signature files alongside them.Digitally signs the files, generating signature files alongside them.sign
(Configuration... configurations) Creates signing tasks that signall of the artifacts
of the given configurations.sign
(PublishArtifact... publishArtifacts) Digitally signs the publish artifacts, generating signature files alongside them.Creates signing tasks that depend on and sign the "archive" produced by the given tasks.signatories
(Closure closure) Configures the signatory provider (delegating to itsconfigure method
).signPom
(MavenDeployment mavenDeployment) Signs the POM artifact for the given Maven deployment.signPom
(MavenDeployment mavenDeployment, Closure closure) Signs the POM artifact for the given Maven deployment.
-
Field Details
-
DEFAULT_CONFIGURATION_NAME
The name of the configuration that all signature artifacts will be placed into ("signatures")- See Also:
-
-
Constructor Details
-
SigningExtension
Configures the signing settings for the given project.
-
-
Method Details
-
getProject
-
setRequired
public void setRequired(boolean required) Whether or not this task should fail if no signatory or signature type are configured at generation time.- Since:
- 4.0
-
setRequired
Whether or not this task should fail if no signatory or signature type are configured at generation time. Ifrequired
is aCallable
, it will be stored and "called" on demand (i.e. whenisRequired()
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 aClosure
(which is aCallable
). For any other type, the value will be stored and evaluated on demand according to the Groovy Truth.signing { required = false }
-
isRequired
public boolean isRequired()Whether or not this task should fail if no signatory or signature type are configured at generation time.Defaults to
true
.- See Also:
-
getDefaultConfiguration
Provides the configuration that signature artifacts are added to. Called once during construction. -
createSignatureTypeProvider
Provides the signature type provider. Called once during construction. -
createSignatoryProvider
Provides the signatory provider. Called once during construction. -
signatories
Configures the signatory provider (delegating to itsconfigure method
).- Parameters:
closure
- the signatory provider configuration DSL- Returns:
- the configured signatory provider
-
getSignatory
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
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.
-
setSignatureTypes
-
getSignatureTypes
-
setSignatories
-
setConfiguration
-
getConfiguration
The configuration that signature artifacts are added to. -
addSignatureSpecConventions
Adds conventions to the given spec, using this settings object's default signatory and signature type as the default signatory and signature type for the spec. -
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
AbstractArchiveTask
, anInvalidUserDataException
will be thrown.The signature artifact for the created task is added to the
for this settings object
.- Parameters:
tasks
- The tasks whose archives are to be signed- Returns:
- the created tasks.
-
sign
Creates signing tasks that signall of the 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 artifact for the created task is added to the
for this settings object
.- Parameters:
configurations
- The configurations whose archives are to be signed- Returns:
- the created tasks.
-
addSignaturesToConfiguration
-
sign
Digitally signs the publish artifacts, generating signature files alongside them.The project's default signatory and default signature type from the
signing settings
will be used to generate the signature. The returnedsign operation
gives access to the created signature files.If there is no configured default signatory available, the sign operation will fail.
- Parameters:
publishArtifacts
- The publish artifacts to sign- Returns:
- The executed
sign operation
-
sign
Digitally signs the files, generating signature files alongside them.The project's default signatory and default signature type from the
signing settings
will be used to generate the signature. The returnedsign operation
gives access to the created signature files.If there is no configured default signatory available, the sign operation will fail.
- Parameters:
files
- The files to sign.- Returns:
- The executed
sign operation
.
-
sign
Digitally signs the files, generating signature files alongside them.The project's default signatory and default signature type from the
signing settings
will be used to generate the signature. The returnedsign operation
gives access to the created signature files.If there is no configured default signatory available, the sign operation will fail.
- Parameters:
classifier
- The classifier to assign to the created signature artifacts.files
- The publish artifacts to sign.- Returns:
- The executed
sign operation
.
-
sign
Creates a newsign operation
using the given closure to configure it before executing it.The project's default signatory and default signature type from the
signing settings
will be used to generate the signature. The returnedsign operation
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.
- Parameters:
closure
- The configuration of thesign operation
.- Returns:
- The executed
sign operation
.
-
signPom
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
sign operation
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.
- Parameters:
mavenDeployment
- The deployment to sign the POM ofclosure
- the configuration of the underlyingsign operation
for the POM (optional)- Returns:
- the generated signature artifact
-
signPom
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
sign operation
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.
- Parameters:
mavenDeployment
- The deployment to sign the POM of- Returns:
- the generated signature artifact
-
doSignOperation
-
doSignOperation
-
getSignatories
-