Gradle plugin to add external git/svn repositories as dependencies.
- You can provide dependency name, git or svn repository info and version in
build.gradlefile. - Plugin clones repository to
libraries/[NAME]directory (can be changed, see further) at specified commit (git) / revision (svn). - Cloned repo will be included as sub-project and correct project dependency will be added to original project.
- Dependencies are resolved recursively, so your vcs dependencies can have other vcs dependencies
- If several projects have dependencies with same name then dependencies info and versions should be completely the same. Otherwise plugin will fail build process.
- Plugin automatically updates repository if version info was updated. But if there are any uncommited changes in local repo, than plugin will fail build process until you manually resolve conflicts.
- Removed dependencies will be automatically cleaned from
librariesdirectory (can be changed, see further).
In settings.gradle file add next lines:
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.alexvasilkov:gradle-vcs-dependency:0.3.1' } } apply plugin: 'com.alexvasilkov.vcs-dependency' Optionally you can also provide some settings next in settings.gradle:
vcs { dir = 'libs' // Directory in which to store vcs repositories, 'libraries' by default cleanup = false // Whether to cleanup unused dirs inside 'libraries' dir, true by default } In build.gradle add next method:
def vcs() { svn name: '[Svn dependency name. Required]', url: '[Svn repository url. Required]', path: '[Path within repo url, i.e. /trunk/library/. Optional]', rev: [Revision number or 'HEAD'. Required] git name: '[Git dependency name. Required]', url: '[Git repository url. Required]', path: '[Path within repo which should be added as dependency, i.e. /library/. Optional]', commit: '[Commit id of any length or 'master' to checkout HEAD. Required]' } Note, that using 'master' as git commit or 'HEAD' as svn revision is not recommended, use explicit commit / revision instead.
Other optional parameters:
def vcs() { xxx dir: '[Repository directory, overrides global vcs directory settings. Optional.]', username: '[Username to access repo. Optional.]', password: '[Password. Optional.]', authGroup: '[Group name to share same access credentials. Optional, default is VCS.]', includeProject: [Whether to include this repo as Gradle project. Optional, true by default.], addDependency: [Whether to add this project as dependency. Only works if 'includeProject' is true. Optional, true by default.], keepUpdated: [Whether to update this repo automatically or not. Optional, true by default.] } If username property is not specified, plugin will look first for property named [name in upper case]_USERNAME and than for property [authGroup]_USERNAME (VCS_USERNAME by default) in next places:
vcs.propertiesin the root directory of the projectgradle.propertiesin the root directory of the projectgradle.propertiesin[USER_HOME]/.gradle/directory- Environment variables
If password property is not specified, plugin will look first for property named [name in upper case]_PASSWORD and than for property [authGroup]_PASSWORD (VCS_PASSWORD by default) in same places.
I.e. if dependency name is ProjectName than plugin will first look for PROJECTNAME_USERNAME and PROJECTNAME_PASSWORD properties.
Copyright 2015 Alex Vasilkov Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.