Skip to content

Ivypot is a Gradle plugin to help managing a local off-line repository for builds in restricted environments

License

Notifications You must be signed in to change notification settings

tinobino/ivypot-gradle-plugin

 
 

Repository files navigation

IvyPot - A Gradle plugin for Off-line Repositories

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.

Adding the plugin

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'
}

Defining Remote Repositories

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)
}
  1. Defines the location of the off-line repository root.

  2. repositories in an implementation of RepositoryHandler and therefore supports all the standard repository definitions a Gradle user would expect.

  3. Ivy repositories in all incantantions available to Gradle is supported.

  4. Flat directory support is planned, but not yet supported.

  5. Restrict the configurations you would like to have added to the synchronisation process. If none are supplied, dependencies from all configurations will be added.

  6. Whether to add dependencies from buildscript. (See further down).

Usage

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)
  }
}
  1. Define the path to the local repository here

Boostrapping plugins in a restricted environment

Just add the repository to repositories closure

buildscript {
    repositories {
      ivy {
        url 'file:///path/to/repo' // (1)
      }
    }
}
  1. Define the path to the local repository here

Adding buildscript dependencies

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.

Limitations

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.

About

Ivypot is a Gradle plugin to help managing a local off-line repository for builds in restricted environments

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Groovy 100.0%