Skip to content

Commit 12bd395

Browse files
committed
v2.0.1: Added defaultAuthGroup option
1 parent fb4d319 commit 12bd395

File tree

6 files changed

+16
-7
lines changed

6 files changed

+16
-7
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ In `settings.gradle` file add the following lines:
1414
jcenter()
1515
}
1616
dependencies {
17-
classpath 'com.alexvasilkov:gradle-git-dependencies:2.0.0'
17+
classpath 'com.alexvasilkov:gradle-git-dependencies:2.0.1'
1818
}
1919
}
2020

@@ -25,6 +25,7 @@ Optionally you can provide settings next in `settings.gradle`:
2525
git {
2626
dir 'libs' // Directory in which to store git repositories, 'libs' by default
2727
cleanup true // Whether to cleanup unused dirs inside 'libs' dir, true by default
28+
defaultAuthGroup 'group name' // Default auth group to be used for all repos. See `Credentials` section below.
2829
}
2930

3031
### Usage ###
@@ -120,6 +121,8 @@ If `authGroup` is provided then the plugin will search for `git.[authGroup].user
120121
* ~/.gradle/gradle.properties
121122
* environment variables, in uppercase and with `_` instead of `.`, e.g. `GIT_GITHUB_USERNAME`
122123

124+
If `defaultAuthGroup` is provided in `settings.gradle` then it will be used for all repos
125+
unless `authGroup` is explicitly set.
123126

124127
### Migration from v1.x.x ###
125128

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ apply plugin: 'groovy'
66

77
ext.group = 'com.alexvasilkov'
88
ext.artifactId = 'gradle-git-dependencies'
9-
ext.version = '2.0.0'
9+
ext.version = '2.0.1'
1010
ext.name = 'Git Dependencies plugin'
1111
ext.description = 'Gradle plugin to add external git repos as project dependencies'
1212
ext.github = 'https://github.com/alexvasilkov/GradleGitDependenciesPlugin'

src/main/groovy/com/alexvasilkov/gradle/git/Credentials.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class Credentials {
1212
private Properties gradleUserProps
1313
private Properties localProps
1414

15-
Credentials(Gradle gradle) {
16-
userDir = gradle.gradleUserHomeDir
15+
Credentials(File gradleUserHomeDir) {
16+
userDir = gradleUserHomeDir
1717

1818
File gradleFile = new File('gradle.properties')
1919
if (gradleFile.exists()) {

src/main/groovy/com/alexvasilkov/gradle/git/GitDependency.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class GitDependency {
2828
commit = builder.commit ?: 'master'
2929
projectPath = builder.projectPath
3030
dir = builder.dir ?: (name != null ? new File(props.dir, name) : null)
31-
authGroup = builder.authGroup
32-
needsAuth = builder.authGroup || builder.username || builder.password
31+
authGroup = builder.authGroup ?: props.defaultAuthGroup
32+
needsAuth = authGroup || builder.username || builder.password
3333
username = needsAuth ? (builder.username ?: credentials.username(authGroup)) : null
3434
password = needsAuth ? (builder.password ?: credentials.password(authGroup)) : null
3535
keepUpdated = builder.keepUpdated ?: true

src/main/groovy/com/alexvasilkov/gradle/git/SettingsExtension.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class SettingsExtension {
88
final File rootDir
99

1010
File dir
11+
String defaultAuthGroup
1112
boolean cleanup
1213
boolean cleanupIdeaModules
1314

@@ -16,6 +17,7 @@ class SettingsExtension {
1617
this.rootDir = settings.rootDir
1718
// Setting default values:
1819
this.dir = new File(settings.rootDir, 'libs')
20+
this.defaultAuthGroup = null
1921
this.cleanup = true
2022
this.cleanupIdeaModules = true
2123
}
@@ -32,6 +34,10 @@ class SettingsExtension {
3234
SettingsExtension.this.dir = dir as File
3335
}
3436

37+
void defaultAuthGroup(String authGroup) {
38+
SettingsExtension.this.defaultAuthGroup = authGroup
39+
}
40+
3541
void cleanup(boolean cleanup) {
3642
SettingsExtension.this.cleanup = cleanup
3743
}

src/main/groovy/com/alexvasilkov/gradle/git/SettingsPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SettingsPlugin implements Plugin<Settings> {
2727
GitDependency dep = buildDependency(settings, null, url, closure)
2828
dependencies.add(null, dep)
2929
})
30-
this.credentials = new Credentials(settings.gradle)
30+
this.credentials = new Credentials(settings.gradle.gradleUserHomeDir)
3131

3232
// Adding configuration method to collect plugin settings
3333
settings.metaClass."$EXTENSION_NAME" = props.&apply

0 commit comments

Comments
 (0)