Skip to content

Commit

Permalink
Spotless 6.22.0 + Ktlint 1.0.0 (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler authored Oct 2, 2023
1 parent 83073e1 commit a2d4d7a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 17 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ subprojects {
'ktlint_standard_filename': 'disabled',
])
target('**/*.kt')
targetExclude("**/build/**")
}
}

Expand Down
18 changes: 14 additions & 4 deletions diffuse/src/main/kotlin/com/jakewharton/diffuse/diffuse.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ fun main(vararg args: String) {
}

private enum class BinaryType {
Apk, Aar, Aab, Jar, Dex
Apk,
Aar,
Aab,
Jar,
Dex,
}

private fun ParameterHolder.binaryType(): OptionWithValues<BinaryType, BinaryType, String> {
Expand All @@ -76,7 +80,9 @@ private fun ParameterHolder.binaryType(): OptionWithValues<BinaryType, BinaryTyp
}

private enum class ReportType {
Text, Html, None
Text,
Html,
None,
}

private fun ParameterHolder.mappingFile(name: String): OptionWithValues<ApiMapping, ApiMapping, ApiMapping> {
Expand Down Expand Up @@ -212,15 +218,19 @@ private class MembersCommand(
.default(Type.All)

enum class Type {
All, Methods, Fields
All,
Methods,
Fields,
}

private val ownership by option(help = "Item ownerships to display. Default is both (declared and referenced).")
.switch("--declared" to Ownership.Declared, "--referenced" to Ownership.Referenced)
.default(Ownership.All)

enum class Ownership {
All, Declared, Referenced
All,
Declared,
Referenced,
}

override fun run() {
Expand Down
18 changes: 9 additions & 9 deletions formats/src/main/kotlin/com/jakewharton/diffuse/format/Aab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class Aab private constructor(
val dexes: List<Dex>,
) {
companion object {
internal const val manifestFilePath = "manifest/${AndroidManifest.NAME}"
internal const val MANIFEST_FILE_PATH = "manifest/${AndroidManifest.NAME}"

fun Zip.toModule(): Module {
val files = toArchiveFiles { it.toAabFileType() }
val manifest = this[manifestFilePath].asInput().source().use {
val manifest = this[MANIFEST_FILE_PATH].asInput().source().use {
XmlNode.parseFrom(it.inputStream()).toManifest()
}
val dexes = entries.filter { it.path.startsWith("dex/") }.map { it.asInput().toDex() }
Expand All @@ -39,21 +39,21 @@ class Aab private constructor(
}

companion object {
private const val bundleMetadataDirectoryName = "BUNDLE-METADATA"
private const val metadataObfuscationDirectoryName =
"$bundleMetadataDirectoryName/com.android.tools.build.obfuscation/proguard.map"
private const val baseDirectoryName = "base"
private const val BUNDLE_METADATA_DIRECTORY_NAME = "BUNDLE-METADATA"
private const val METADATA_OBFUSCATION_DIRECTORY_NAME =
"$BUNDLE_METADATA_DIRECTORY_NAME/com.android.tools.build.obfuscation/proguard.map"
private const val BASE_DIRECTORY_NAME = "base"

@JvmStatic
@JvmName("parse")
fun Input.toAab(): Aab {
toZip().use { zip ->
val apiMapping =
zip.find(metadataObfuscationDirectoryName)?.asInput()?.toApiMapping() ?: ApiMapping.EMPTY
val baseModule = zip.directoryView(baseDirectoryName).toModule()
zip.find(METADATA_OBFUSCATION_DIRECTORY_NAME)?.asInput()?.toApiMapping() ?: ApiMapping.EMPTY
val baseModule = zip.directoryView(BASE_DIRECTORY_NAME).toModule()
val featureModules = zip.directories
// TODO there's probably a better way to discover feature module names.
.filter { it != baseDirectoryName && it != bundleMetadataDirectoryName && it != "META-INF" }
.filter { it != BASE_DIRECTORY_NAME && it != BUNDLE_METADATA_DIRECTORY_NAME && it != "META-INF" }
.associateWith { zip.directoryView(it).toModule() }
return Aab(name, apiMapping, baseModule, featureModules)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ data class ArchiveFile(
@JvmStatic
@JvmName("fromAabName")
fun String.toAabFileType() = when {
equals(Aab.Module.manifestFilePath) -> Manifest
equals(Aab.Module.MANIFEST_FILE_PATH) -> Manifest
startsWith("dex/") -> Dex
startsWith("lib/") -> Native
startsWith("assets/") -> Asset
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ r8 = "com.android.tools:r8:8.1.56"
dokka = "org.jetbrains.dokka:1.9.0"
kotlin-jvm = "org.jetbrains.kotlin.jvm:1.9.10"
mavenPublish = "com.vanniktech.maven.publish:0.25.3"
spotless = "com.diffplug.spotless:6.21.0"
spotless = "com.diffplug.spotless:6.22.0"
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ interface Report {

interface Factory {
fun toTextReport(): Report
fun toHtmlReport(): Report { TODO("Implement HTML reporting") }
fun toHtmlReport(): Report {
TODO("Implement HTML reporting")
}
}
}

0 comments on commit a2d4d7a

Please sign in to comment.