interface IvyPublication : 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:
module
- project.name
organisation
- project.group
revision
- project.version
status
- project.status
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.
In addition, IvyModuleDescriptorSpec provides configuration methods to customize licenses, authors, and the description to be published in the Ivy module descriptor.
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 IvyModuleDescriptorSpec#withXml(org.gradle.api.Action)
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 { license { name = "Custom License" } author { name = "Custom Name" } description { text = "Custom Description" } } } } }
Since
1.3
abstract fun artifact(source: Any): IvyArtifact
Creates a custom IvyArtifact to be included in the publication. The
abstract fun artifact(source: Any, config: Action<in IvyArtifact>): IvyArtifact
Creates an IvyArtifact to be included in the publication, which is configured by the associated action. The first parameter is used to create a custom artifact and add it to the publication, as per
|
|
abstract fun configurations(config: Action<in IvyConfigurationContainer>): Unit
Defines some IvyConfigurations that should be included in the published ivy module descriptor file. The following example demonstrates how to add a "testCompile" configuration, and a "testRuntime" configuration that extends it.
|
|
abstract fun descriptor(configure: Action<in IvyModuleDescriptorSpec>): Unit
Configures the descriptor that will be published. The descriptor XML can be modified by using the |
|
abstract fun from(component: SoftwareComponent): Unit
Provides the software component that should be published.
|
|
abstract fun getArtifacts(): IvyArtifactSet
The complete set of artifacts for this publication. Setting this property will clear any previously added artifacts and create artifacts from the specified sources. Each supplied source is interpreted as per
|
|
abstract fun getConfigurations(): IvyConfigurationContainer
Returns the complete set of configurations for this publication. |
|
abstract fun getDescriptor(): IvyModuleDescriptorSpec
The module descriptor that will be published. |
|
abstract fun getModule(): String
Returns the module for this publication. |
|
abstract fun getOrganisation(): String
Returns the organisation for this publication. |
|
abstract fun getRevision(): String
Returns the revision for this publication. |
|
abstract fun setArtifacts(sources: MutableIterable<*>): Unit
Sets the artifacts for this publication. Each supplied value is interpreted as per |
|
abstract fun setModule(module: String): Unit
Sets the module for this publication. |
|
abstract fun setOrganisation(organisation: String): Unit
Sets the organisation for this publication. |
|
abstract fun setRevision(revision: String): Unit
Sets the revision for this publication. |