public class SigningExtension extends GroovyObjectSupport
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_CONFIGURATION_NAME
The name of the configuration that all signature artifacts will be placed into ("signatures")
|
Constructor and Description |
---|
SigningExtension(Project project)
Configures the signing settings for the given project.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addSignatureSpecConventions(SignatureSpec spec)
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(org.gradle.plugins.signing.Sign task,
Configuration configuration) |
protected SignatoryProvider |
createSignatoryProvider()
Provides the signatory provider.
|
protected SignatureTypeProvider |
createSignatureTypeProvider()
Provides the signature type provider.
|
protected SignOperation |
doSignOperation(Action<SignOperation> setup) |
protected SignOperation |
doSignOperation(Closure setup) |
Configuration |
getConfiguration()
The configuration that signature artifacts are added to.
|
static String |
getDEFAULT_CONFIGURATION_NAME() |
protected Configuration |
getDefaultConfiguration()
Provides the configuration that signature artifacts are added to.
|
Project |
getProject() |
SignatoryProvider |
getSignatories() |
Signatory |
getSignatory()
The signatory that will be used for signing when an explicit signatory has not been specified.
|
SignatureType |
getSignatureType()
The signature type that will be used for signing files when an explicit signature type has not been specified.
|
SignatureTypeProvider |
getSignatureTypes() |
boolean |
isRequired()
Whether or not this task should fail if no signatory or signature type are configured at generation time.
|
void |
setConfiguration(Configuration configuration) |
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) |
SignOperation |
sign(Closure closure)
Creates a new
sign operation using the given closure to configure it before executing it. |
List<org.gradle.plugins.signing.Sign> |
sign(Configuration... configurations)
Creates signing tasks that sign
all of the artifacts of the given configurations. |
SignOperation |
sign(File... files)
Digitally signs the files, generating signature files alongside them.
|
SignOperation |
sign(PublishArtifact... publishArtifacts)
Digitally signs the publish artifacts, generating signature files alongside them.
|
SignOperation |
sign(String classifier,
File... files)
Digitally signs the files, generating signature files alongside them.
|
List<org.gradle.plugins.signing.Sign> |
sign(Task... tasks)
Creates signing tasks that depend on and sign the "archive" produced by the given tasks.
|
SignatoryProvider |
signatories(Closure closure)
Configures the signatory provider (delegating to its
configure method ). |
Signature |
signPom(MavenDeployment mavenDeployment)
Signs the POM artifact for the given Maven deployment.
|
Signature |
signPom(MavenDeployment mavenDeployment,
Closure closure)
Signs the POM artifact for the given Maven deployment.
|
getMetaClass, getProperty, invokeMethod, setMetaClass, setProperty
public static final String DEFAULT_CONFIGURATION_NAME
public SigningExtension(Project project)
public final Project getProject()
public void setRequired(Object required)
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 }
public boolean isRequired()
Defaults to true
.
setRequired(Object)
protected Configuration getDefaultConfiguration()
protected SignatureTypeProvider createSignatureTypeProvider()
protected SignatoryProvider createSignatoryProvider()
public SignatoryProvider signatories(Closure closure)
configure method
).closure
- the signatory provider configuration DSLpublic Signatory getSignatory()
Delegates to the signatory provider's default signatory.
public SignatureType getSignatureType()
Delegates to the signature type provider's default type.
public void setSignatureTypes(SignatureTypeProvider signatureTypes)
public SignatureTypeProvider getSignatureTypes()
public void setSignatories(SignatoryProvider signatories)
public void setConfiguration(Configuration configuration)
public Configuration getConfiguration()
protected void addSignatureSpecConventions(SignatureSpec spec)
public List<org.gradle.plugins.signing.Sign> sign(Task... 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
, an InvalidUserDataException
will be thrown.
The signature artifact for the created task is added to the for this settings object
.
tasks
- The tasks whose archives are to be signedpublic List<org.gradle.plugins.signing.Sign> sign(Configuration... configurations)
all 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
.
configurations
- The configurations whose archives are to be signedprotected Object addSignaturesToConfiguration(org.gradle.plugins.signing.Sign task, Configuration configuration)
public SignOperation sign(PublishArtifact... publishArtifacts)
The project's default signatory and default signature type from the signing settings
will be used to generate the signature. The returned sign
operation
gives access to the created signature files.
If there is no configured default signatory available, the sign operation will fail.
publishArtifacts
- The publish artifacts to signsign operation
public SignOperation sign(File... files)
The project's default signatory and default signature type from the signing settings
will be used to generate the signature. The returned sign
operation
gives access to the created signature files.
If there is no configured default signatory available, the sign operation will fail.
files
- The files to sign.sign operation
.public SignOperation sign(String classifier, File... files)
The project's default signatory and default signature type from the signing settings
will be used to generate the signature. The returned sign
operation
gives access to the created signature files.
If there is no configured default signatory available, the sign operation will fail.
classifier
- The classifier to assign to the created signature artifacts.files
- The publish artifacts to sign.sign operation
.public SignOperation sign(Closure closure)
sign 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 returned sign
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.
closure
- The configuration of the sign operation
.sign operation
.public Signature signPom(MavenDeployment mavenDeployment, Closure closure)
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.
mavenDeployment
- The deployment to sign the POM ofclosure
- the configuration of the underlying sign operation
for the POM (optional)public Signature signPom(MavenDeployment mavenDeployment)
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.
mavenDeployment
- The deployment to sign the POM ofprotected SignOperation doSignOperation(Closure setup)
protected SignOperation doSignOperation(Action<SignOperation> setup)
public SignatoryProvider getSignatories()
public static String getDEFAULT_CONFIGURATION_NAME()