public class Signature
extends org.gradle.api.internal.artifacts.publish.AbstractPublishArtifact
A signature file is always generated from another file, which may be a PublishArtifact
.
Constructor and Description |
---|
Signature(Callable<File> toSign,
Callable<String> classifier,
SignatureSpec signatureSpec,
Object... tasks)
Creates a signature artifact for the file returned by the
toSign closure. |
Signature(Closure<File> toSign,
Closure<String> classifier,
SignatureSpec signatureSpec,
Object... tasks)
Creates a signature artifact for the file returned by the
toSign closure. |
Signature(File toSign,
SignatureSpec signatureSpec,
Object... tasks)
Creates a signature artifact for the given file.
|
Signature(File toSign,
String classifier,
SignatureSpec signatureSpec,
Object... tasks)
Creates a signature artifact for the given file, with the given classifier.
|
Signature(PublishArtifact toSign,
SignatureSpec signatureSpec,
Object... tasks)
Creates a signature artifact for the given public artifact.
|
Modifier and Type | Method and Description |
---|---|
void |
generate()
Generates the signature file.
|
String |
getClassifier()
The classifier of the signature artifact.
|
Date |
getDate()
The date of the signature artifact.
|
String |
getExtension()
The extension of the signature artifact.
|
File |
getFile()
The file for the generated signature, which may not yet exist.
|
String |
getName()
The name of the signature artifact.
|
Signatory |
getSignatory()
The signatory of this signature file.
|
SignatureSpec |
getSignatureSpec() |
SignatureType |
getSignatureType()
The file representation type of the signature.
|
File |
getToSign()
The file that is to be signed.
|
PublishArtifact |
getToSignArtifact() |
String |
getType()
The type of the signature artifact.
|
void |
setClassifier(String classifier) |
void |
setDate(Date date) |
void |
setExtension(String extension) |
void |
setFile(File file) |
void |
setName(String name) |
void |
setSignatureSpec(SignatureSpec signatureSpec) |
void |
setType(String type) |
public Signature(PublishArtifact toSign, SignatureSpec signatureSpec, Object... tasks)
The file to sign will be the file of the given artifact and the classifier of this signature artifact will default to the classifier of the given artifact to sign.
The artifact to sign may change after being used as the source for this signature.
toSign
- The artifact that is to be signedsignatureSpec
- The specification of how the artifact is to be signedtasks
- The task(s) that will invoke generate()
on this signature (optional)public Signature(File toSign, SignatureSpec signatureSpec, Object... tasks)
toSign
- The file that is to be signedsignatureSpec
- The specification of how the artifact is to be signedtasks
- The task(s) that will invoke generate()
on this signature (optional)public Signature(File toSign, String classifier, SignatureSpec signatureSpec, Object... tasks)
toSign
- The file that is to be signedclassifier
- The classifier to assign to the signature (should match the files)signatureSpec
- The specification of how the artifact is to be signedtasks
- The task(s) that will invoke generate()
on this signature (optional)public Signature(Closure<File> toSign, Closure<String> classifier, SignatureSpec signatureSpec, Object... tasks)
toSign
closure.
The closures will be “evaluated” on demand whenever the value is needed (e.g. at generation time)
toSign
- A closure that produces a File for the object to sign (non File return values will be used as the path to the file)classifier
- A closure that produces the classifier to assign to the signature artifact on demandsignatureSpec
- The specification of how the artifact is to be signedtasks
- The task(s) that will invoke generate()
on this signature (optional)public Signature(Callable<File> toSign, Callable<String> classifier, SignatureSpec signatureSpec, Object... tasks)
toSign
closure.
The closures will be “evaluated” on demand whenever the value is needed (e.g. at generation time)
toSign
- A closure that produces a File for the object to sign (non File return values will be used as the path to the file)classifier
- A closure that produces the classifier to assign to the signature artifact on demandsignatureSpec
- The specification of how the artifact is to be signedtasks
- The task(s) that will invoke generate()
on this signature (optional)public File getToSign()
null
if unknown at this time.public void setName(String name)
public String getName()
Defaults to the name of the signature file
.
null
if unknown at this time.public void setExtension(String extension)
public String getExtension()
Defaults to the specified file extension of the signature type
.
null
if unknown at this time.public void setType(String type)
public String getType()
Defaults to the extension of the file to sign
plus the extension of the signature type
. For example, when signing the file ‘my.zip’ with a
signature type with extension ‘sig’, the default type is ‘zip.sig’.
null
if the file to sign or signature type are unknown at this time.public void setClassifier(String classifier)
public String getClassifier()
Defaults to the classifier of the source artifact (if signing an artifact) or the given classifier at construction (if given).
null
if unknown at this time.public void setDate(Date date)
public Date getDate()
Defaults to the last modified time of the signature file
(if exists)
null
if unknown at this time.public void setFile(File file)
public File getFile()
Defaults to a file alongside the file to sign
with the extension of the signature type
.
null
if unknown at this time.public Signatory getSignatory()
null
if unknown at this time.public SignatureType getSignatureType()
null
if unknown at this time.public void setSignatureSpec(SignatureSpec signatureSpec)
public SignatureSpec getSignatureSpec()
public final PublishArtifact getToSignArtifact()
public void generate()
In order to generate the signature, the file to sign
, signatory
and signature type
must be known (i.e. non null
).
InvalidUserDataException
- if the there is insufficient information available to generate the signature.