Skip to content

Commit 9518d22

Browse files
authored
Merge pull request #102 from PatilShreyas/v1.3.0-updatedeps
Update dependencies and release workflow publishing command
2 parents dd2c1e0 + ccc7ca6 commit 9518d22

File tree

36 files changed

+506
-421
lines changed

36 files changed

+506
-421
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,7 @@ jobs:
4040
run: ./gradlew build --stacktrace
4141

4242
- name: Publish Library on Maven Central
43-
run: |
44-
echo "Publishing Core🚀"
45-
./gradlew :core:publish
46-
echo "Published Core✅"
47-
echo "Releasing Core...🚀"
48-
./gradlew closeAndReleaseRepository
49-
echo "Released Core✅"
50-
51-
echo "Publishing Report Generator🚀"
52-
./gradlew :report-generator:publish
53-
echo "Published Report Generator✅"
54-
echo "Releasing Report Generator...🚀"
55-
./gradlew closeAndReleaseRepository
56-
echo "Released Report Generator✅"
43+
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
5744
env:
5845
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }}
5946
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSWORD }}

build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,5 @@ subprojects {
3131
ktlint()
3232
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
3333
}
34-
kotlinGradle {
35-
target("*.gradle.kts")
36-
ktlint()
37-
}
3834
}
3935
}

cli/build.gradle.kts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ dependencies {
1919
implementation(libs.kotlinx.cli)
2020
}
2121

22-
tasks.withType<Jar>() {
22+
tasks.withType<Jar> {
2323
manifest {
2424
attributes["Main-Class"] = mainCliClassName
2525
}
26-
val dependencies = configurations
27-
.runtimeClasspath
28-
.get()
29-
.map(::zipTree)
26+
val dependencies =
27+
configurations
28+
.runtimeClasspath
29+
.get()
30+
.map(::zipTree)
3031
from(dependencies)
3132
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
3233
}

cli/src/main/kotlin/dev/shreyaspatil/composeCompilerMetricsGenerator/cli/Main.kt

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,26 @@ import java.nio.file.Paths
4444
fun main(args: Array<String>) {
4545
val arguments = CliArguments(args, Paths.get("").toAbsolutePath())
4646

47-
val reportSpec = ReportSpec(
48-
name = arguments.applicationName,
49-
options = ReportOptions(
50-
includeStableComposables = arguments.includeStableComposables,
51-
includeStableClasses = arguments.includeStableClasses,
52-
includeClasses = arguments.includeClasses,
53-
showOnlyUnstableComposables = arguments.showOnlyUnstableComposables,
54-
),
55-
)
47+
val reportSpec =
48+
ReportSpec(
49+
name = arguments.applicationName,
50+
options =
51+
ReportOptions(
52+
includeStableComposables = arguments.includeStableComposables,
53+
includeStableClasses = arguments.includeStableClasses,
54+
includeClasses = arguments.includeClasses,
55+
showOnlyUnstableComposables = arguments.showOnlyUnstableComposables,
56+
),
57+
)
5658
val rawReportProvider = arguments.getRawReportProvider()
5759

5860
printHeader("Generating Composable HTML Report")
5961

60-
val html = HtmlReportGenerator(
61-
reportSpec = reportSpec,
62-
metricsProvider = ComposeCompilerMetricsProvider(rawReportProvider),
63-
).generateHtml()
62+
val html =
63+
HtmlReportGenerator(
64+
reportSpec = reportSpec,
65+
metricsProvider = ComposeCompilerMetricsProvider(rawReportProvider),
66+
).generateHtml()
6467

6568
printHeader("Saving Composable Report")
6669
val reportPath = saveReportAsHtml(html, arguments.outputDirectory)
@@ -72,7 +75,10 @@ fun main(args: Array<String>) {
7275
/**
7376
* Saves a file with [htmlContent] having name as 'index.html' at specified [outputDirectory]
7477
*/
75-
fun saveReportAsHtml(htmlContent: String, outputDirectory: String): String {
78+
fun saveReportAsHtml(
79+
htmlContent: String,
80+
outputDirectory: String,
81+
): String {
7682
val directory = File(Paths.get(outputDirectory).toAbsolutePath().toString())
7783

7884
if (!directory.exists()) {
@@ -169,12 +175,13 @@ class CliArguments(args: Array<String>, private val path: Path) {
169175
fun getRawReportProvider(): ComposeCompilerRawReportProvider {
170176
val directory = inputDirectory
171177

172-
val files = arrayOf(
173-
overallStatsFile,
174-
detailedStatsFile,
175-
composableMetricsFile,
176-
classMetricsFile,
177-
)
178+
val files =
179+
arrayOf(
180+
overallStatsFile,
181+
detailedStatsFile,
182+
composableMetricsFile,
183+
classMetricsFile,
184+
)
178185

179186
return if (directory != null) {
180187
ensureDirectory(directory) { "Directory '$directory' not exists" }
@@ -206,12 +213,13 @@ class CliArguments(args: Array<String>, private val path: Path) {
206213
}
207214
}
208215

209-
fun printHeader(header: String) = println(
210-
"""
211-
------------------------------------------------------------------
212-
$header
213-
""".trimIndent(),
214-
)
216+
fun printHeader(header: String) =
217+
println(
218+
"""
219+
------------------------------------------------------------------
220+
$header
221+
""".trimIndent(),
222+
)
215223

216224
object Constants {
217225
const val VERSION = "v1.1.0"

core/src/main/kotlin/dev/shreyaspatil/composeCompilerMetricsGenerator/core/ComposeCompilerMetricsProvider.kt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ interface ComposeCompilerMetricsProvider {
6666
private class DefaultComposeCompilerMetricsProvider(
6767
private val contentProvider: ComposeMetricsContentProvider,
6868
) : ComposeCompilerMetricsProvider {
69-
7069
override fun getOverallStatistics(): Map<String, Long> {
7170
val statistics = mutableMapOf<String, Long>()
7271
contentProvider.briefStatisticsContents.forEach { statContent ->
@@ -85,15 +84,16 @@ private class DefaultComposeCompilerMetricsProvider(
8584
override fun getDetailedStatistics(): DetailedStatistics {
8685
val csv = contentProvider.detailedStatisticsCsvRows
8786

88-
val metrics = if (csv.size > 1) {
89-
val headers = splitWithCsvSeparator(csv.first())
87+
val metrics =
88+
if (csv.size > 1) {
89+
val headers = splitWithCsvSeparator(csv.first())
9090

91-
csv.subList(1, csv.size)
92-
.map { splitWithCsvSeparator(it) }
93-
.map { items -> RowItems(items.mapIndexed { index, value -> Item(headers[index], value) }) }
94-
} else {
95-
emptyList()
96-
}
91+
csv.subList(1, csv.size)
92+
.map { splitWithCsvSeparator(it) }
93+
.map { items -> RowItems(items.mapIndexed { index, value -> Item(headers[index], value) }) }
94+
} else {
95+
emptyList()
96+
}
9797

9898
return DetailedStatistics(metrics)
9999
}
@@ -112,9 +112,7 @@ private class DefaultComposeCompilerMetricsProvider(
112112
/**
113113
* Factory function for creating [ComposeCompilerMetricsProvider].
114114
*/
115-
fun ComposeCompilerMetricsProvider(
116-
files: ComposeCompilerRawReportProvider,
117-
): ComposeCompilerMetricsProvider {
115+
fun ComposeCompilerMetricsProvider(files: ComposeCompilerRawReportProvider): ComposeCompilerMetricsProvider {
118116
val contentProvider = ComposeMetricsContentProvider(files)
119117
return DefaultComposeCompilerMetricsProvider(contentProvider)
120118
}

core/src/main/kotlin/dev/shreyaspatil/composeCompilerMetricsGenerator/core/ComposeCompilerRawReportProvider.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ sealed interface ComposeCompilerRawReportProvider {
7373
* Validates report and metric files
7474
*/
7575
fun ComposeCompilerRawReportProvider.validateComposeCompilerRawReportProvider() {
76-
val files = briefStatisticsJsonFiles +
77-
detailedStatisticsCsvFiles +
78-
composableReportFiles +
79-
classesReportFiles
76+
val files =
77+
briefStatisticsJsonFiles +
78+
detailedStatisticsCsvFiles +
79+
composableReportFiles +
80+
classesReportFiles
8081

8182
files.forEach { ensureFileExists(it) { "File '$it' not exists" } }
8283
}

core/src/main/kotlin/dev/shreyaspatil/composeCompilerMetricsGenerator/core/file/ReportAndMetricsFileFinder.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ import java.io.File
3131
* @param directory The directory in which files will be searched
3232
*/
3333
class ReportAndMetricsFileFinder(directory: File) {
34-
private val allFiles = directory
35-
.listFiles()
36-
?.filterNotNull()
37-
?: emptyList()
34+
private val allFiles =
35+
directory
36+
.listFiles()
37+
?.filterNotNull()
38+
?: emptyList()
3839

3940
fun findBriefStatisticsJsonFile(): List<File> {
4041
return allFiles.filter { it.name.endsWith(FileSuffixes.MODULE_REPORT_JSON) }

core/src/main/kotlin/dev/shreyaspatil/composeCompilerMetricsGenerator/core/mapper/ConditionMapper.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ package dev.shreyaspatil.composeCompilerMetricsGenerator.core.mapper
2626
import dev.shreyaspatil.composeCompilerMetricsGenerator.core.model.Condition
2727

2828
object ConditionMapper {
29-
fun from(value: String): Condition = when (value.lowercase()) {
30-
"stable" -> Condition.STABLE
31-
"unstable" -> Condition.UNSTABLE
32-
else -> Condition.MISSING
33-
}
29+
fun from(value: String): Condition =
30+
when (value.lowercase()) {
31+
"stable" -> Condition.STABLE
32+
"unstable" -> Condition.UNSTABLE
33+
else -> Condition.MISSING
34+
}
3435
}

core/src/main/kotlin/dev/shreyaspatil/composeCompilerMetricsGenerator/core/model/Condition.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@
2424
package dev.shreyaspatil.composeCompilerMetricsGenerator.core.model
2525

2626
enum class Condition {
27-
STABLE, UNSTABLE, MISSING
27+
STABLE,
28+
UNSTABLE,
29+
MISSING,
2830
}

core/src/main/kotlin/dev/shreyaspatil/composeCompilerMetricsGenerator/core/parser/ClassReportParser.kt

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,30 @@ object ClassReportParser : Parser<String, ClassesReport> {
4343
override fun parse(content: String): ClassesReport {
4444
val errors = mutableListOf<ParsingException>()
4545

46-
val classes = getClasses(content)
47-
.mapNotNull { classBody ->
48-
runCatching {
49-
parseClassDetail(classBody)
50-
}.onFailure { cause ->
51-
errors.add(ParsingException(classBody, cause))
52-
}.getOrNull()
53-
}.toList()
46+
val classes =
47+
getClasses(content)
48+
.mapNotNull { classBody ->
49+
runCatching {
50+
parseClassDetail(classBody)
51+
}.onFailure { cause ->
52+
errors.add(ParsingException(classBody, cause))
53+
}.getOrNull()
54+
}.toList()
5455

5556
return ClassesReport(classes, errors.toList())
5657
}
5758

5859
internal fun getClasses(content: String): List<String> {
5960
val lines = content.split("\n").filter { it.isNotBlank() }
6061

61-
val classIndexes = lines.mapIndexedNotNull { index, s ->
62-
if (REGEX_CLASS_NAME.containsMatchIn(s)) {
63-
index
64-
} else {
65-
null
62+
val classIndexes =
63+
lines.mapIndexedNotNull { index, s ->
64+
if (REGEX_CLASS_NAME.containsMatchIn(s)) {
65+
index
66+
} else {
67+
null
68+
}
6669
}
67-
}
6870

6971
return classIndexes.mapIndexed { index: Int, item: Int ->
7072
lines.subList(item, classIndexes.getOrElse(index + 1) { lines.size }).joinToString(separator = "\n")
@@ -77,14 +79,16 @@ object ClassReportParser : Parser<String, ClassesReport> {
7779
private fun parseClassDetail(classBody: String): ClassDetail {
7880
val classDetail = REGEX_CLASS_NAME.find(classBody)?.groupValues
7981
val className = classDetail?.getOrNull(2) ?: error("Undefined name for the class body: $classBody")
80-
val stability = classDetail.getOrNull(1)?.let { ConditionMapper.from(it) }
81-
?: error("Undefined stability status for the class body: $classBody")
82+
val stability =
83+
classDetail.getOrNull(1)?.let { ConditionMapper.from(it) }
84+
?: error("Undefined stability status for the class body: $classBody")
8285

8386
val runtimeStability =
8487
REGEX_RUNTIME_STABILITY.find(classBody)?.groupValues?.getOrNull(1)?.let { ConditionMapper.from(it) }
8588

86-
val fields = REGEX_CLASS_FIELDS.findAll(classBody).map { it.groupValues }.filter { it.isNotEmpty() }
87-
.map { ClassDetail.Field(it[2], it[3]) }.toList()
89+
val fields =
90+
REGEX_CLASS_FIELDS.findAll(classBody).map { it.groupValues }.filter { it.isNotEmpty() }
91+
.map { ClassDetail.Field(it[2], it[3]) }.toList()
8892

8993
return ClassDetail(
9094
className = className,

0 commit comments

Comments
 (0)