Not all development teams have the luxury of relying on Maven Central, Bintray for day to day development. Some of them are still fortunate to proxy public repositories via in-house Artifactory or Nexxus instances. Others have even more strict requirements including the abaility to be able to build an isolated environment. This plugin is for them. It allows for pubic dependencies, including transitive dependencies, to be downloaded in a controlled manner and the internal security processes to be applied to the binary files before committing them to an internal storage area.
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'org.ysb33r.gradle:ivypot:0.3.2'
}
}
apply plugin : 'org.ysb33r.ivypot'
or if you use Gradle 2.1+
If you are in a restricted environment, you might want to use approach number #1 and conditionally add the remote reference to work only when you are in a non-restricted environment. i.e.
repositories {
if(!System.getenv('RESTRICTED')) {
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
plugins {
id 'org.ysb33r.ivypot' version '0.3'
}
The plugin provides a default task called syncRemoteRepositories
which is of type org.ysb33r.gradle.ivypot.OfflineRepositorySync
.
(You are free to create more instances of this task type).
syncRemoteRepositories {
repoRoot '/path/to/repo' // (1)
repositories { // (2)
jcenter()
mavenCentral()
mavenLocal()
maven {
url 'http://foo/bar'
credentials {
username 'pig'
password 'hog'
}
}
ivy {
url 'http://foo.bar' // (3)
}
flatDir {
dirs '/path/dir1', '/path/dir2' // (4)
}
}
configurations 'compile', 'testCompile' // (5)
includeBuildScriptDependencies = false // (6)
}
-
Defines the location of the off-line repository root.
-
repositories
in an implementation of RepositoryHandler and therefore supports all the standard repository definitions a Gradle user would expect. -
Ivy repositories in all incantantions available to Gradle is supported.
-
Flat directory support is planned, but not yet supported.
-
Restrict the configurations you would like to have added to the synchronisation process. If none are supplied, dependencies from all configurations will be added.
-
Whether to add dependencies from
buildscript
. (See further down).
For normal usage one simply has to point to the local repository. It is assumed that this repository would be committed to some form of source control or artifact management which is accessible with the restricted environment. The layout of this repository is a standard Ivy layout.
repositories {
ivy {
url 'file:///path/to/repo' // (1)
}
}
-
Define the path to the local repository here
Just add the repository to repositories
closure
buildscript {
repositories {
ivy {
url 'file:///path/to/repo' // (1)
}
}
}
-
Define the path to the local repository here
By default buildscript dependencies will not be added to the synchronisation list. By setting includeBuildScriptDependencies = true
in
the configuration closure of the task these will be added.
The resolution process cannot be fine-tuned at present - not to the level at least which is described in http://gradle.org/docs/current//userguide/dependency_management.html#sec:ivy_repositories.