11import com.android.build.api.dsl.ApplicationExtension
22import com.android.build.api.dsl.LibraryExtension
3- import com.vanniktech.maven.publish.MavenPublishBaseExtension
43import io.getstream.core.Configuration
5- import java.io.FileNotFoundException
6- import java.util.Calendar
74
85apply (from = " ${rootDir} /gradle/scripts/sonar.gradle" )
96// Top-level build file where you can add configuration options common to all sub-projects/modules.
107plugins {
8+ alias(libs.plugins.stream.project)
119 alias(libs.plugins.stream.android.library) apply false
1210 alias(libs.plugins.stream.android.application) apply false
1311 alias(libs.plugins.stream.java.library) apply false
@@ -20,18 +18,15 @@ plugins {
2018 alias(libs.plugins.maven.publish)
2119 alias(libs.plugins.dokka) apply false
2220 alias(libs.plugins.arturbosch.detekt) apply true
23- alias(libs.plugins.spotless) apply true
2421 alias(libs.plugins.sonarqube) apply true
2522 alias(libs.plugins.kover) apply true
2623}
2724
28- spotless {
29- kotlin {
30- val currentYear = Calendar .getInstance().get(Calendar .YEAR ).toString()
31- target(" **/*.kt" )
32- targetExclude(" **/build/**/*.kt" )
33- ktfmt().kotlinlangStyle()
34- licenseHeaderFile(file(" ./config/license/generated/license-$currentYear .txt" ))
25+ streamProject {
26+ repositoryName = " stream-core-android"
27+
28+ spotless {
29+ useKtfmt = true
3530 }
3631}
3732
@@ -67,112 +62,3 @@ subprojects {
6762 }
6863 }
6964}
70-
71- // License tasks
72- subprojects {
73- apply (from = " ${rootDir} /gradle/scripts/coverage.gradle" )
74- tasks.register(" generateLicense" ) {
75- val currentYear = Calendar .getInstance().get(Calendar .YEAR ).toString()
76- val licenseTemplate = file(" ../config/license/license.template" )
77- val generatedLicense = file(" ../config/license/generated/license-$currentYear .txt" )
78- val detektFile = file(" ../config/detekt/detekt.yml" )
79- val projectName = project.findProperty(" projectName" )?.toString() ? : " stream-core-android"
80-
81- doLast {
82- if (licenseTemplate.exists()) {
83- // Generate license
84- val licenseContent = licenseTemplate.readText()
85- .replace(" {currentYear}" , currentYear)
86- .replace(" {project}" , projectName)
87- generatedLicense.writeText(licenseContent)
88- println (" License file generated: ${generatedLicense.absolutePath} " )
89-
90- // Update detekt.yml
91-
92- if (detektFile.exists()) {
93- val pattern = Regex (""" licenseTemplateFile:\s*['"]\.\./license/generated/license-\d{4}\.txt['"]""" )
94- val replacement = """ licenseTemplateFile: '../license/generated/license-$currentYear .txt'"""
95- val detektContent = detektFile.readText().replace(pattern, replacement)
96- detektFile.writeText(detektContent)
97-
98- println (" Detekt configuration updated: ${detektFile.absolutePath} " )
99- } else {
100- throw FileNotFoundException (" Detekt configuration file not found: ${detektFile.absolutePath} " )
101- }
102- } else {
103- throw FileNotFoundException (" Template file not found: ${licenseTemplate.absolutePath} " )
104- }
105- }
106- }
107- }
108-
109- subprojects {
110- plugins.withId(" com.vanniktech.maven.publish" ) {
111- extensions.configure<MavenPublishBaseExtension > {
112- publishToMavenCentral(automaticRelease = true )
113-
114- pom {
115- name.set(" Stream Android Core" )
116- description.set(" Stream Core official Android SDK" )
117- url.set(" https://github.com/getstream/stream-core-android" )
118-
119- licenses {
120- license {
121- name.set(" Stream License" )
122- url.set(" https://github.com/GetStream/stream-core-android/blob/main/LICENSE" )
123- }
124- }
125-
126- developers {
127- developer {
128- id = " aleksandar-apostolov"
129- name = " Aleksandar Apostolov"
130- 131- }
132- developer {
133- id = " VelikovPetar"
134- name = " Petar Velikov"
135- 136- }
137- developer {
138- id = " andremion"
139- name = " André Mion"
140- 141- }
142- developer {
143- id = " rahul-lohra"
144- name = " Rahul Kumar Lohra"
145- 146- }
147- developer {
148- id = " gpunto"
149- name = " Gianmarco David"
150- 151- }
152- }
153-
154- scm {
155- connection.set(" scm:git:github.com/getstream/stream-core-android.git" )
156- developerConnection.set(" scm:git:ssh://github.com/getstream/stream-core-android.git" )
157- url.set(" https://github.com/getstream/stream-core-android/tree/main" )
158- }
159- }
160- }
161- }
162- }
163-
164- tasks.register(" printAllArtifacts" ) {
165- group = " publishing"
166- description = " Prints all artifacts that will be published"
167-
168- doLast {
169- subprojects.forEach { subproject ->
170- subproject.plugins.withId(" com.vanniktech.maven.publish" ) {
171- subproject.extensions.findByType(PublishingExtension ::class .java)
172- ?.publications
173- ?.filterIsInstance<MavenPublication >()
174- ?.forEach { println (" ${it.groupId} :${it.artifactId} :${it.version} " ) }
175- }
176- }
177- }
178- }
0 commit comments