Skip to content

Commit 716e783

Browse files
artembilangaryrussell
authored andcommitted
GH-1344: Enable updateCopyrights onlyIf grgit (#1345)
* GH-1344: Enable updateCopyrights onlyIf grgit Fixes #1344 Sometimes people build our project outside of Git repository * Make the `updateCopyrights` Gralde task conditional on the presence of `grgit` object initialized by the `org.ajoberstar.grgit` when Git repository is present. Otherwise it is `null` * Check for `grgit` presence when we try to gather `modifiedFiles` * * Check for `.git` dir before applying `grgit` plugin
1 parent 4f97156 commit 716e783

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

build.gradle

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,19 @@ plugins {
1616
id 'idea'
1717
id 'org.sonarqube' version '2.7.1'
1818
id 'org.asciidoctor.convert' version '1.6.1'
19-
id 'org.ajoberstar.grgit' version '3.1.1'
19+
id 'org.ajoberstar.grgit' version '3.1.1' apply false
2020
id 'io.spring.nohttp' version '0.0.3.RELEASE'
2121
id 'io.spring.dependency-management' version '1.0.8.RELEASE' apply false
2222
}
2323

2424
apply plugin: 'io.spring.nohttp'
2525

26+
def gitPresent = new File('.git').exists()
27+
28+
if(gitPresent) {
29+
apply plugin: 'org.ajoberstar.grgit'
30+
}
31+
2632
description = 'Spring Kafka'
2733

2834
ext {
@@ -34,8 +40,11 @@ ext {
3440
linkScmDevConnection = '[email protected]:spring-projects/spring-kafka.git'
3541
docResourcesVersion = '0.1.0.RELEASE'
3642

37-
modifiedFiles =
43+
44+
if (gitPresent) {
45+
modifiedFiles =
3846
files(grgit.status().unstaged.modified).filter{ f -> f.name.endsWith('.java') || f.name.endsWith('.kt') }
47+
}
3948

4049
assertjVersion = '3.14.0'
4150
googleJsr305Version = '3.0.2'
@@ -168,8 +177,10 @@ subprojects { subproject ->
168177

169178

170179
task updateCopyrights {
171-
onlyIf { !System.getenv('TRAVIS') && !System.getenv('bamboo_buildKey') }
172-
inputs.files(modifiedFiles.filter { f -> f.path.contains(subproject.name) })
180+
onlyIf { gitPresent && !System.getenv('TRAVIS') && !System.getenv('bamboo_buildKey') }
181+
if (gitPresent) {
182+
inputs.files(modifiedFiles.filter { f -> f.path.contains(subproject.name) })
183+
}
173184
outputs.dir('build')
174185

175186
doLast {

0 commit comments

Comments
 (0)