95 lines
2.2 KiB
Groovy
95 lines
2.2 KiB
Groovy
plugins {
|
|
id 'io.spring.nohttp'
|
|
id 'org.springframework.pulsar.root-project'
|
|
id 'org.springframework.pulsar.update-version'
|
|
id 'org.ajoberstar.grgit' version '4.0.1' apply false
|
|
}
|
|
|
|
description = 'Spring for Apache Pulsar'
|
|
|
|
apply from: 'gradle/aggregate-jacoco-report.gradle'
|
|
|
|
def gitPresent = new File('.git').exists()
|
|
|
|
if (gitPresent) {
|
|
apply plugin: 'org.ajoberstar.grgit'
|
|
}
|
|
|
|
ext {
|
|
if (gitPresent) {
|
|
modifiedFiles = files(grgit.status().unstaged.modified).filter{ f -> f.name.endsWith('.java') }
|
|
}
|
|
}
|
|
|
|
allprojects {
|
|
group = 'org.springframework.pulsar'
|
|
configurations.all {
|
|
resolutionStrategy.cacheChangingModulesFor 0, "minutes"
|
|
}
|
|
}
|
|
|
|
if (hasProperty('buildScan')) {
|
|
buildScan {
|
|
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
|
|
termsOfServiceAgree = 'yes'
|
|
}
|
|
}
|
|
|
|
nohttp {
|
|
allowlistFile = project.file('src/nohttp/allowlist.lines')
|
|
source.exclude "**/bin/**"
|
|
source.exclude "**/build/**"
|
|
source.exclude "**/out/**"
|
|
source.exclude "**/target/**"
|
|
}
|
|
|
|
check {
|
|
dependsOn checkstyleNohttp
|
|
}
|
|
|
|
/**
|
|
* Update copyrights for modified files:
|
|
* 'gradle updateCopyrights'
|
|
*
|
|
* Update copyrights for ALL files:
|
|
* 'gradle updateCopyrights -Pall=true'
|
|
*/
|
|
subprojects { subproject ->
|
|
task updateCopyrights {
|
|
if (findProperty("all") == "true") {
|
|
inputs.files(fileTree("${projectDir}").matching {
|
|
include "**/*.java"
|
|
}.files)
|
|
}
|
|
else {
|
|
onlyIf { gitPresent && !System.getenv('GITHUB_ACTION') }
|
|
if (gitPresent) {
|
|
inputs.files(modifiedFiles.filter { f -> f.path.contains(subproject.name) })
|
|
}
|
|
}
|
|
outputs.dir('build')
|
|
doLast {
|
|
def now = Calendar.instance.get(Calendar.YEAR) as String
|
|
inputs.files.each { file ->
|
|
def line
|
|
file.withReader { reader ->
|
|
while (line = reader.readLine()) {
|
|
def matcher = line =~ /Copyright (20\d\d)-?(20\d\d)?/
|
|
if (matcher.count) {
|
|
def beginningYear = matcher[0][1]
|
|
if (now != beginningYear && now != matcher[0][2]) {
|
|
def years = "$beginningYear-$now"
|
|
def sourceCode = file.text
|
|
sourceCode = sourceCode.replaceFirst(/20\d\d(-20\d\d)?/, years)
|
|
file.write(sourceCode)
|
|
println "Copyright updated for file: $file"
|
|
}
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|