Configure Multi-project
For a multi-project the plugin must be applied to the root project and all interesting subprojects.
Root project configuration
Inspecting subprojects
It is necessary to declare which subprojects to be included for collection of metadata.
ivypot {
projectsWithDependencies { path -> (1)
path.endWith('-foobuilder')
}
}
1 | A single predicate that is passed the project path of each subproject.
It should return true if the subproject is to be checked for metadata.
If the project is to be included, the org.ysb33r.ivypot plugin must also be applied to that subproject. |
Location of offline repository
ivypot {
repoDetails {
root = '.offline-repo' (1)
}
}
1 | Configure the location of the offline repository.
The default is .offline-repo in the root of the project. |
If you change the location of the repository, you need to also configure in every subproject if you plan to utilise any of the location getters for passing to tests. |
Declaring credentials for repositories
Credentials are only declared in the root project. We do not extract credentials from repositories directly for various (pseudo-)security reasons.
ivypot {
credentials {
forName('ourRepo') { (1)
username = '123' (2)
password = providers.gradleProperty('myPassword') (3)
realm = 'some-realm' (4)
}
}
}
1 | Declare the repository name to which these credentials will be applied. |
2 | Username |
3 | Password. Example show how to use a Gradle property to retrieve a password. |
4 | Optional realm. |
Lazy-evaluated properties can be supplied for all three DSL properties. |
The names of the credentials must match the names of repositories in the subprojects.
Declaring binary repositories
Binary repositories are only declared in the root project.
Binary repositories are arbitrary locations from which binaries can be downloaded.
For instance you might want to download a terraform
executable to be used during tests.
These repositories are declared by name, which then is used as the group name when declaring the appropriate binaries using the cachedBinaries
DSL block.
ivypot {
binaryRepositories {
source 'nodejs', { (1)
rootUri = 'https://nodejs.org/dist/' (2)
artifactPattern = 'v[revision]/[module]-v[revision]-[classifier].[ext]' (3)
}
}
}
1 | Declare a binary repository by name. |
2 | Set the root URI for the repository. |
3 | Declare pattern on how to resolve the binaryy artifact. Once a binary is resolved and substituted against the pattern, the result is concatenated to the root URI in order to determine the final URI. |
Binary repositories currently do not support credentials. |
Subproject configuration
Location of offline repository
The repo location is not configurable in a subproject. It will extract the value from the root project.
Adding and excluding repositories
Repositories are automatically added from anything declared int he standard repositories
Gradle DSL block.
Only Ivy & Maven repositories are supported.
mavenLocal
is always excluded.
If is also possible to exclude specific repositories.
repositories {
maven {
name = 'myRepo'
url = 'https://my-repo.example'
}
ivy {
name = 'myCustomIvy'
patternLayout {
artifact '[module]/[revision]/[artifact](.[ext])'
ivy '[module]/[revision]/ivy.xml'
}
}
}
ivypot {
repositories {
excludeByName 'myRepo' (1)
forIvy 'myCustomIvy', {
ivyPatterns '[module]/[revision]/ivy.xml' (2)
artifactPatterns '[module]/[revision]/[artifact](.[ext])' (3)
artifactsOnly() (4)
}
}
}
1 | Exclude one or more repositories by name. |
2 | Declare one or more Ivy patterns to be used for the named repository. |
3 | Declare one or more Ivy artifact patterns to be used for the named repository. |
4 | Declare that the named Ivy repository contains no metadata. |
Due to a restriction in the Gradle API, we cannot retrieve Ivy information from the declared repositories. It is therefore necessary to duplicate some information. |
Managing configurations
ivypot {
configurations {
named 'foo', 'bar' (1)
filter { name -> (2)
name.startsWith('test')
}
}
}
1 | Only include the named configurations. |
2 | Provide a filter for only including certain configurations. |
If neither named , nor filter is used, then all configurations in the (sub)project are included.
|
Adding binaries to be cached
ivypot {
cacheBinaries {
add 'nodejs:node:7.10.0:linux-x64@tar.xz'(1)
}
}
1 | Binaries are added in the typical Gradle format of group:name:version:classifier@extension .
Classifier is optional, and it depends on how the pattern has been set up in the binaryRepositories DSL block.
Extension is always required and will raise an exception if not supplied. |
The translation from a Gradle-style coordinate to Ivy pattern is effectively [organisation]:[module]:[revision](:[classifier])@[ext] .
|