Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kotlin 1.8.10 and friends #1017

Merged
merged 2 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ ij_formatter_tags_enabled = false
ij_smart_tabs = false
ij_wrap_on_typing = false

# Back-ticked method names are allowed to exceed the line length. That's especially helpful for
# test methods with descriptive names.
ktlint_ignore_back_ticked_identifier = true

[*.java]
ij_java_align_consecutive_assignments = false
ij_java_align_consecutive_variable_declarations = false
Expand Down Expand Up @@ -483,7 +479,33 @@ ij_groovy_while_brace_force = if_multiline
ij_groovy_while_on_new_line = false
ij_groovy_wrap_long_lines = false

[{*.gradle.kts,*.kt,*.kts,*.main.kts}]
# KtLint specific settings
# noinspection EditorConfigKeyCorrectness
[{*.kt,*.kts}]
kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^
# Back-ticked method names are allowed to exceed the line length. That's especially helpful for
# test methods with descriptive names.
ktlint_ignore_back_ticked_identifier = true

ktlint_code_style = official
ktlint_function_signature_body_expression_wrapping = default
ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 3

ktlint_experimental_class-naming = disabled
ktlint_experimental_function-naming = disabled
ktlint_experimental_function-signature = disabled
ktlint_experimental_property-naming = disabled
ktlint_standard_class-naming = disabled
ktlint_standard_filename = disabled
ktlint_standard_function-naming = disabled
ktlint_standard_function-signature = disabled
ktlint_standard_max-line-length = disabled
ktlint_standard_no-empty-first-line-in-method-block = disabled
ktlint_standard_property-naming = disabled
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled

[{*.kt,*.kts}]
# noinspection EditorConfigKeyCorrectness
ktlint_disabled_rules = trailing-comma-on-declaration-site,trailing-comma-on-call-site
ij_continuation_indent_size = 2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kotlin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ jobs :
name : Check with Gradle
with :
arguments : |
allTests test apiCheck checkVersionIsSnapshot lint lintKotlin --continue
allTests test apiCheck checkVersionIsSnapshot lint ktlintCheck --continue
cache-read-only : false

# Report as Github Pull Request Check.
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/dungeon-benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ dependencies {
androidComponents {
beforeVariants(selector().all()) {
// TODO use it.enable when using AGP 7.3+
it.enabled = it.buildType == "release"
it.enable = it.buildType == "release"
}
}
11 changes: 6 additions & 5 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
`kotlin-dsl`
alias(libs.plugins.google.ksp)
alias(libs.plugins.ktlint)
}

repositories {
Expand All @@ -20,8 +20,6 @@ dependencies {
implementation(libs.dokka.gradle.plugin)
implementation(libs.dropbox.dependencyGuard)
implementation(libs.kotlin.gradle.plugin)
implementation(libs.ktlint.core)
implementation(libs.kotlinter)
implementation(libs.squareup.moshi)
implementation(libs.squareup.moshi.adapters)
implementation(libs.vanniktech.publish)
Expand All @@ -31,6 +29,9 @@ dependencies {

java {
// Java 11 is required when compiling against AGP 7.4.0+
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
toolchain.languageVersion.set(JavaLanguageVersion.of(11))
}

kotlin {
jvmToolchain(11)
}
2 changes: 0 additions & 2 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
enableFeaturePreview("VERSION_CATALOGS")

dependencyResolutionManagement {

@Suppress("UnstableApiUsage")
Expand Down
3 changes: 1 addition & 2 deletions build-logic/src/main/java/android-ui-tests.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ dependencies {

"androidTestImplementation"(libsCatalog.library("androidx-test-espresso-core"))
"androidTestImplementation"(libsCatalog.library("androidx-test-junit"))
"androidTestImplementation"(libsCatalog.library("squareup-leakcanary-instrumentation")
)
"androidTestImplementation"(libsCatalog.library("squareup-leakcanary-instrumentation"))
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.squareup.workflow1.buildsrc

import com.squareup.workflow1.libsCatalog
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.kotlin
Expand All @@ -10,12 +11,10 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val Project.isRunningFromIde
get() = properties["android.injected.invoked.from.ide"] == "true"

@Suppress("SuspiciousCollectionReassignment")
fun Project.kotlinCommonSettings(
bomConfigurationName: String
) {

applyKtLint()
pluginManager.apply(libsCatalog.findPlugin("ktlint").get().get().pluginId)

// force the same Kotlin version everywhere, including transitive dependencies
dependencies {
Expand All @@ -24,7 +23,6 @@ fun Project.kotlinCommonSettings(

tasks.withType<KotlinCompile> {
kotlinOptions {

jvmTarget = "1.8"

// Allow warnings when running from IDE, makes it easier to experiment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ open class ArtifactsCheckTask @Inject constructor(
YELLOW("\u001B[33m")
}

private val supported = "win" !in System.getProperty("os.name").toLowerCase(Locale.ROOT)
private val supported = "win" !in System.getProperty("os.name").lowercase(Locale.ROOT)
private fun String.colorized(color: Color) = if (supported) {
"${color.escape}$this${RESET.escape}"
} else {
Expand Down

This file was deleted.

13 changes: 7 additions & 6 deletions build-logic/src/main/java/dependency-guard.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ afterEvaluate {
// If we got here, we're either in an empty "parent" module without a build plugin
// (and no configurations), or we're in a vanilla Kotlin module. In this case, we can just look
// at configuration names.
else -> configurations
.map { it.name }
.filter {
it.endsWith("runtimeClasspath", ignoreCase = true) &&
!it.endsWith("testRuntimeClasspath", ignoreCase = true)
}
else ->
configurations
.map { it.name }
.filter {
it.endsWith("runtimeClasspath", ignoreCase = true) &&
!it.endsWith("testRuntimeClasspath", ignoreCase = true)
}
}

if (configurationNames.isNotEmpty()) {
Expand Down
1 change: 0 additions & 1 deletion build-logic/src/main/java/kotlin-jvm.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ tasks.withType<Test> {
}
}


project.kotlinCommonSettings(bomConfigurationName = "implementation")
4 changes: 1 addition & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import com.squareup.workflow1.buildsrc.applyKtLint
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
import java.net.URL

Expand Down Expand Up @@ -26,6 +25,7 @@ plugins {
base
id("artifacts-check")
id("dependency-guard")
alias(libs.plugins.ktlint)
}

subprojects {
Expand All @@ -39,8 +39,6 @@ subprojects {
}
}

applyKtLint()

apply(from = rootProject.file(".buildscript/binary-validation.gradle"))

// This plugin needs to be applied to the root projects for the dokkaGfmCollector task we use to
Expand Down
Loading