interface ArtifactHandler
This class is for defining artifacts to be published and adding them to configurations. Creating publish artifacts does not mean to create an archive. What is created is a domain object which represents a file to be published and information on how it should be published (e.g. the name). To create an publish artifact and assign it to a configuration you can use the following syntax: <configurationName> <artifact-notation>, <artifact-notation> ... or <configurationName> <artifact-notation> { ... some code to configure the artifact }
The notation can be one of the following types:
In each case, a ConfigurablePublishArtifact instance is created for the artifact, to allow artifact properties to be configured. You can also override the default values for artifact properties by using a closure to configure the properties of the artifact instance ExamplesAn example showing how to associate an archive task with a configuration via the artifact handler. This way the archive can be published or referred in other projects via the configuration.
|
|
interface ComponentMetadataHandler
Allows the build to provide rules that modify the metadata of depended-on software components. Possible uses of component metadata rules are:
Example:
|
|
interface ComponentModuleMetadataHandler
Allows to modify the metadata of depended-on software components. Example:
|
|
interface DependencyConstraintHandler
A |
|
interface DependencyHandler
A To declare a specific dependency for a configuration you can use the following syntax:
Example shows a basic way of declaring dependencies. Advanced dependency configuration
To do some advanced configuration on a dependency when it is declared, you can additionally pass a configuration closure: Examples of advanced dependency declaration including:
More examples of advanced configuration, useful when dependency module has multiple artifacts:
Dependency notations
There are several supported dependency notations. These are described below. For each dependency declared this way, a Dependency object is created. You can use this object to query or further configure the dependency. You can also always add instances of org.gradle.api.artifacts.Dependency directly: configurationName <instance> External dependencies
There are two notations supported for declaring a dependency on an external module. One is a string notation formatted this way: configurationName "group:name:version:classifier@extension"
The other is a map notation: configurationName group: group, name: name, version: version, classifier: classifier, ext: extension
In both notations, all properties, except name, are optional. External dependencies are represented by a . Project dependencies
To add a project dependency, you use the following notation:
The notation By default, when you declare dependency to projectA, you actually declare dependency to the 'default' configuration of the projectA. If you need to depend on a specific configuration of projectA, use map notation for projects:
Project dependencies are represented using a org.gradle.api.artifacts.ProjectDependency. File dependenciesYou can also add a dependency using a org.gradle.api.file.FileCollection: configurationName files('a file')
File dependencies are represented using a org.gradle.api.artifacts.SelfResolvingDependency. Dependencies to other configurationsYou can add a dependency using a org.gradle.api.artifacts.Configuration. When the configuration is from the same project as the target configuration, the target configuration is changed to extend from the provided configuration. When the configuration is from a different project, a project dependency is added. Gradle distribution specific dependenciesIt is possible to depend on certain Gradle APIs or libraries that Gradle ships with. It is particularly useful for Gradle plugin development. Example: Client module dependencies
To add a client module to a configuration you can use the notation: The module notation is the same as the dependency notations described above, except that the classifier property is not available. Client modules are represented using a org.gradle.api.artifacts.ClientModule.
|
|
interface DependencyLockingHandler
A |
|
interface RepositoryHandler : ArtifactRepositoryContainer
A |