From 998eb2cd01e313d14c0953e240e5628fdb36282b Mon Sep 17 00:00:00 2001 From: snappdevelopment Date: Mon, 2 Sep 2024 18:45:59 +0200 Subject: [PATCH 1/7] Add debug and release builds for app and remove jvmTarget --- .gitignore | 1 + jsontree/build.gradle.kts | 4 ---- sample/build.gradle.kts | 15 ++++++++++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 45c7f2d..4777b70 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,7 @@ captures/ .idea/navEditor.xml .idea/other.xml .idea/studiobot.xml +.idea/artifacts .kotlin diff --git a/jsontree/build.gradle.kts b/jsontree/build.gradle.kts index 6e57616..bfbda74 100644 --- a/jsontree/build.gradle.kts +++ b/jsontree/build.gradle.kts @@ -17,10 +17,6 @@ kotlin { publishLibraryVariants("release") @OptIn(ExperimentalKotlinGradlePluginApi::class) instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) - @OptIn(ExperimentalKotlinGradlePluginApi::class) - compilerOptions { - jvmTarget.set(JvmTarget.JVM_1_8) - } @OptIn(ExperimentalKotlinGradlePluginApi::class) instrumentedTestVariant { diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index a9b1c7d..00bd08c 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -72,7 +72,8 @@ android { compileSdk = 34 defaultConfig { - minSdk = 24 + minSdk = 21 + targetSdk = 34 } sourceSets["main"].apply { manifest.srcFile("src/androidMain/AndroidManifest.xml") @@ -82,6 +83,18 @@ android { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } + buildTypes { + getByName("release") { + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + //for testing only, don't do this in your app + signingConfig = signingConfigs.getByName("debug") + } + getByName("debug") { + applicationIdSuffix = ".debug" + signingConfig = signingConfigs.getByName("debug") + } + } buildFeatures { compose = true } From f977bb40a14041927f4c906071f2d6a0a4523cb6 Mon Sep 17 00:00:00 2001 From: snappdevelopment Date: Mon, 2 Sep 2024 19:09:43 +0200 Subject: [PATCH 2/7] downgrade gradle plugin and adjust sample code --- gradle/libs.versions.toml | 2 +- jsontree/build.gradle.kts | 1 - sample/build.gradle.kts | 2 - sample/src/commonMain/kotlin/App.kt | 103 ++++++++++++++++++---------- 4 files changed, 67 insertions(+), 41 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d2f55a8..9ab7719 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ android-compileSdk = "34" java-toolchain = "17" compose = "1.6.11" -agp = "8.4.2" +agp = "8.3.2" kotlin = "2.0.0" publish = "0.29.0" nexus-publish = "2.0.0" diff --git a/jsontree/build.gradle.kts b/jsontree/build.gradle.kts index bfbda74..addbb2d 100644 --- a/jsontree/build.gradle.kts +++ b/jsontree/build.gradle.kts @@ -86,7 +86,6 @@ kotlin { } } - android { namespace = "com.sebastianneubauer.jsontree" compileSdk = libs.versions.android.compileSdk.get().toInt() diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index 00bd08c..7c46681 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -65,8 +65,6 @@ kotlin { } - - android { namespace = "com.sebastianneubauer.jsontreesample" compileSdk = 34 diff --git a/sample/src/commonMain/kotlin/App.kt b/sample/src/commonMain/kotlin/App.kt index 2ef6c25..f8789f7 100644 --- a/sample/src/commonMain/kotlin/App.kt +++ b/sample/src/commonMain/kotlin/App.kt @@ -22,6 +22,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -39,22 +40,23 @@ import com.sebastianneubauer.jsontree.defaultLightColors import com.sebastianneubauer.jsontreesample.ui.theme.JsonTreeTheme import org.jetbrains.compose.ui.tooling.preview.Preview - @Composable internal fun App() = JsonTreeTheme { MainScreen() } @OptIn( - ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class, ExperimentalLayoutApi::class + ExperimentalMaterial3Api::class, + ExperimentalFoundationApi::class, + ExperimentalLayoutApi::class ) @Composable -fun MainScreen() { - +private fun MainScreen() { Scaffold( modifier = Modifier.safeDrawingPadding(), topBar = { CenterAlignedTopAppBar( + colors = TopAppBarDefaults.centerAlignedTopAppBarColors(containerColor = Color.White), title = { Text( modifier = Modifier.padding(horizontal = 16.dp), @@ -68,7 +70,9 @@ fun MainScreen() { contentWindowInsets = WindowInsets(top = 60.dp), ) { padding -> Column( - modifier = Modifier.fillMaxSize().padding(padding) + modifier = Modifier + .fillMaxSize() + .padding(padding) ) { var errorMessage: String? by remember { mutableStateOf(null) } var json: String by remember { mutableStateOf(simpleJson) } @@ -78,17 +82,24 @@ fun MainScreen() { var showItemCount: Boolean by remember { mutableStateOf(true) } var expandSingleChildren: Boolean by remember { mutableStateOf(true) } - FlowRow { - Button(modifier = Modifier.padding(horizontal = 8.dp), onClick = { - errorMessage = null - json = when (json) { - emptyJson -> simpleJson - simpleJson -> complexJson - complexJson -> invalidJson - invalidJson -> emptyJson - else -> throw IllegalStateException("No JSON selected!") + FlowRow( + modifier = Modifier + .fillMaxWidth() + .background(color = Color.White), + ) { + Button( + modifier = Modifier.padding(horizontal = 8.dp), + onClick = { + errorMessage = null + json = when (json) { + emptyJson -> simpleJson + simpleJson -> complexJson + complexJson -> invalidJson + invalidJson -> emptyJson + else -> throw IllegalStateException("No JSON selected!") + } } - }) { + ) { Text( text = when (json) { simpleJson -> "Simple Json" @@ -100,36 +111,47 @@ fun MainScreen() { ) } - Button(modifier = Modifier.padding(horizontal = 8.dp), onClick = { - val newState = when (initialState) { - TreeState.EXPANDED -> TreeState.COLLAPSED - TreeState.COLLAPSED -> TreeState.FIRST_ITEM_EXPANDED - TreeState.FIRST_ITEM_EXPANDED -> TreeState.EXPANDED + Button( + modifier = Modifier.padding(horizontal = 8.dp), + onClick = { + val newState = when (initialState) { + TreeState.EXPANDED -> TreeState.COLLAPSED + TreeState.COLLAPSED -> TreeState.FIRST_ITEM_EXPANDED + TreeState.FIRST_ITEM_EXPANDED -> TreeState.EXPANDED + } + initialState = newState } - initialState = newState - }) { + ) { Text(text = initialState.name) } - Button(modifier = Modifier.padding(horizontal = 8.dp), - onClick = { showIndices = !showIndices }) { + Button( + modifier = Modifier.padding(horizontal = 8.dp), + onClick = { showIndices = !showIndices } + ) { Text(text = if (showIndices) "Hide indices" else "Show indices") } - Button(modifier = Modifier.padding(horizontal = 8.dp), - onClick = { showItemCount = !showItemCount }) { + Button( + modifier = Modifier.padding(horizontal = 8.dp), + onClick = { showItemCount = !showItemCount } + ) { Text(text = if (showItemCount) "Hide item count" else "Show item count") } - Button(modifier = Modifier.padding(horizontal = 8.dp), onClick = { - colors = - if (colors == defaultLightColors) defaultDarkColors else defaultLightColors - }) { + Button( + modifier = Modifier.padding(horizontal = 8.dp), + onClick = { + colors = if (colors == defaultLightColors) defaultDarkColors else defaultLightColors + } + ) { Text(text = if (colors == defaultLightColors) "Light" else "Dark") } - Button(modifier = Modifier.padding(horizontal = 8.dp), - onClick = { expandSingleChildren = !expandSingleChildren }) { + Button( + modifier = Modifier.padding(horizontal = 8.dp), + onClick = { expandSingleChildren = !expandSingleChildren } + ) { Text(text = if (expandSingleChildren) "Expand children" else "Don't expand children") } } @@ -147,12 +169,20 @@ fun MainScreen() { val error = errorMessage if (error != null) { Text( - text = error, color = Color.Black + modifier = Modifier + .fillMaxSize() + .background( + color = if (colors == defaultLightColors) Color.White else Color.Black + ), + text = error, + color = if (colors == defaultLightColors) Color.Black else Color.White, ) } else { JsonTree( - modifier = Modifier.fillMaxSize() - .horizontalScroll(rememberScrollState()).background( + modifier = Modifier + .fillMaxSize() + .horizontalScroll(rememberScrollState()) + .background( if (colors == defaultLightColors) Color.White else Color.Black ), contentPadding = PaddingValues(16.dp), @@ -191,9 +221,8 @@ fun MainScreen() { } } - @Preview @Composable -fun PreviewMainScreen() = JsonTreeTheme { +private fun PreviewMainScreen() = JsonTreeTheme { MainScreen() } \ No newline at end of file From 3bd2d30e5dfd4443a11794ddea2dda39d8eb1155 Mon Sep 17 00:00:00 2001 From: snappdevelopment Date: Tue, 3 Sep 2024 08:02:13 +0200 Subject: [PATCH 3/7] Add ios files to gitignore --- .gitignore | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.gitignore b/.gitignore index 4777b70..a2fe686 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,23 @@ captures/ .kotlin +# Xcode +*.xcodeproj/* +!*.xcodeproj/project.pbxproj +!*.xcodeproj/xcshareddata/ +!*.xcodeproj/project.xcworkspace/ +!*.xcworkspace/contents.xcworkspacedata +**/xcshareddata/WorkspaceSettings.xcsettings +xcuserdata + +# CocoaPods +Pods/ + +# iOS App packaging +*.ipa +*.dSYM.zip +*.dSYM + # Keystore files # Uncomment the following lines if you do not want to check your keystore files in. #*.jks From a51f986a71318abe2db5f82e175e507ac6619dc2 Mon Sep 17 00:00:00 2001 From: snappdevelopment Date: Wed, 4 Sep 2024 07:19:01 +0200 Subject: [PATCH 4/7] Add file to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a2fe686..a3c1abe 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,7 @@ captures/ !*.xcworkspace/contents.xcworkspacedata **/xcshareddata/WorkspaceSettings.xcsettings xcuserdata +IDEWorkspaceChecks.plist # CocoaPods Pods/ From ba4c852efa60ca6ed01256f8f4fe1b7cc18dcb61 Mon Sep 17 00:00:00 2001 From: snappdevelopment Date: Wed, 4 Sep 2024 07:44:26 +0200 Subject: [PATCH 5/7] Rename CI tasks --- .github/workflows/check-pr.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check-pr.yaml b/.github/workflows/check-pr.yaml index 96985ec..5a27f81 100644 --- a/.github/workflows/check-pr.yaml +++ b/.github/workflows/check-pr.yaml @@ -8,7 +8,7 @@ on: workflow_call: jobs: - assembleDebug: + assembleAndroidDebug: runs-on: macos-latest steps: @@ -21,10 +21,10 @@ jobs: distribution: 'zulu' java-version: '17' - - name: Assemble Debug + - name: Assemble Android Debug run: ./gradlew assembleDebug --stacktrace - assembleRelease: + assembleAndroidRelease: runs-on: macos-latest steps: @@ -37,7 +37,7 @@ jobs: distribution: 'zulu' java-version: '17' - - name: Assemble Release + - name: Assemble Android Release run: ./gradlew assembleRelease --stacktrace # UI tests on CI are flaky @@ -64,7 +64,7 @@ jobs: check: runs-on: macos-latest - needs: [assembleDebug, assembleRelease] + needs: [assembleAndroidDebug, assembleAndroidRelease] steps: - name: Checkout code @@ -81,7 +81,7 @@ jobs: detekt: runs-on: macos-latest - needs: [assembleDebug, assembleRelease] + needs: [assembleAndroidDebug, assembleAndroidRelease] steps: - name: Checkout code From b71660801ba22cabc7f5bad789b5e7bff6582b9d Mon Sep 17 00:00:00 2001 From: snappdevelopment Date: Fri, 6 Sep 2024 07:49:19 +0200 Subject: [PATCH 6/7] Remove unused lib version --- gradle/libs.versions.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9ab7719..d65289a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,7 +8,6 @@ compose = "1.6.11" agp = "8.3.2" kotlin = "2.0.0" publish = "0.29.0" -nexus-publish = "2.0.0" api-validator = "0.16.3" atomicfuGradlePlugin = "0.22.0" From 07d52398ec469f819a9dc2a1467be89af32046c5 Mon Sep 17 00:00:00 2001 From: snappdevelopment Date: Sat, 7 Sep 2024 09:54:14 +0200 Subject: [PATCH 7/7] Adjust CI --- .github/workflows/check-pr.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check-pr.yaml b/.github/workflows/check-pr.yaml index 5a27f81..664bba0 100644 --- a/.github/workflows/check-pr.yaml +++ b/.github/workflows/check-pr.yaml @@ -62,7 +62,7 @@ jobs: # arch: x86_64 # script: ./gradlew connectedCheck --stacktrace - check: + test: runs-on: macos-latest needs: [assembleAndroidDebug, assembleAndroidRelease] @@ -76,8 +76,8 @@ jobs: distribution: 'zulu' java-version: '17' - - name: Run checks - run: ./gradlew check --stacktrace + - name: Run tests + run: ./gradlew :jsontree:jvmTest --tests com.sebastianneubauer.jsontree.JsonTreeParserTest --stacktrace detekt: runs-on: macos-latest