Interface IvyPublication
- All Superinterfaces:
- Named,- Publication
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.
 
 // Example of publishing a java component with an added source jar and custom module description
 plugins {
     id 'java'
     id '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
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.gradle.api.NamedNamed.Namer
- 
Method SummaryModifier and TypeMethodDescriptionCreates a customIvyArtifactto be included in the publication.artifact(Object source, Action<? super IvyArtifact> config) Creates anIvyArtifactto be included in the publication, which is configured by the associated action.voidconfigurations(Action<? super IvyConfigurationContainer> config) Defines someIvyConfigurations that should be included in the published ivy module descriptor file.voiddescriptor(Action<? super IvyModuleDescriptorSpec> configure) Configures the descriptor that will be published.voidfrom(SoftwareComponent component) Provides the software component that should be published.The complete set of artifacts for this publication.Returns the complete set of configurations for this publication.The module descriptor that will be published.Returns the module for this publication.Returns the organisation for this publication.Returns the revision for this publication.voidsetArtifacts(Iterable<?> sources) Sets the artifacts for this publication.voidSets the module for this publication.voidsetOrganisation(String organisation) Sets the organisation for this publication.voidsetRevision(String revision) Sets the revision for this publication.voidSilences all the compatibility warnings for the Ivy publication.voidsuppressIvyMetadataWarningsFor(String variantName) Silences the compatibility warnings for the Ivy publication for the specified variant.voidversionMapping(Action<? super VersionMappingStrategy> configureAction) Configures the version mapping strategy.Methods inherited from interface org.gradle.api.publish.PublicationwithBuildIdentifier, withoutBuildIdentifier
- 
Method Details- 
getDescriptorIvyModuleDescriptorSpec getDescriptor()The module descriptor that will be published.- Returns:
- The module descriptor that will be published.
 
- 
descriptorConfigures the descriptor that will be published.The descriptor XML can be modified by using the IvyModuleDescriptorSpec.withXml(org.gradle.api.Action)method.- Parameters:
- configure- The configuration action.
 
- 
fromProvides the software component that should be published.- Any artifacts declared by the component will be included in the publication.
- The dependencies declared by the component will be included in the published meta-data.
 plugins { id 'java' id 'ivy-publish' } publishing { publications { ivy(IvyPublication) { from components.java } } }- Parameters:
- component- The software component to publish.
 
- 
configurationsDefines someIvyConfigurations 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.plugins { id 'java' id 'ivy-publish' } publishing { publications { ivy(IvyPublication) { configurations { testCompile {} testRuntime { extend "testCompile" } } } } }- Parameters:
- config- An action or closure to configure the values of the constructed- IvyConfiguration.
 
- 
getConfigurationsIvyConfigurationContainer getConfigurations()Returns the complete set of configurations for this publication.- Returns:
- the configurations
 
- 
artifactCreates a customIvyArtifactto be included in the publication. Theartifactmethod can take a variety of input:- A PublishArtifactinstance. Name, type, extension and classifier values are taken from the supplied instance.
- An AbstractArchiveTaskinstance. Name, type, extension and classifier values are taken from the supplied instance.
- Anything that can be resolved to a Filevia theProject.file(Object)method. Name, extension and classifier values are interpolated from the file name.
- A Mapthat contains a 'source' entry that can be resolved as any of the other input types, including file. This map can contain additional attributes to further configure the constructed artifact.
 plugins { id 'ivy-publish' } task sourceJar(type: Jar) { archiveClassifier = "source" } task genDocs { doLast { // 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 } } }- Parameters:
- source- The source of the artifact content.
 
- A 
- 
artifactCreates anIvyArtifactto 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 perartifact(Object). The createdIvyArtifactis then configured using the supplied action. This method also accepts the configure action as a closure argument, by type coercion.plugins { id 'ivy-publish' } task sourceJar(type: Jar) { archiveClassifier = "source" } task genDocs { doLast { // 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 } } } }- Parameters:
- source- The source of the artifact.
- config- An action to configure the values of the constructed- IvyArtifact.
 
- 
getArtifactsIvyArtifactSet getArtifacts()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 artifact(Object). For example, to exclude the dependencies declared by a component and instead use a custom set of artifacts:plugins { id 'java' id 'ivy-publish' } task sourceJar(type: Jar) { archiveClassifier = "source" } publishing { publications { ivy(IvyPublication) { from components.java artifacts = ["my-custom-jar.jar", sourceJar] } } }- Returns:
- the artifacts.
 
- 
setArtifactsSets the artifacts for this publication. Each supplied value is interpreted as perartifact(Object).- Parameters:
- sources- The set of artifacts for this publication.
 
- 
getOrganisationString getOrganisation()Returns the organisation for this publication.
- 
setOrganisationSets the organisation for this publication.
- 
getModuleString getModule()Returns the module for this publication.
- 
setModuleSets the module for this publication.
- 
getRevisionString getRevision()Returns the revision for this publication.
- 
setRevisionSets the revision for this publication.
- 
versionMappingConfigures the version mapping strategy. For example, to use resolved versions for runtime dependencies:plugins { id 'java' id 'ivy-publish' } publishing { publications { maven(IvyPublication) { from components.java versionMapping { usage('java-runtime'){ fromResolutionResult() } } } } }- Parameters:
- configureAction- the configuration
- Since:
- 5.4
 
- 
suppressIvyMetadataWarningsForSilences the compatibility warnings for the Ivy publication for the specified variant. Warnings are emitted when Gradle features are used that cannot be mapped completely to Ivy xml.- Parameters:
- variantName- the variant to silence warning for
- Since:
- 6.0
 
- 
suppressAllIvyMetadataWarningsvoid suppressAllIvyMetadataWarnings()Silences all the compatibility warnings for the Ivy publication. Warnings are emitted when Gradle features are used that cannot be mapped completely to Ivy xml.- Since:
- 6.0
 
 
-