Skip to content

Commit

Permalink
Update jvm target (#254)
Browse files Browse the repository at this point in the history
* Update JvmTarget to 17, refactor build scripts

* Remove apply false plugins (this doesn't work in precompiled plugins)

* remove targetCompatibility
  • Loading branch information
illarionov authored Jan 22, 2024
1 parent 982ede8 commit 15990d5
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 31 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ anvil = "2.4.9"
bmversions = "0.50.0"
detekt = "1.23.4"
diktat = "1.2.5"
detekt-compose-rules = "0.3.8"
detekt-compose-rules = "0.3.10"
dagger = "2.50"
kotlin = "1.9.22"
ksp = "1.9.22-1.0.17"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import ru.pixnews.gradle.base.versionCatalog
* Convention plugin that configures crashlytics
*/
plugins {
id("com.android.application") apply false
id("ru.pixnews.gradle.base.build-parameters")
id("com.google.firebase.crashlytics")
}
Expand All @@ -33,6 +32,6 @@ extensions.configure<ApplicationExtension>("android") {
}

dependencies {
implementation(versionCatalog.findLibrary("firebase.analytics").get())
implementation(versionCatalog.findLibrary("firebase.crashlytics").get())
add("implementation", versionCatalog.findLibrary("firebase.analytics").get())
add("implementation", versionCatalog.findLibrary("firebase.crashlytics").get())
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/

import androidx.room.gradle.RoomExtension
import com.android.build.api.dsl.CommonExtension
import ru.pixnews.gradle.base.versionCatalog

Expand All @@ -12,13 +13,12 @@ import ru.pixnews.gradle.base.versionCatalog
* For cases when [ru.pixnews.gradle.android.room] doesn't work
*/
plugins {
id("com.android.library") apply false
id("androidx.room")
id("ru.pixnews.gradle.base.build-parameters")
kotlin("kapt")
}

room {
extensions.configure<RoomExtension> {
schemaDirectory("$projectDir/schemas/")
}

Expand All @@ -35,8 +35,8 @@ extensions.configure<CommonExtension<*, *, *, *, *, *>>("android") {
}

dependencies {
annotationProcessor(versionCatalog.findLibrary("androidx.room.compiler").get())
api(versionCatalog.findLibrary("androidx.room").get())
add("annotationProcessor", versionCatalog.findLibrary("androidx.room.compiler").get())
add("api", versionCatalog.findLibrary("androidx.room").get())
add("kapt", versionCatalog.findLibrary("androidx.room.compiler").get())
testImplementation(versionCatalog.findLibrary("androidx.room.testing").get())
add("testImplementation", versionCatalog.findLibrary("androidx.room.testing").get())
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/

import androidx.room.gradle.RoomExtension
import com.android.build.api.dsl.CommonExtension
import ru.pixnews.gradle.base.versionCatalog

/**
* Convention plugin that configures Room
*/
plugins {
id("com.android.library") apply false
id("androidx.room")
id("com.google.devtools.ksp")
id("ru.pixnews.gradle.base.build-parameters")
}

room {
extensions.configure<RoomExtension> {
schemaDirectory("$projectDir/schemas/")
}

Expand All @@ -34,9 +34,9 @@ extensions.configure<CommonExtension<*, *, *, *, *, *>>("android") {
}

dependencies {
annotationProcessor(versionCatalog.findLibrary("androidx.room.compiler").get())
api(versionCatalog.findLibrary("androidx.room").get())
ksp(versionCatalog.findLibrary("androidx.room.compiler").get())
add("annotationProcessor", versionCatalog.findLibrary("androidx.room.compiler").get())
add("api", versionCatalog.findLibrary("androidx.room").get())
add("ksp", versionCatalog.findLibrary("androidx.room.compiler").get())

testImplementation(versionCatalog.findLibrary("androidx.room.testing").get())
add("testImplementation", versionCatalog.findLibrary("androidx.room.testing").get())
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import ru.pixnews.gradle.base.versionCatalog
* Convention plugin with paparazzi configuration
*/
plugins {
id("com.android.library") apply false
id("app.cash.paparazzi")
}

Expand All @@ -29,7 +28,7 @@ plugins.withType<LibraryPlugin> {
dependencies {
"testImplementation"(versionCatalog.findLibrary("junit-jupiter-vintage-engine").get())
constraints {
testImplementation("com.google.guava:guava") {
add("testImplementation", "com.google.guava:guava") {
attributes {
attribute(
TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,15 @@ internal fun Project.configureCommonAndroid(
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
// https://issuetracker.google.com/u/1/issues/266687543
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
isCoreLibraryDesugaringEnabled = true
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask<KotlinJvmCompilerOptions>>()
.configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
jvmTarget.set(JvmTarget.JVM_17)
// There are some plugins incompatible with K2 compiler:
// ComposeCompiler, R8
// languageVersion.set(KOTLIN_2_0)
Expand Down
3 changes: 1 addition & 2 deletions gradle/plugin/project/base/project-plugin-base.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
plugins {
alias(libs.plugins.kotlin.jvm)
id("ru.pixnews.gradle.base.kotlindsl")
}

group = "ru.pixnews.gradle"

dependencies {
implementation(gradleKotlinDsl())
implementation("ru.pixnews.gradle.base:gradle-build-parameters")
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ plugins.withId("java-test-fixtures") {
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask<KotlinJvmCompilerOptions>>()
.configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
jvmTarget.set(JvmTarget.JVM_17)
// D8: An error occurred when parsing kotlin metadata.
// languageVersion.set(KOTLIN_2_0)
freeCompilerArgs.addAll(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ru.pixnews.gradle.lint.configureCommonAndroidLint
* Convention plugin that configures Android Lint in projects with the Android Gradle plugin
*/
project.plugins.withType(AppPlugin::class.java) {
extensions.configure<CommonExtension<*, *, *, *, *, *>>("android") {
extensions.configure(CommonExtension::class.java) {
lint {
configureCommonAndroidLint()
checkDependencies = true
Expand All @@ -28,7 +28,7 @@ listOf(
TestPlugin::class.java,
).forEach { agpLibraryPlugin ->
plugins.withType(agpLibraryPlugin) {
extensions.configure<CommonExtension<*, *, *, *, *, *>>("android") {
extensions.configure(CommonExtension::class.java) {
lint {
configureCommonAndroidLint()
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/plugin/project/project-plugins.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
plugins {
alias(libs.plugins.kotlin.jvm) apply false
id("ru.pixnews.gradle.base.kotlindsl") apply false
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

plugins {
alias(libs.plugins.kotlin.jvm)
id("ru.pixnews.gradle.base.kotlindsl")
}

group = "ru.pixnews.gradle.testing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private fun Test.configureCommonJunit5TestOptions() {
STANDARD_ERROR,
)
}
it.events = logEvents
events = logEvents
}
}

Expand Down

0 comments on commit 15990d5

Please sign in to comment.