Configure Single Project
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. |
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. |
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. |
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.
|
Declaring binary repositories
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. |
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] .
|
Kotlin example
As all the previous examples were in Groovy DSL., here is an example of the same in Kotlin DSL.
val simple by configurations.creating
val github by configurations.creating
repositories {
mavenCentral()
}
dependencies {
simple("com.slack.api:slack-app-backend:1.8.0")
github(":ivypot-gradle-plugin:master@zip")
}
ivypot {
repoDetails {
setRoot(".repo")
}
binaryRepositories {
source("nodejs", {
setRootUri("https://nodejs.org/dist/")
setArtifactPattern("v[revision]/[module]-v[revision]-[classifier].[ext]")
})
}
cacheBinaries {
add("nodejs:node:7.10.0:linux-x64@tar.xz")
}
configurations {
filter { cfg -> cfg.name == "simple" }
}
}