# PublicationContainer

interface PublicationContainer : ExtensiblePolymorphicDomainObjectContainer<Publication> (source)

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

- The org.gradle.api.publish.maven.plugins.MavenPublishPlugin makes it possible to create org.gradle.api.publish.maven.MavenPublication instances.
- The org.gradle.api.publish.ivy.plugins.IvyPublishPlugin makes it possible to create org.gradle.api.publish.ivy.IvyPublication instances.

    plugins {
        id 'ivy-publish'
    }

    publishing.publications.create('publication-name', IvyPublication) {
        // Configure the ivy publication here
    }

Content copied to clipboard
The usual way to add publications is via a configuration block. See the documentation for publications for examples of how to create and configure publications.

#### Since

1.3

#### See also

Publication
PublishingExtension

## Properties

creating
Link copied to clipboard
val <T : Any> NamedDomainObjectContainer<T>.creating: NamedDomainObjectContainerCreatingDelegateProvider<T>

Provides a property delegate that creates elements of the default collection type.

## Functions

add
Link copied to clipboard
abstract fun add(p: E): Boolean
abstract fun add(e: T): Boolean
Adds an object to the collection, if there is no existing object in the collection with the same name.
addAll
Link copied to clipboard
abstract fun addAll(p: Collection<out E>): Boolean
abstract fun addAll(c: Collection<out T>): Boolean
Adds any of the given objects to the collection that do not have the same name as any existing element.
addAllLater
Link copied to clipboard
abstract fun addAllLater(provider: Provider<out Iterable<T>>)
Adds elements to this collection, given a Provider of Iterable that will provide the elements when required.
addLater
Link copied to clipboard
abstract fun addLater(provider: Provider<out T>)
Adds an element to this collection, given a Provider that will provide the element when required.
addRule
Link copied to clipboard
abstract fun addRule(rule: Rule): Rule
abstract fun addRule(description: String, ruleAction: Closure): Rule
abstract fun addRule(description: String, ruleAction: Action<String>): Rule
Adds a rule to this collection.
all
Link copied to clipboard
abstract fun all(action: Closure)
Executes the given closure against all objects in this collection, and any objects subsequently added to this collection.
abstract fun all(action: Action<in T>)
Executes the given action against all objects in this collection, and any objects subsequently added to this collection.
clear
Link copied to clipboard
abstract fun clear()
configure
Link copied to clipboard
abstract fun configure(configureClosure: Closure): NamedDomainObjectContainer<T>
Allows the container to be configured, creating missing objects as they are referenced.
abstract fun configure(cl: Closure): T
configureEach
Link copied to clipboard
abstract fun configureEach(action: Action<in T>)
Configures each element in this collection using the given action, as each element is required.
containerWithType
Link copied to clipboard
abstract fun <U : T?> containerWithType(type: Class<U>): NamedDomainObjectContainer<U>
Creates a regular container that wraps the polymorphic container presenting all elements of a specified type.
containerWithType
Link copied to clipboard
inline fun <U : T, T : Any> PolymorphicDomainObjectContainer<T>.containerWithType(type: KClass<U>): NamedDomainObjectContainer<U>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.PolymorphicDomainObjectContainer.containerWithType.

contains
Link copied to clipboard
abstract fun contains(p: Any): Boolean
containsAll
Link copied to clipboard
abstract fun containsAll(p: Collection<out Any>): Boolean
copyOf
Link copied to clipboard
open fun <E> copyOf(coll: Collection<out E>): Set<E>
create
Link copied to clipboard
abstract fun create(name: String): T
Creates a new item with the given name, adding it to this container.
abstract fun create(name: String, configureClosure: Closure): T
Creates a new item with the given name, adding it to this container, then configuring it with the given closure.
abstract fun create(name: String, configureAction: Action<in T>): T
Creates a new item with the given name, adding it to this container, then configuring it with the given action.
abstract fun <U : T?> create(name: String, type: Class<U>): U
Creates a domain object with the specified name and type, and adds it to the container.
abstract fun <U : T?> create(name: String, type: Class<U>, configuration: Action<in U>): U
Creates a domain object with the specified name and type, adds it to the container, and configures it with the specified action.
create
Link copied to clipboard
inline fun <U : Any> PolymorphicDomainObjectContainer<in U>.create(name: String): U?

Creates a domain object with the specified name and type, and adds it to the container.

inline fun <U : Any> PolymorphicDomainObjectContainer<in U>.create(name: String, noinline configuration: U.() -> Unit): U?

Creates a domain object with the specified name and type, adds it to the container, and configures it with the specified action.

inline fun <U : T, T : Any> PolymorphicDomainObjectContainer<T>.create(name: String, type: KClass<U>): U
inline fun <U : T, T : Any> PolymorphicDomainObjectContainer<T>.create(name: String, type: KClass<U>, configuration: Action<in U>): U

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.PolymorphicDomainObjectContainer.create.

creating
Link copied to clipboard
fun <T : Any> NamedDomainObjectContainer<T>.creating(configuration: T.() -> Unit): NamedDomainObjectContainerCreatingDelegateProvider<T>

Provides a property delegate that creates elements of the default collection type with the given configuration.

fun <T : Any, U : T> PolymorphicDomainObjectContainer<T>.creating(type: KClass<U>): PolymorphicDomainObjectContainerCreatingDelegateProvider<T, U>

Provides a property delegate that creates elements of the given type.

fun <T : Any, U : T> PolymorphicDomainObjectContainer<T>.creating(type: Class<U>, configuration: U.() -> Unit): PolymorphicDomainObjectContainerCreatingDelegateProvider<T, U>

Provides a property delegate that creates elements of the given type expressed as a java.lang.Class with the given configuration.

fun <T : Any, U : T> PolymorphicDomainObjectContainer<T>.creating(type: KClass<U>, configuration: U.() -> Unit): PolymorphicDomainObjectContainerCreatingDelegateProvider<T, U>

Provides a property delegate that creates elements of the given type with the given configuration.

disallowChanges
Link copied to clipboard
@Incubating
open fun disallowChanges()
Disallows further structural modifications to this collection.
equals
Link copied to clipboard
abstract fun equals(p: Any): Boolean
findAll
Link copied to clipboard
abstract fun findAll(spec: Closure): Collection<T>
abstract fun findAll(spec: Closure): Set<T>
Returns a collection which contains the objects in this collection which meet the given closure specification.
findByName
Link copied to clipboard
@Nullable
abstract fun findByName(name: String): @Nullable T
Locates an object by name, returning null if there is no such object.
forEach
Link copied to clipboard
open fun forEach(action: Consumer<in T>)
get
Link copied to clipboard
operator fun <T : Any> NamedDomainObjectCollection<T>.get(name: String): T

Locates an object by name, failing if there is no such object.

getAsMap
Link copied to clipboard
abstract fun getAsMap(): SortedMap<String, T>
Returns the objects in this collection, as a map from object name to object instance.
getAt
Link copied to clipboard
abstract fun getAt(name: String): T
Locates an object by name, failing if there is no such object.
getByName
Link copied to clipboard
abstract fun getByName(name: String): T
abstract fun getByName(name: String, configureClosure: Closure): T
abstract fun getByName(name: String, configureAction: Action<in T>): T
Locates an object by name, failing if there is no such object.
getByName
Link copied to clipboard
inline fun <T : Any> NamedDomainObjectCollection<out Any>.getByName(name: String): T

Locates an object by name and casts it to the expected type T.

inline fun <T : Any> NamedDomainObjectCollection<out Any>.getByName(name: String, configure: T.() -> Unit): T

Locates an object by name and casts it to the expected type T then configures it.

fun <T : Any> NamedDomainObjectCollection<out Any>.getByName(name: String, type: KClass<T>): T

Locates an object by name and casts it to the expected type.

fun <T : Any> NamedDomainObjectCollection<out Any>.getByName(name: String, type: KClass<T>, configure: T.() -> Unit): T

Locates an object by name and casts it to the expected type then configures it.

getCollectionSchema
Link copied to clipboard
@Internal
abstract fun getCollectionSchema(): NamedDomainObjectCollectionSchema
Provides access to the schema of all created or registered named domain objects in this collection.
getNamer
Link copied to clipboard
abstract fun getNamer(): Namer<T>
An object that represents the naming strategy used to name objects of this collection.
getNames
Link copied to clipboard
abstract fun getNames(): SortedSet<String>
Returns the names of the objects in this collection as a Set of Strings.
getRules
Link copied to clipboard
abstract fun getRules(): List<Rule>
Returns the rules used by this collection.
getting
Link copied to clipboard
fun <T : Any, U : T> NamedDomainObjectContainer<T>.getting(type: KClass<U>): PolymorphicDomainObjectContainerGettingDelegateProvider<T, U>

Provides a property delegate that gets elements of the given type.

fun <T : Any, U : T> NamedDomainObjectContainer<T>.getting(type: KClass<U>, configuration: U.() -> Unit): PolymorphicDomainObjectContainerGettingDelegateProvider<T, U>

Provides a property delegate that gets elements of the given type and applies the given configuration.

hashCode
Link copied to clipboard
abstract fun hashCode(): Int
isEmpty
Link copied to clipboard
abstract fun isEmpty(): Boolean
iterator
Link copied to clipboard
abstract fun iterator(): Iterator<T>
abstract fun iterator(): Iterator<E>
matching
Link copied to clipboard
abstract fun matching(spec: Closure): DomainObjectCollection<T>
abstract fun matching(spec: Closure): DomainObjectSet<T>
abstract fun matching(spec: Closure): NamedDomainObjectCollection<T>
Returns a collection which contains the objects in this collection which meet the given closure specification.
abstract fun matching(spec: Spec<in T>): DomainObjectCollection<T>
abstract fun matching(spec: Spec<in T>): DomainObjectSet<T>
abstract fun matching(spec: Spec<in T>): NamedDomainObjectCollection<T>
Returns a collection which contains the objects in this collection which meet the given specification.
abstract fun matching(spec: Closure): NamedDomainObjectSet<T>
abstract fun matching(spec: Spec<in T>): NamedDomainObjectSet<T>
maybeCreate
Link copied to clipboard
abstract fun maybeCreate(name: String): T
Looks for an item with the given name, creating and adding it to this container if it does not exist.
abstract fun <U : T?> maybeCreate(name: String, type: Class<U>): U
Looks for an item with the given name and type, creating and adding it to this container if it does not exist.
maybeCreate
Link copied to clipboard
inline fun <U : Any> PolymorphicDomainObjectContainer<in U>.maybeCreate(name: String): U?

Creates a domain object with the specified name and type if it does not exists, and adds it to the container.

inline fun <U : T, T : Any> PolymorphicDomainObjectContainer<T>.maybeCreate(name: String, type: KClass<U>): U

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.PolymorphicDomainObjectContainer.maybeCreate.

named
Link copied to clipboard
abstract fun named(name: String): NamedDomainObjectProvider<T>
abstract fun named(name: String, configurationAction: Action<in T>): NamedDomainObjectProvider<T>
Locates a object by name, failing if there is no such object.
@Incubating
open fun named(nameFilter: Spec<String>): NamedDomainObjectCollection<T>
abstract fun named(nameFilter: Spec<String>): NamedDomainObjectSet<T>
Returns a collection containing the objects with names matching the provided filter.
abstract fun <S : T?> named(name: String, type: Class<S>): NamedDomainObjectProvider<S>
abstract fun <S : T?> named(name: String, type: Class<S>, configurationAction: Action<in S>): NamedDomainObjectProvider<S>
Locates a object by name and type, failing if there is no such object.
named
Link copied to clipboard
inline fun <T : Any> NamedDomainObjectCollection<out Any>.named(name: String): NamedDomainObjectProvider<T>
fun <T : Any> NamedDomainObjectCollection<out Any>.named(name: String, type: KClass<T>): NamedDomainObjectProvider<T>

Locates an object by name and type, without triggering its creation or configuration, failing if there is no such object.

inline fun <S : T, T : Any> NamedDomainObjectCollection<T>.named(name: String, type: KClass<S>): NamedDomainObjectProvider<S>
inline fun <S : T, T : Any> NamedDomainObjectCollection<T>.named(name: String, type: KClass<S>, configurationAction: Action<in S>): NamedDomainObjectProvider<S>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.NamedDomainObjectCollection.named.

inline fun <T : Any> NamedDomainObjectCollection<out Any>.named(name: String, noinline configuration: T.() -> Unit): NamedDomainObjectProvider<T>
fun <T : Any> NamedDomainObjectCollection<out Any>.named(name: String, type: KClass<T>, configuration: T.() -> Unit): NamedDomainObjectProvider<T>

Configures an object by name and type, without triggering its creation or configuration, failing if there is no such object.

of
Link copied to clipboard
open fun <E> of(): Set<E>
parallelStream
Link copied to clipboard
open fun parallelStream(): Stream<E>
provideDelegate
Link copied to clipboard
operator fun <T : Any> NamedDomainObjectCollection<T>.provideDelegate(thisRef: Any?, property: KProperty<*>): NamedDomainObjectProvider<T?>?

Allows a NamedDomainObjectCollection to be used as a property delegate.

register
Link copied to clipboard
abstract fun register(name: String): NamedDomainObjectProvider<T>
abstract fun <U : T?> register(name: String, type: Class<U>): NamedDomainObjectProvider<U>
Defines a new object, which will be created when it is required.
abstract fun register(name: String, configurationAction: Action<in T>): NamedDomainObjectProvider<T>
abstract fun <U : T?> register(name: String, type: Class<U>, configurationAction: Action<in U>): NamedDomainObjectProvider<U>
Defines a new object, which will be created and configured when it is required.
register
Link copied to clipboard
inline fun <T : Any> PolymorphicDomainObjectContainer<in T>.register(name: String): NamedDomainObjectProvider<T>

Defines a new object, which will be created when it is required.

inline fun <T : Any> PolymorphicDomainObjectContainer<in T>.register(name: String, noinline configuration: T.() -> Unit): NamedDomainObjectProvider<T>

Defines and configure a new object, which will be created when it is required.

inline fun <U : T, T : Any> PolymorphicDomainObjectContainer<T>.register(name: String, type: KClass<U>): NamedDomainObjectProvider<U>
inline fun <U : T, T : Any> PolymorphicDomainObjectContainer<T>.register(name: String, type: KClass<U>, configurationAction: Action<in U>): NamedDomainObjectProvider<U>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.PolymorphicDomainObjectContainer.register.

registerBinding
Link copied to clipboard
abstract fun <U : T?> registerBinding(type: Class<U>, implementationType: Class<out U>)
Registers a binding from the specified "public" domain object type to the specified implementation type.
registerBinding
Link copied to clipboard
inline fun <U : T, T : Any> ExtensiblePolymorphicDomainObjectContainer<T>.registerBinding(type: KClass<U>, implementationType: KClass<out U>)

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.ExtensiblePolymorphicDomainObjectContainer.registerBinding.

registerFactory
Link copied to clipboard
abstract fun <U : T?> registerFactory(type: Class<U>, factory: Closure<out U>)
abstract fun <U : T?> registerFactory(type: Class<U>, factory: NamedDomainObjectFactory<out U>)
Registers a factory for creating elements of the specified type.
abstract fun <U : T?> registerFactory(type: Class<U>, factory: NamedDomainObjectFactory<out U>)
remove
Link copied to clipboard
abstract fun remove(p: Any): Boolean
removeAll
Link copied to clipboard
abstract fun removeAll(p: Collection<out Any>): Boolean
removeIf
Link copied to clipboard
open fun removeIf(filter: Predicate<in E>): Boolean
retainAll
Link copied to clipboard
abstract fun retainAll(p: Collection<out Any>): Boolean
size
Link copied to clipboard
abstract fun size(): Int
spliterator
Link copied to clipboard
open fun spliterator(): Spliterator<T>
open fun spliterator(): Spliterator<E>
stream
Link copied to clipboard
open fun stream(): Stream<E>
toArray
Link copied to clipboard
abstract fun toArray(): Array<Any>
abstract fun <T> toArray(p: Array<T>): Array<T>
whenObjectAdded
Link copied to clipboard
abstract fun whenObjectAdded(action: Closure)
Adds a closure to be called when an object is added to this collection.
abstract fun whenObjectAdded(action: Action<in T>): Action<in T>
Adds an `Action` to be executed when an object is added to this collection.
whenObjectRemoved
Link copied to clipboard
abstract fun whenObjectRemoved(action: Closure)
Adds a closure to be called when an object is removed from this collection.
abstract fun whenObjectRemoved(action: Action<in T>): Action<in T>
Adds an `Action` to be executed when an object is removed from this collection.
withType
Link copied to clipboard
abstract fun <S : T?> withType(type: Class<S>): DomainObjectCollection<S>
abstract fun <S : T?> withType(type: Class<S>, @DelegatesTo(genericTypeIndex = 0) configureClosure: Closure): DomainObjectCollection<S>
abstract fun <S : T?> withType(type: Class<S>, configureAction: Action<in S>): DomainObjectCollection<S>
abstract fun <S : T?> withType(type: Class<S>): DomainObjectSet<S>
abstract fun <S : T?> withType(type: Class<S>): NamedDomainObjectCollection<S>
Returns a collection containing the objects in this collection of the given type.
abstract fun <S : T?> withType(type: Class<S>): NamedDomainObjectSet<S>
withType
Link copied to clipboard
inline fun <S : Any> DomainObjectCollection<in S>.withType(): DomainObjectCollection<S?>?
inline fun <S : Any> NamedDomainObjectCollection<in S>.withType(): NamedDomainObjectCollection<S>

Returns a collection containing the objects in this collection of the given type. The returned collection is live, so that when matching objects are later added to this collection, they are also visible in the filtered collection.

inline fun <S : Any> DomainObjectCollection<in S>.withType(noinline configuration: S.() -> Unit): DomainObjectCollection<S?>?

Returns a collection containing the objects in this collection of the given type. Equivalent to calling `withType(type).all(configureAction)`.

inline fun <S : T, T : Any> DomainObjectCollection<T>.withType(type: KClass<S>): DomainObjectCollection<S>
inline fun <S : T, T : Any> DomainObjectCollection<T>.withType(type: KClass<S>, configureAction: Action<in S>): DomainObjectCollection<S>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.DomainObjectCollection.withType.

inline fun <S : T, T : Any> DomainObjectSet<T>.withType(type: KClass<S>): DomainObjectSet<S>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.DomainObjectSet.withType.

inline fun <S : T, T : Any> NamedDomainObjectCollection<T>.withType(type: KClass<S>): NamedDomainObjectCollection<S>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.NamedDomainObjectCollection.withType.

inline fun <S : T, T : Any> NamedDomainObjectSet<T>.withType(type: KClass<S>): NamedDomainObjectSet<S>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.NamedDomainObjectSet.withType.