Skip to content

Commit 71fbef9

Browse files
authored
[RKOTLIN-1100] Clean up build system (#1770)
1 parent 97f288c commit 71fbef9

File tree

153 files changed

+1013
-672
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+1013
-672
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -329,3 +329,11 @@ DerivedData/
329329

330330
# End of https://www.gitignore.io/api/c,git,c++,java,cmake,xcode,kotlin,android,intellij,visualstudiocode
331331
dynamic_libraries.properties
332+
333+
**/.kotlin
334+
335+
**/output
336+
337+
packages/test-sync/mongodb-realm/
338+
339+
packages/m2-buildrepo

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,12 @@
9898
* Minimum Gradle version: 7.2.
9999
* Minimum Android Gradle Plugin version: 7.1.3.
100100
* Minimum Android SDK: 16.
101-
* Minimum R8: 8.0.34.
101+
* Minimum R8: 8.3.37.
102102

103103
### Internal
104104
* Updated to Realm Core 14.7.0 commit c280bdb17522323d5c30dc32a2b9efc9dc80ca3b.
105105
* Changed Kotlin compiler testing framework to https://github.com/zacsweers/kotlin-compile-testing
106+
* Updated to Detekt 1.23.6.
106107

107108

108109
## 1.16.0 (2024-05-01)

benchmarks/androidApp/build.gradle.kts

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ plugins {
55
}
66

77
android {
8+
namespace = "io.realm.kotlin.benchmarks.android"
9+
testNamespace = "io.realm.kotlin.benchmarks.android.test"
810
compileSdk = Versions.Android.compileSdkVersion
911

1012
compileOptions {

benchmarks/androidApp/src/androidTest/AndroidManifest.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
4-
package="io.realm.kotlin.benchmarks.android.test">
3+
xmlns:tools="http://schemas.android.com/tools">
54

65
<!--
76
Important: disable debugging for accurate performance results
@@ -13,5 +12,5 @@
1312
android:debuggable="false"
1413
android:requestLegacyExternalStorage="true"
1514
tools:ignore="HardcodedDebugMode"
16-
tools:replace="android:debuggable" />
15+
/>
1716
</manifest>
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest package="io.realm.kotlin.benchmarks.android" />
2+
<manifest/>

benchmarks/gradle.properties

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ kotlin.code.style=official
66

77
#Android
88
android.useAndroidX=true
9+
10+
kotlin.mpp.applyDefaultHierarchyTemplate=false

benchmarks/shared/build.gradle.kts

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ plugins {
88
version = "1.0"
99

1010
kotlin {
11-
android()
11+
androidTarget()
1212
jvm()
1313
// Disable iOS until needed
1414
// iosX64()
@@ -31,9 +31,6 @@ kotlin {
3131
implementation("io.realm.kotlin:library-sync:${Realm.version}")
3232
}
3333
}
34-
val main by creating {
35-
dependsOn(commonMain)
36-
}
3734
val androidMain by getting
3835
// Disable iOS until needed
3936
// val iosX64Main by getting
@@ -58,6 +55,7 @@ kotlin {
5855
}
5956

6057
android {
58+
namespace = "io.realm.kotlin.benchmarks"
6159
compileSdk = Versions.Android.compileSdkVersion
6260
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
6361
defaultConfig {
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest package="io.realm.kotlin.benchmarks" />
2+
<manifest/>

buildSrc/build.gradle.kts

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ dependencies {
5555
implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:${Versions.detektPlugin}")
5656
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}")
5757
implementation("com.android.tools:r8:${Versions.Android.r8}")
58-
implementation("com.android.tools.build:gradle:${Versions.Android.buildTools}") // TODO LATER Don't know why this has to be here. See if we can remove this
59-
implementation("com.android.tools.build:gradle-api:${Versions.Android.buildTools}")
58+
implementation("com.android.tools.build:gradle:${Versions.Android.buildTools}")
6059
implementation(kotlin("script-runtime"))
6160
}

buildSrc/gradle.properties

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Copyright 2024 Realm Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
kotlin.options.suppressFreeCompilerArgsModificationWarning=true

buildSrc/src/main/kotlin/Config.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ object Versions {
103103
const val buildToolsVersion = "33.0.0"
104104
const val buildTools = "7.3.1" // https://maven.google.com/web/index.html?q=gradle#com.android.tools.build:gradle
105105
const val ndkVersion = "23.2.8568313"
106-
const val r8 = "8.0.34" // See https://developer.android.com/build/kotlin-support
106+
const val r8 = "8.3.37" // See https://developer.android.com/build/kotlin-support
107107
}
108108
const val androidxBenchmarkPlugin = "1.2.0-alpha12" // https://maven.google.com/web/index.html#androidx.benchmark:androidx.benchmark.gradle.plugin
109109
const val androidxStartup = "1.1.1" // https://maven.google.com/web/index.html?q=startup#androidx.startup:startup-runtime
@@ -115,7 +115,7 @@ object Versions {
115115
const val buildkonfig = "0.13.3" // https://github.com/yshrsmz/BuildKonfig
116116
const val coroutines = "1.7.0" // https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core
117117
const val datetime = "0.4.0" // https://github.com/Kotlin/kotlinx-datetime
118-
const val detektPlugin = "1.22.0-RC2" // https://github.com/detekt/detekt
118+
const val detektPlugin = "1.23.6" // https://github.com/detekt/detekt
119119
const val dokka = "1.9.0" // https://github.com/Kotlin/dokka
120120
const val gradlePluginPublishPlugin = "0.15.0" // https://plugins.gradle.org/plugin/com.gradle.plugin-publish
121121
const val jmh = "1.34" // https://github.com/openjdk/jmh

buildSrc/src/main/kotlin/realm-lint.gradle.kts

+29-21
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import io.gitlab.arturbosch.detekt.Detekt
19+
import io.gitlab.arturbosch.detekt.extensions.DetektReports
1820
import java.nio.file.Files
1921
import java.nio.file.Paths
2022

@@ -86,30 +88,36 @@ allprojects {
8688

8789
detekt {
8890
buildUponDefaultConfig = true // preconfigure defaults
89-
config = files("$configDir/detekt/detekt.yml") // point to your custom config defining rules to run, overwriting default behavior
91+
config.from(files("$configDir/detekt/detekt.yml")) // point to your custom config defining rules to run, overwriting default behavior
9092
baseline = file("$configDir/detekt/baseline.xml") // a way of suppressing issues before introducing detekt
91-
input = files(
92-
file("src/androidMain/kotlin"),
93-
file("src/androidAndroidTest/kotlin"),
94-
file("src/androidTest/kotlin"),
95-
file("src/commonMain/kotlin"),
96-
file("src/commonTest/kotlin"),
97-
file("src/darwin/kotlin"),
98-
file("src/ios/kotlin"),
99-
file("src/iosMain/kotlin"),
100-
file("src/iosTest/kotlin"),
101-
file("src/jvm/kotlin"),
102-
file("src/jvmMain/kotlin"),
103-
file("src/main/kotlin"),
104-
file("src/macosMain/kotlin"),
105-
file("src/macosTest/kotlin"),
106-
file("src/test/kotlin")
93+
source.files.addAll(
94+
files(
95+
file("src/androidMain/kotlin"),
96+
file("src/androidAndroidTest/kotlin"),
97+
file("src/androidTest/kotlin"),
98+
file("src/commonMain/kotlin"),
99+
file("src/commonTest/kotlin"),
100+
file("src/darwin/kotlin"),
101+
file("src/ios/kotlin"),
102+
file("src/iosMain/kotlin"),
103+
file("src/iosTest/kotlin"),
104+
file("src/jvm/kotlin"),
105+
file("src/jvmMain/kotlin"),
106+
file("src/main/kotlin"),
107+
file("src/macosMain/kotlin"),
108+
file("src/macosTest/kotlin"),
109+
file("src/test/kotlin")
110+
)
107111
)
108112

109-
reports {
110-
html.enabled = true // observe findings in your browser with structure and code snippets
111-
xml.enabled = false // checkstyle like format mainly for integrations like GHA
112-
txt.enabled = false // similar to the console output, contains issue signature to manually edit baseline files
113+
tasks.withType<Detekt>().configureEach {
114+
reports {
115+
xml.required.set(true)
116+
html.required.set(true)
117+
txt.required.set(true)
118+
sarif.required.set(true)
119+
md.required.set(true)
120+
}
113121
}
114122
}
115123
}

config/detekt/detekt.yml

+10-13
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ naming:
310310
BooleanPropertyNaming:
311311
active: false
312312
allowedPattern: '^(is|has|are)'
313-
ignoreOverridden: true
314313
ClassNaming:
315314
active: true
316315
excludes: ['**/test/**', '**/androidTest/**', '**/androidAndroidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
@@ -321,7 +320,6 @@ naming:
321320
parameterPattern: '[a-z][A-Za-z0-9]*'
322321
privateParameterPattern: '[a-z][A-Za-z0-9]*'
323322
excludeClassPattern: '$^'
324-
ignoreOverridden: true
325323
EnumNaming:
326324
active: true
327325
excludes: ['**/test/**', '**/androidTest/**', '**/androidAndroidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
@@ -343,13 +341,11 @@ naming:
343341
excludes: ['**/test/**', '**/androidTest/**', '**/androidAndroidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
344342
functionPattern: '[a-z][a-zA-Z0-9]*'
345343
excludeClassPattern: '$^'
346-
ignoreOverridden: true
347344
FunctionParameterNaming:
348345
active: true
349346
excludes: ['**/test/**', '**/androidTest/**', '**/androidAndroidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
350347
parameterPattern: '[a-z][A-Za-z0-9]*'
351348
excludeClassPattern: '$^'
352-
ignoreOverridden: true
353349
InvalidPackageDeclaration:
354350
active: true
355351
rootPackage: ''
@@ -398,8 +394,7 @@ naming:
398394
variablePattern: '[a-z][A-Za-z0-9]*'
399395
privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*'
400396
excludeClassPattern: '$^'
401-
ignoreOverridden: true
402-
397+
#
403398
performance:
404399
active: true
405400
ArrayPrimitive:
@@ -549,12 +544,14 @@ style:
549544
includeLineWrapping: false
550545
ForbiddenComment:
551546
active: true
552-
values:
553-
- 'FIXME:'
554-
- 'STOPSHIP:'
555-
- 'TODO:'
547+
comments:
548+
- reason: 'Forbidden FIXME todo marker in comment, please fix the problem.'
549+
value: 'FIXME:'
550+
- reason: 'Forbidden STOPSHIP todo marker in comment, please fix the problem.'
551+
value: 'STOPSHIP:'
552+
- reason: 'Forbidden TODO todo marker in comment, please fix the problem.'
553+
value: 'TODO:'
556554
allowedPatterns: ''
557-
customMessage: ''
558555
ForbiddenImport:
559556
active: false
560557
imports: []
@@ -599,7 +596,7 @@ style:
599596
ignoreEnums: false
600597
ignoreRanges: false
601598
ignoreExtensionFunctions: true
602-
MandatoryBracesIfStatements:
599+
BracesOnIfStatements:
603600
active: false
604601
MandatoryBracesLoops:
605602
active: false
@@ -636,7 +633,7 @@ style:
636633
active: true
637634
OptionalUnit:
638635
active: false
639-
OptionalWhenBraces:
636+
BracesOnWhenStatements:
640637
active: false
641638
PreferToOverPairSyntax:
642639
active: false

examples/kmm-sample/androidApp/build.gradle.kts

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ android {
4646
}
4747
}
4848

49-
compileSdkVersion(Versions.Android.compileSdkVersion)
49+
compileSdk = Versions.Android.compileSdkVersion
5050
defaultConfig {
5151
applicationId = "io.realm.example.kmmsample.androidApp"
5252
// FIXME Use Versions.Android.minSdk when it is aligned in the SDK
53-
minSdkVersion(21)
54-
targetSdkVersion(Versions.Android.targetSdk)
53+
minSdk = 21
54+
targetSdk = Versions.Android.targetSdk
5555
versionCode = 1
5656
versionName = "$version"
5757
}

examples/kmm-sample/androidApp/src/main/java/io/realm/example/kmmsample/androidApp/MainActivity.kt

-4
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ class MainActivity : AppCompatActivity() {
4242
sumTV.text = "= 🤔"
4343
}
4444
}
45-
46-
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
47-
48-
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
4945
}
5046

5147
countTV.text = "History count: ${Calculator.history().size}"

examples/kmm-sample/gradle.properties

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ org.gradle.jvmargs=-Xms512m -Xmx2048m
2020
kotlin.code.style=official
2121
xcodeproj=./iosApp
2222
android.useAndroidX=true
23-
kotlin.mpp.enableGranularSourceSetsMetadata=true
24-
kotlin.native.enableDependencyPropagation=false
25-
23+
kotlin.mpp.applyDefaultHierarchyTemplate=false
2624
kotlin.mpp.stability.nowarn=true
2725
kotlin.mpp.androidSourceSetLayoutVersion1.nowarn=true

examples/kmm-sample/shared/build.gradle.kts

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ configurations.all {
3232

3333
kotlin {
3434
jvm()
35-
android()
35+
androidTarget()
3636
val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget = when {
3737
System.getenv("SDK_NAME")?.startsWith("iphoneos") == true -> ::iosArm64
3838
System.getenv("NATIVE_ARCH")?.startsWith("arm") == true -> ::iosSimulatorArm64
@@ -75,11 +75,11 @@ kotlin {
7575
}
7676
}
7777
android {
78-
compileSdkVersion(Versions.Android.compileSdkVersion)
78+
compileSdk = Versions.Android.compileSdkVersion
7979
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
8080
defaultConfig {
81-
minSdkVersion(Versions.Android.minSdk)
82-
targetSdkVersion(Versions.Android.targetSdk)
81+
minSdk = Versions.Android.minSdk
82+
targetSdk = Versions.Android.targetSdk
8383
}
8484
buildTypes {
8585
getByName("release") {

examples/min-android-sample/app/build.gradle.kts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ plugins {
44
}
55

66
android {
7-
compileSdkVersion(31)
7+
compileSdk = 31
88
defaultConfig {
99
applicationId = "io.realm.example.minandroidsample.android"
10-
minSdkVersion(16)
11-
targetSdkVersion(31)
10+
minSdk = 16
11+
targetSdk = 31
1212
versionCode = 1
1313
versionName = "1.0"
1414
}

examples/min-android-sample/build.gradle.kts

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ buildscript {
1212
gradlePluginPortal()
1313
google()
1414
mavenCentral()
15+
maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
1516
}
1617
dependencies {
1718
classpath("com.android.tools.build:gradle:7.1.3")
@@ -29,5 +30,6 @@ allprojects {
2930
maven(url = "file://${rootProject.rootDir.absolutePath}/../../packages/build/m2-buildrepo")
3031
google()
3132
mavenCentral()
33+
maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
3234
}
3335
}

0 commit comments

Comments
 (0)