@@ -17,6 +17,7 @@ plugins {
1717 id(" com.github.johnrengelman.shadow" )
1818 id(" com.apollographql.apollo3" )
1919 id(" com.avast.gradle.docker-compose" )
20+ id(" io.gitlab.arturbosch.detekt" )
2021 kotlin(" jvm" )
2122}
2223
@@ -64,6 +65,8 @@ dependencies {
6465 implementation(" org.jetbrains.kotlinx:kotlinx-datetime:0.4.0" )
6566
6667 testImplementation(" org.junit.jupiter:junit-jupiter-engine:$jupiterVersion " )
68+
69+ detektPlugins(" io.gitlab.arturbosch.detekt:detekt-formatting:1.21.0" )
6770}
6871
6972configure< app.cash.licensee.LicenseeExtension > {
@@ -170,6 +173,45 @@ apollo {
170173spotless {
171174 kotlin {
172175 targetExclude(" **/generated/**" )
173- licenseHeaderFile(file(" LICENSE-HEADER.txt" ))
176+
177+ val startYear = 2022
178+ val currentYear = Calendar .getInstance().get(Calendar .YEAR )
179+ val copyrightYears = if (startYear == currentYear) {
180+ " $startYear "
181+ } else {
182+ " $startYear -$currentYear "
183+ }
184+
185+ val jetbrainsProject = findProject(" :protocol" ) ? : rootProject
186+ val licenseHeader = Regex (" ( . Copyright [\\ S\\ s]+)" )
187+ .find(File (jetbrainsProject.projectDir, " LICENSE" ).readText())!!
188+ .value.lines().joinToString(" \n " ) {
189+ if (it.trim().isEmpty()) {
190+ " *"
191+ } else {
192+ " * " + it.trim()
193+ }
194+ }
195+ val formattedLicenseHeader = buildString {
196+ append(" /*\n " )
197+ append(
198+ licenseHeader.replace(
199+ " Copyright [yyyy] [name of copyright owner]" ,
200+ " Source++, the open-source live coding platform.\n " +
201+ " * Copyright (C) $copyrightYears CodeBrig, Inc."
202+ ).replace(
203+ " http://www.apache.org/licenses/LICENSE-2.0" ,
204+ " http://www.apache.org/licenses/LICENSE-2.0"
205+ )
206+ )
207+ append(" /" )
208+ }
209+ licenseHeader(formattedLicenseHeader)
174210 }
175211}
212+
213+ detekt {
214+ parallel = true
215+ buildUponDefaultConfig = true
216+ config.setFrom(arrayOf(File (project.rootDir, " detekt.yml" )))
217+ }
0 commit comments