-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* New configuration DSL, closer to original gradle dependencies. * Updated credentials handling, using new properties. * Fixed problem with cached singletons. * Dropped SVN support.
- Loading branch information
1 parent
e628b20
commit b5810e1
Showing
24 changed files
with
820 additions
and
799 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
GradleVcsDependencyPlugin | ||
========================= | ||
GradleGitDependencies | ||
===================== | ||
|
||
[![Maven Central][mvn-img]][mvn-url] | ||
|
||
Gradle plugin to add external Git and SVN repositories as dependencies. | ||
Gradle plugin to add external git repositories as dependencies. | ||
|
||
### How to use ### | ||
### Setup ### | ||
|
||
In `settings.gradle` file add the following lines: | ||
|
||
|
@@ -14,96 +14,123 @@ In `settings.gradle` file add the following lines: | |
jcenter() | ||
} | ||
dependencies { | ||
classpath 'com.alexvasilkov:gradle-vcs-dependency:1.1.1' | ||
classpath 'com.alexvasilkov:gradle-git-dependencies:2.0.0' | ||
} | ||
} | ||
|
||
apply plugin: 'com.alexvasilkov.vcs-dependency' | ||
apply plugin: 'com.alexvasilkov.git-dependencies' | ||
|
||
Optionally you can provide 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 | ||
git { | ||
dir 'libs' // Directory in which to store git repositories, 'libs' by default | ||
cleanup true // Whether to cleanup unused dirs inside 'libs' dir, true by default | ||
} | ||
|
||
Now in `build.gradle` add the following method: | ||
### Usage ### | ||
|
||
def vcs() { | ||
git name: 'GitDependencyName', | ||
url: 'https://example.com/repository.git', | ||
commit: '12345678abcdefgh' | ||
Now in `build.gradle` add the following: | ||
|
||
svn name: 'SvnDependencyName', | ||
url: 'https://example.com/repository', | ||
rev: 123 | ||
git { | ||
implementation 'https://example.com/repository.git', { | ||
name 'DependencyName' | ||
commit '12345678abcdefgh' | ||
} | ||
} | ||
|
||
Supported parameters: | ||
|
||
| Parameter | Description | | ||
| --------- | ----------- | | ||
| name | Dependency name, will be used as Gradle dependency name and as source code directory name. Required. | | ||
| url | Git (or SVN) repository url. Required. | | ||
| path | Path within repository which should be added as dependency. For example `/library/`, `/trunk/`. | | ||
| commit | Git commit id of any length, tag name, branch name. For example `v1.2.3` or `master`. Required for Git. | | ||
| rev | SVN revision number or 'HEAD'. Required for SVN. | | ||
| dir | Repository directory, overrides global directory settings. | | ||
| username | Username to access repository. | | ||
| password | Password to access repository. | | ||
| authGroup | Group name (prefix) used when looking for access credentials. See `Credentials` section for more details. Default is `VCS`. | | ||
| noAuth | Whether authentication is required for this repository. Default value is `true` meaning that missing credentials will fail build process. | | ||
| includeProject | Whether to include this repository as Gradle project or not. Can be set to `false` if you only want this repository to be fetched before building main project. Default is `true`. | | ||
| keepUpdated | Whether to update this repository automatically or not. Default is `true`. | | ||
| configName | Gradle dependency configuration name. For example `compile`, `implementation`, `api`. Default value is `implementation`. | | ||
|
||
Note, that using 'master' as git commit or 'HEAD' as svn revision is not recommended, use explicit commit / revision instead. | ||
|
||
|
||
### Example ### | ||
|
||
def vcs() { | ||
git name: 'GestureViews', | ||
url: 'https://github.com/alexvasilkov/GestureViews.git', | ||
commit: 'v2.5.1', | ||
path: '/library', | ||
noAuth: true | ||
Where `implementation` is a configuration name, similar as used for regular gradle dependencies. | ||
Can be any valid configuration name. | ||
|
||
#### Supported parameters #### | ||
|
||
| Parameter | Description | | ||
| --------------- | ----------- | | ||
| name | Dependency name. Will be used as gradle project name and as repo directory name. If the name is not set then it will be taken from url. | | ||
| commit | Git commit id of any length, tag name or branch name. For example `e628b205`, `v1.2.3`. Set to `master` by default. | | ||
| tag | Same as `commit`, see above. | | ||
| branch | Same as `commit`, see above. | | ||
| dir | Directory for cloned repository. Used to override default directory as defined in `settings.gradle`. | | ||
| projectPath | Path within repository which should be added as gradle project. By default repo's root directory is added as project. | | ||
| username | Username to access repository. See `Credentials` section below. | | ||
| password | Password to access repository. See `Credentials` section below. | | ||
| authGroup | Group name used when looking for credentials. See `Credentials` section below. | | ||
| keepUpdated | Whether to update this repository automatically or not. Default is `true`. | | ||
|
||
Note that using `master` or any other branch name as git commit is not recommended, | ||
use explicit commit or tag instead. | ||
|
||
|
||
You can also specify git repos in `settings.gradle` similar as it is done in `build.gradle` | ||
but use `fetch` instead of configuration name: | ||
|
||
git { | ||
fetch 'https://example.com/repository.git', { | ||
dir '$rootDir/gradle/scripts' | ||
tag 'v1.2.3' | ||
} | ||
} | ||
|
||
Such repositories will be downloaded but not added as dependencies. | ||
This can be useful, for example, if you want to pre-fetch build scripts. | ||
|
||
### How it works ### | ||
### Examples ### | ||
|
||
1. You're providing dependency name, Git or SVN repository URL and other details in `build.gradle` file. | ||
1. Plugin clones repository to `libraries/[NAME]` project directory (can be changed, see further) | ||
at specified commit (Git) or revision (SVN). | ||
1. Cloned repo will be included as sub-project and necessary dependency will be added to original project. | ||
1. Dependencies are resolved recursively, for example your Git dependency can have other Git or SVN dependencies. | ||
1. If several projects have dependencies with same name then dependencies info and versions | ||
should be completely the same. Otherwise plugin will fail build process. | ||
1. Plugin automatically updates repository if version info was updated. But if there are any uncommited | ||
changes in local repo then plugin will fail build process until you manually resolve conflicts. | ||
1. Removed dependencies will be automatically cleaned from `libraries` directory (can be changed, see further). | ||
git { | ||
implementation '[email protected]:alexvasilkov/GestureViews.git' | ||
|
||
api 'https://github.com/alexvasilkov/GestureViews.git', { | ||
name 'GestureViews' | ||
tag 'v2.6.0' | ||
projectPath '/library' | ||
} | ||
} | ||
|
||
|
||
### How it works ### | ||
|
||
1. You're providing git repository URL and other optional details in `build.gradle` file. | ||
2. The plugin clones repository to `libs/[name]` directory (both name and directory can be changed) | ||
at specified commit, tag or branch. | ||
3. Cloned repo will be included as sub-project and defined as dependency of original project. | ||
4. Dependencies are resolved recursively, i.e. your git dependency can have other git dependencies. | ||
5. If several projects have dependencies with same name then all other details (url, commit, etc) | ||
should be completely the same, otherwise build process will fail. | ||
6. Plugin automatically updates repository if `commit` does not much local commit. If there are any | ||
uncommited changes in local repo then build process will fail until you manually resolve conflicts. | ||
7. Removed dependencies will be automatically cleaned from `libs` directory. | ||
|
||
### Credentials ### | ||
|
||
If `username` property is not specified, plugin will look first for property named | ||
`[name in upper case]_USERNAME` and then for property `[authGroup]_USERNAME` | ||
(`VCS_USERNAME` by default) in next places: | ||
If git repo is using SSH url (starts with `git@`) then the plugin will automatically try to use | ||
local SSH key. But you need to ensure your SSH key is correctly setup, see instructions for | ||
[GitHub](https://help.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh) | ||
or [Bitbucket](https://confluence.atlassian.com/bitbucket/ssh-keys-935365775.html) | ||
|
||
If git repo is using HTTPS url then there are two options how you can define credentials: | ||
|
||
* Using `username` and `password` options directly in `build.gradle`. | ||
* Using `authGroup` option and providing credentials as specified below. | ||
|
||
If `authGroup` is provided then the plugin will search for `git.[authGroup].username` and | ||
`git.[authGroup].password` params in: | ||
|
||
* command line arguments (e.g. `[email protected]`) | ||
* gradle.properties | ||
* local.properties | ||
* ~/.gradle/gradle.properties | ||
* environment variables, in uppercase and with `_` instead of `.`, e.g. `GIT_GITHUB_USERNAME` | ||
|
||
1. `vcs.properties` in the root directory of the project | ||
1. `gradle.properties` in the root directory of the project | ||
1. `gradle.properties` in `[USER_HOME]/.gradle/` directory | ||
1. Environment variables | ||
|
||
If `password` property is not specified, plugin will look first for property named | ||
`[name in upper case]_PASSWORD` and then for property `[authGroup]_PASSWORD` | ||
(`VCS_PASSWORD` by default) in same places. | ||
### Migration from v1.x.x ### | ||
|
||
For example, if `name` property is set to `ProjectName` and `authGroup` property set to `Company` | ||
then plugin will first look for properties called `PROJECTNAME_USERNAME` and `PROJECTNAME_PASSWORD`. | ||
If no credentials found then plugin will check properties `COMPANY_USERNAME` and `COMPANY_PASSWORD`. | ||
There were several breaking changes since version 1.x.x: | ||
|
||
* Default directory is changed from `libraries` to `libs`. | ||
* Instead of defining `def vcs() { ... }` method you can use simpler `git { ... }` | ||
* Git dependencies declaration is reimplemented to mimic default gradle dependencies section. | ||
* Credentials properties names are changed, e.g. was `GIT_AUTHGROUP_USERNAME`, | ||
become `git.authGroup.username`. | ||
* Dropped SVN support. | ||
|
||
#### License #### | ||
|
||
|
@@ -119,5 +146,5 @@ If no credentials found then plugin will check properties `COMPANY_USERNAME` and | |
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
[mvn-url]: https://maven-badges.herokuapp.com/maven-central/com.alexvasilkov/gradle-vcs-dependency | ||
[mvn-img]: https://img.shields.io/maven-central/v/com.alexvasilkov/gradle-vcs-dependency.svg?style=flat-square | ||
[mvn-url]: https://maven-badges.herokuapp.com/maven-central/com.alexvasilkov/gradle-git-dependencies | ||
[mvn-img]: https://img.shields.io/maven-central/v/com.alexvasilkov/gradle-git-dependencies.svg?style=flat-square |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
apply plugin: 'groovy' | ||
|
||
tasks.withType(GroovyCompile) { | ||
sourceCompatibility = '1.7' | ||
targetCompatibility = '1.7' | ||
} | ||
|
||
repositories { | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
compile gradleApi() | ||
compile localGroovy() | ||
|
||
compile 'org.tmatesoft.svnkit:svnkit:1.9.2' | ||
compile 'org.ajoberstar:grgit:1.9.3' | ||
compile 'org.ajoberstar.grgit:grgit-core:4.0.2' | ||
} | ||
|
||
// Build & upload: './gradlew clean build uploadArchives' | ||
apply from: "${rootDir}/gradle/scripts/gradle-plugin-mvn-push.gradle" | ||
// Build & upload: './gradlew clean build publish' | ||
apply from: "$rootDir/gradle/scripts/publish.gradle" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.