|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD |
org.gradle.api.publish.Publicationorg.gradle.api.publish.ivy.IvyPublication
org.gradle.api.Named
@Incubating @HasInternalProtocol public interface IvyPublication extends Publication
A IvyPublication is the representation/configuration of how Gradle should publish something in Ivy format, to an Ivy repository. You directly add a named Ivy Publication the project's publishing.publications container by providing IvyPublication as the type.
publishing { publications { myPublicationName(IvyPublication) { // Configure the publication here } } }
The Ivy module identifying attributes of the publication are mapped as follows:
For certain common use cases, it's often sufficient to specify the component to publish, using (from(org.gradle.api.component.SoftwareComponent). The published component is used to determine which artifacts to publish, and which configurations and dependencies should be listed in the generated ivy descriptor file.
You can add configurations to the generated ivy descriptor file, by supplying a Closure to the configurations(org.gradle.api.Action) method.
To add additional artifacts to the set published, use the artifact(Object) and artifact(Object, org.gradle.api.Action) methods. You can also completely replace the set of published artifacts using setArtifacts(Iterable). Together, these methods give you full control over the artifacts to be published.
For any other tweaks to the publication, it is possible to modify the generated Ivy descriptor file prior to publication. This is done using the IvyModuleDescriptor.withXml method, normally via a Closure passed to the descriptor(org.gradle.api.Action) method.
apply plugin: "java" apply plugin: "ivy-publish" task sourceJar(type: Jar) { from sourceSets.main.allJava } publishing { publications { myPublication(IvyPublication) { from components.java artifact(sourceJar) { type "source" extension "src.jar" conf "runtime" } descriptor.withXml { asNode().info[0].appendNode("description", "custom-description") } } } }
Method Summary | |
---|---|
IvyArtifact
|
artifact(Object source)
Creates a custom IvyArtifact to be included in the publication. |
IvyArtifact
|
artifact(Object source, Action config)
Creates an IvyArtifact to be included in the publication, which is configured by the associated action. |
void
|
configurations(Action config)
Defines some IvyConfigurations that should be included in the published ivy module descriptor file. |
void
|
descriptor(Action configure)
Configures the descriptor that will be published. |
void
|
from(SoftwareComponent component)
Provides the software component that should be published. |
IvyArtifactSet
|
getArtifacts()
The complete set of artifacts for this publication. |
IvyConfigurationContainer
|
getConfigurations()
Returns the complete set of configurations for this publication. |
IvyModuleDescriptor
|
getDescriptor()
The module descriptor that will be published. |
String
|
getModule()
Returns the module for this publication. |
String
|
getOrganisation()
Returns the organisation for this publication. |
String
|
getRevision()
Returns the revision for this publication. |
void
|
setArtifacts(Iterable sources)
Sets the artifacts for this publication. |
void
|
setModule(String module)
Sets the module for this publication. |
void
|
setOrganisation(String organisation)
Sets the organisation for this publication. |
void
|
setRevision(String revision)
Sets the revision for this publication. |
Methods inherited from interface Named | |
---|---|
getName |
Method Detail |
---|
public IvyArtifact artifact(Object source)
artifact
method can take a variety of input:
apply plugin: "ivy-publish" task sourceJar(type: Jar) { classifier "source" } task genDocs << { // Generate 'my-docs-file.htm' } publishing { publications { ivy(IvyPublication) { artifact sourceJar // Publish the output of the sourceJar task artifact 'my-file-name.jar' // Publish a file created outside of the build artifact source: 'my-docs-file.htm', classifier: 'docs', extension: 'html', builtBy: genDocs // Publish a file generated by the 'genDocs' task } } }
source
- The source of the artifact content.
public IvyArtifact artifact(Object source, Action config)
apply plugin: "ivy-publish" task sourceJar(type: Jar) { classifier "source" } task genDocs << { // Generate 'my-docs-file.htm' } publishing { publications { ivy(IvyPublication) { artifact(sourceJar) { // These values will be used instead of the values from the task. The task values will not be updated. classifier "src" extension "zip" conf "runtime->default" } artifact("my-docs-file.htm") { type "documentation" extension "html" builtBy genDocs } } } }
source
- The source of the artifact.config
- An action to configure the values of the constructed IvyArtifact.
public void configurations(Action config)
apply plugin: "java" apply plugin: "ivy-publish" publishing { publications { ivy(IvyPublication) { configurations { testCompile {} testRuntime { extend "testCompile" } } } } }
config
- An action or closure to configure the values of the constructed IvyConfiguration.
public void descriptor(Action configure)
The descriptor XML can be modified by using the IvyModuleDescriptor.withXml method.
configure
- The configuration action.
public void from(SoftwareComponent component)
apply plugin: "java" apply plugin: "ivy-publish" publishing { publications { ivy(IvyPublication) { from components.java } } }
component
- The software component to publish.
public IvyArtifactSet getArtifacts()
Setting this property will clear any previously added artifacts and create artifacts from the specified sources. Each supplied source is interpreted as per artifact(Object). For example, to exclude the dependencies declared by a component and instead use a custom set of artifacts:
apply plugin: "java" apply plugin: "ivy-publish" task sourceJar(type: Jar) { classifier "source" } publishing { publications { ivy(IvyPublication) { from components.java artifacts = ["my-custom-jar.jar", sourceJar] } } }
public IvyConfigurationContainer getConfigurations()
public IvyModuleDescriptor getDescriptor()
public String getModule()
public String getOrganisation()
public String getRevision()
public void setArtifacts(Iterable sources)
sources
- The set of artifacts for this publication.
public void setModule(String module)
public void setOrganisation(String organisation)
public void setRevision(String revision)
Gradle API 1.12