Groovy Documentation

org.gradle.api.publish
[Java] Interface PublicationContainer

org.gradle.api.NamedDomainObjectSet
  org.gradle.api.DomainObjectCollection
      java.util.Collection
          org.gradle.api.NamedDomainObjectCollection
              org.gradle.api.publish.PublicationContainer
                  java.lang.Iterable
All Superinterfaces:
NamedDomainObjectSet, DomainObjectCollection, Collection, NamedDomainObjectCollection, Iterable

@Incubating
public interface PublicationContainer
extends NamedDomainObjectSet

A PublicationContainer is responsible for creating and managing Publication instances. The set of available publication types is dependent on the application of particular plugins:

See the documentation for PublishingExtension.publications for more examples of how to create and configure publications.
See Also:
Publication
PublishingExtension
Since:
1.3


Method Summary
Object add(String name, Class type)

Creates a publication with the specified name and type, adding it to the container.

Object add(String name, Class type, Action configuration)

Creates a publication with the specified name and type, adding it to the container and configuring it with the supplied action.

 
Methods inherited from interface NamedDomainObjectSet
findAll, matching, matching, withType
 
Methods inherited from interface NamedDomainObjectCollection
add, addAll, addRule, addRule, findByName, getAsMap, getAt, getByName, getByName, getNamer, getRules, matching, matching, withType
 
Methods inherited from interface Set
add, remove, equals, hashCode, clear, isEmpty, contains, size, toArray, toArray, iterator, spliterator, addAll, containsAll, removeAll, retainAll, stream, removeIf, parallelStream, forEach
 

Method Detail

add

public Object add(String name, Class type)
Creates a publication with the specified name and type, adding it to the container.
 apply plugin: 'maven-publish'

 publishing.publications.add('publication-name', MavenPublication)
 
throws:
InvalidUserDataException If type is not a valid publication type, or if a publication named "name" already exists.
Returns:
The added publication
Parameters:
name - The publication name.
type - The publication type.


add

public Object add(String name, Class type, Action configuration)
Creates a publication with the specified name and type, adding it to the container and configuring it with the supplied action. A Closure can be supplied in place of an action, through type coercion.
 apply plugin: 'ivy-publish'

 publishing.publications.add('publication-name', IvyPublication) {
     // Configure the ivy publication here
 }
 
throws:
InvalidUserDataException If type is not a valid publication type, or if a publication named "name" already exists.
Returns:
The added publication
Parameters:
name - The publication name.
type - The publication type.
configuration - The action or closure to configure the publication with.


 

Gradle API 1.5