GH-1344: Enable updateCopyrights onlyIf grgit (#1345)
* GH-1344: Enable updateCopyrights onlyIf grgit Fixes https://github.com/spring-projects/spring-kafka/issues/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
This commit is contained in:
committed by
Gary Russell
parent
52408e4aad
commit
16af5fb65c
19
build.gradle
19
build.gradle
@@ -17,13 +17,19 @@ plugins {
|
||||
id 'idea'
|
||||
id 'org.sonarqube' version '2.7.1'
|
||||
id 'org.asciidoctor.convert' version '1.6.1'
|
||||
id 'org.ajoberstar.grgit' version '3.1.1'
|
||||
id 'org.ajoberstar.grgit' version '3.1.1' apply false
|
||||
id 'io.spring.nohttp' version '0.0.3.RELEASE'
|
||||
id 'io.spring.dependency-management' version '1.0.8.RELEASE' apply false
|
||||
}
|
||||
|
||||
apply plugin: 'io.spring.nohttp'
|
||||
|
||||
def gitPresent = new File('.git').exists()
|
||||
|
||||
if(gitPresent) {
|
||||
apply plugin: 'org.ajoberstar.grgit'
|
||||
}
|
||||
|
||||
description = 'Spring Kafka'
|
||||
|
||||
ext {
|
||||
@@ -35,8 +41,11 @@ ext {
|
||||
linkScmDevConnection = 'git@github.com:spring-projects/spring-kafka.git'
|
||||
docResourcesVersion = '0.1.0.RELEASE'
|
||||
|
||||
modifiedFiles =
|
||||
|
||||
if (gitPresent) {
|
||||
modifiedFiles =
|
||||
files(grgit.status().unstaged.modified).filter{ f -> f.name.endsWith('.java') || f.name.endsWith('.kt') }
|
||||
}
|
||||
|
||||
assertjVersion = '3.15.0'
|
||||
googleJsr305Version = '3.0.2'
|
||||
@@ -170,8 +179,10 @@ subprojects { subproject ->
|
||||
|
||||
|
||||
task updateCopyrights {
|
||||
onlyIf { !System.getenv('TRAVIS') && !System.getenv('bamboo_buildKey') }
|
||||
inputs.files(modifiedFiles.filter { f -> f.path.contains(subproject.name) })
|
||||
onlyIf { gitPresent && !System.getenv('TRAVIS') && !System.getenv('bamboo_buildKey') }
|
||||
if (gitPresent) {
|
||||
inputs.files(modifiedFiles.filter { f -> f.path.contains(subproject.name) })
|
||||
}
|
||||
outputs.dir('build')
|
||||
|
||||
doLast {
|
||||
|
||||
Reference in New Issue
Block a user