File tree Expand file tree Collapse file tree 1 file changed +36
-1
lines changed
Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Original file line number Diff line number Diff line change 1+ import java.util.Calendar
2+
13buildscript {
24 repositories {
35 mavenCentral()
@@ -134,7 +136,40 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
134136spotless {
135137 kotlin {
136138 target(" **/*.kt" )
137- licenseHeaderFile(file(" LICENSE-HEADER.txt" ))
139+
140+ val startYear = 2022
141+ val currentYear = Calendar .getInstance().get(Calendar .YEAR )
142+ val copyrightYears = if (startYear == currentYear) {
143+ " $startYear "
144+ } else {
145+ " $startYear -$currentYear "
146+ }
147+
148+ val jetbrainsProject = findProject(" :protocol" ) ? : rootProject
149+ val licenseHeader = Regex (" ( . Copyright [\\ S\\ s]+)" )
150+ .find(File (jetbrainsProject.projectDir, " LICENSE" ).readText())!!
151+ .value.lines().joinToString(" \n " ) {
152+ if (it.trim().isEmpty()) {
153+ " *"
154+ } else {
155+ " * " + it.trim()
156+ }
157+ }
158+ val formattedLicenseHeader = buildString {
159+ append(" /*\n " )
160+ append(
161+ licenseHeader.replace(
162+ " Copyright [yyyy] [name of copyright owner]" ,
163+ " Source++, the open-source live coding platform.\n " +
164+ " * Copyright (C) $copyrightYears CodeBrig, Inc."
165+ ).replace(
166+ " http://www.apache.org/licenses/LICENSE-2.0" ,
167+ " http://www.apache.org/licenses/LICENSE-2.0"
168+ )
169+ )
170+ append(" /" )
171+ }
172+ licenseHeader(formattedLicenseHeader)
138173 }
139174}
140175
You can’t perform that action at this time.
0 commit comments