1
- GradleVcsDependencyPlugin
2
- =========================
1
+ GradleGitDependencies
2
+ =====================
3
3
4
4
[ ![ Maven Central] [ mvn-img ]] [ mvn-url ]
5
5
6
- Gradle plugin to add external Git and SVN repositories as dependencies.
6
+ Gradle plugin to add external git repositories as dependencies.
7
7
8
- ### How to use ###
8
+ ### Setup ###
9
9
10
10
In ` settings.gradle ` file add the following lines:
11
11
@@ -14,96 +14,123 @@ In `settings.gradle` file add the following lines:
14
14
jcenter()
15
15
}
16
16
dependencies {
17
- classpath 'com.alexvasilkov:gradle-vcs-dependency:1.1.1 '
17
+ classpath 'com.alexvasilkov:gradle-git-dependencies:2.0.0 '
18
18
}
19
19
}
20
20
21
- apply plugin: 'com.alexvasilkov.vcs-dependency '
21
+ apply plugin: 'com.alexvasilkov.git-dependencies '
22
22
23
23
Optionally you can provide settings next in ` settings.gradle ` :
24
24
25
- vcs {
26
- dir = 'libs' // Directory in which to store vcs repositories, 'libraries ' by default
27
- cleanup = false // Whether to cleanup unused dirs inside 'libraries ' dir, true by default
25
+ git {
26
+ dir 'libs' // Directory in which to store git repositories, 'libs ' by default
27
+ cleanup true // Whether to cleanup unused dirs inside 'libs ' dir, true by default
28
28
}
29
29
30
- Now in ` build.gradle ` add the following method:
30
+ ### Usage ###
31
31
32
- def vcs() {
33
- git name: 'GitDependencyName',
34
- url: 'https://example.com/repository.git',
35
- commit: '12345678abcdefgh'
32
+ Now in ` build.gradle ` add the following:
36
33
37
- svn name: 'SvnDependencyName',
38
- url: 'https://example.com/repository',
39
- rev: 123
34
+ git {
35
+ implementation 'https://example.com/repository.git', {
36
+ name 'DependencyName'
37
+ commit '12345678abcdefgh'
38
+ }
40
39
}
41
40
42
- Supported parameters:
43
-
44
- | Parameter | Description |
45
- | --------- | ----------- |
46
- | name | Dependency name, will be used as Gradle dependency name and as source code directory name. Required. |
47
- | url | Git (or SVN) repository url. Required. |
48
- | path | Path within repository which should be added as dependency. For example ` /library/ ` , ` /trunk/ ` . |
49
- | commit | Git commit id of any length, tag name, branch name. For example ` v1.2.3 ` or ` master ` . Required for Git. |
50
- | rev | SVN revision number or 'HEAD'. Required for SVN. |
51
- | dir | Repository directory, overrides global directory settings. |
52
- | username | Username to access repository. |
53
- | password | Password to access repository. |
54
- | authGroup | Group name (prefix) used when looking for access credentials. See ` Credentials ` section for more details. Default is ` VCS ` . |
55
- | noAuth | Whether authentication is required for this repository. Default value is ` true ` meaning that missing credentials will fail build process. |
56
- | 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 ` . |
57
- | keepUpdated | Whether to update this repository automatically or not. Default is ` true ` . |
58
- | configName | Gradle dependency configuration name. For example ` compile ` , ` implementation ` , ` api ` . Default value is ` implementation ` . |
59
-
60
- Note, that using 'master' as git commit or 'HEAD' as svn revision is not recommended, use explicit commit / revision instead.
61
-
62
-
63
- ### Example ###
64
-
65
- def vcs() {
66
- git name: 'GestureViews',
67
- url: 'https://github.com/alexvasilkov/GestureViews.git',
68
- commit: 'v2.5.1',
69
- path: '/library',
70
- noAuth: true
41
+ Where ` implementation ` is a configuration name, similar as used for regular gradle dependencies.
42
+ Can be any valid configuration name.
43
+
44
+ #### Supported parameters ####
45
+
46
+ | Parameter | Description |
47
+ | --------------- | ----------- |
48
+ | 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. |
49
+ | commit | Git commit id of any length, tag name or branch name. For example ` e628b205 ` , ` v1.2.3 ` . Set to ` master ` by default. |
50
+ | tag | Same as ` commit ` , see above. |
51
+ | branch | Same as ` commit ` , see above. |
52
+ | dir | Directory for cloned repository. Used to override default directory as defined in ` settings.gradle ` . |
53
+ | projectPath | Path within repository which should be added as gradle project. By default repo's root directory is added as project. |
54
+ | username | Username to access repository. See ` Credentials ` section below. |
55
+ | password | Password to access repository. See ` Credentials ` section below. |
56
+ | authGroup | Group name used when looking for credentials. See ` Credentials ` section below. |
57
+ | keepUpdated | Whether to update this repository automatically or not. Default is ` true ` . |
58
+
59
+ Note that using ` master ` or any other branch name as git commit is not recommended,
60
+ use explicit commit or tag instead.
61
+
62
+
63
+ You can also specify git repos in ` settings.gradle ` similar as it is done in ` build.gradle `
64
+ but use ` fetch ` instead of configuration name:
65
+
66
+ git {
67
+ fetch 'https://example.com/repository.git', {
68
+ dir '$rootDir/gradle/scripts'
69
+ tag 'v1.2.3'
70
+ }
71
71
}
72
72
73
+ Such repositories will be downloaded but not added as dependencies.
74
+ This can be useful, for example, if you want to pre-fetch build scripts.
73
75
74
- ### How it works ###
76
+ ### Examples ###
75
77
76
- 1 . You're providing dependency name, Git or SVN repository URL and other details in ` build.gradle ` file.
77
- 1 . Plugin clones repository to ` libraries/[NAME] ` project directory (can be changed, see further)
78
- at specified commit (Git) or revision (SVN).
79
- 1 . Cloned repo will be included as sub-project and necessary dependency will be added to original project.
80
- 1 . Dependencies are resolved recursively, for example your Git dependency can have other Git or SVN dependencies.
81
- 1 . If several projects have dependencies with same name then dependencies info and versions
82
- should be completely the same. Otherwise plugin will fail build process.
83
- 1 . Plugin automatically updates repository if version info was updated. But if there are any uncommited
84
- changes in local repo then plugin will fail build process until you manually resolve conflicts.
85
- 1 . Removed dependencies will be automatically cleaned from ` libraries ` directory (can be changed, see further).
78
+ git {
79
+ implementation '[email protected] :alexvasilkov/GestureViews.git'
86
80
81
+ api 'https://github.com/alexvasilkov/GestureViews.git', {
82
+ name 'GestureViews'
83
+ tag 'v2.6.0'
84
+ projectPath '/library'
85
+ }
86
+ }
87
+
88
+
89
+ ### How it works ###
90
+
91
+ 1 . You're providing git repository URL and other optional details in ` build.gradle ` file.
92
+ 2 . The plugin clones repository to ` libs/[name] ` directory (both name and directory can be changed)
93
+ at specified commit, tag or branch.
94
+ 3 . Cloned repo will be included as sub-project and defined as dependency of original project.
95
+ 4 . Dependencies are resolved recursively, i.e. your git dependency can have other git dependencies.
96
+ 5 . If several projects have dependencies with same name then all other details (url, commit, etc)
97
+ should be completely the same, otherwise build process will fail.
98
+ 6 . Plugin automatically updates repository if ` commit ` does not much local commit. If there are any
99
+ uncommited changes in local repo then build process will fail until you manually resolve conflicts.
100
+ 7 . Removed dependencies will be automatically cleaned from ` libs ` directory.
87
101
88
102
### Credentials ###
89
103
90
- If ` username ` property is not specified, plugin will look first for property named
91
- ` [name in upper case]_USERNAME ` and then for property ` [authGroup]_USERNAME `
92
- (` VCS_USERNAME ` by default) in next places:
104
+ If git repo is using SSH url (starts with ` git@ ` ) then the plugin will automatically try to use
105
+ local SSH key. But you need to ensure your SSH key is correctly setup, see instructions for
106
+ [ GitHub] ( https://help.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh )
107
+ or [ Bitbucket] ( https://confluence.atlassian.com/bitbucket/ssh-keys-935365775.html )
108
+
109
+ If git repo is using HTTPS url then there are two options how you can define credentials:
110
+
111
+ * Using ` username ` and ` password ` options directly in ` build.gradle ` .
112
+ * Using ` authGroup ` option and providing credentials as specified below.
113
+
114
+ If ` authGroup ` is provided then the plugin will search for ` git.[authGroup].username ` and
115
+ ` git.[authGroup].password ` params in:
116
+
117
+ * command line arguments (e.g.
` [email protected] ` )
118
+ * gradle.properties
119
+ * local.properties
120
+ * ~ /.gradle/gradle.properties
121
+ * environment variables, in uppercase and with ` _ ` instead of ` . ` , e.g. ` GIT_GITHUB_USERNAME `
93
122
94
- 1 . ` vcs.properties ` in the root directory of the project
95
- 1 . ` gradle.properties ` in the root directory of the project
96
- 1 . ` gradle.properties ` in ` [USER_HOME]/.gradle/ ` directory
97
- 1 . Environment variables
98
123
99
- If ` password ` property is not specified, plugin will look first for property named
100
- ` [name in upper case]_PASSWORD ` and then for property ` [authGroup]_PASSWORD `
101
- (` VCS_PASSWORD ` by default) in same places.
124
+ ### Migration from v1.x.x ###
102
125
103
- For example, if ` name ` property is set to ` ProjectName ` and ` authGroup ` property set to ` Company `
104
- then plugin will first look for properties called ` PROJECTNAME_USERNAME ` and ` PROJECTNAME_PASSWORD ` .
105
- If no credentials found then plugin will check properties ` COMPANY_USERNAME ` and ` COMPANY_PASSWORD ` .
126
+ There were several breaking changes since version 1.x.x:
106
127
128
+ * Default directory is changed from ` libraries ` to ` libs ` .
129
+ * Instead of defining ` def vcs() { ... } ` method you can use simpler ` git { ... } `
130
+ * Git dependencies declaration is reimplemented to mimic default gradle dependencies section.
131
+ * Credentials properties names are changed, e.g. was ` GIT_AUTHGROUP_USERNAME ` ,
132
+ become ` git.authGroup.username ` .
133
+ * Dropped SVN support.
107
134
108
135
#### License ####
109
136
@@ -119,5 +146,5 @@ If no credentials found then plugin will check properties `COMPANY_USERNAME` and
119
146
See the License for the specific language governing permissions and
120
147
limitations under the License.
121
148
122
- [ mvn-url ] : https://maven-badges.herokuapp.com/maven-central/com.alexvasilkov/gradle-vcs-dependency
123
- [ mvn-img ] : https://img.shields.io/maven-central/v/com.alexvasilkov/gradle-vcs-dependency .svg?style=flat-square
149
+ [ mvn-url ] : https://maven-badges.herokuapp.com/maven-central/com.alexvasilkov/gradle-git-dependencies
150
+ [ mvn-img ] : https://img.shields.io/maven-central/v/com.alexvasilkov/gradle-git-dependencies .svg?style=flat-square
0 commit comments