Skip to content

Commit

Permalink
kotlin 1.8.10 and friends
Browse files Browse the repository at this point in the history
- kotlin `1.8.10`
- ksp `1.8.10-1.0.9`
- drop Kotlinter because it doesn't play nicely with KSP's new source sets
- replace Kotlinter with `com.rickbusarow.ktlint`
- KtLint `0.49.1`
  - this comes with updated `.editorconfig` requirements
  • Loading branch information
RBusarow committed Jun 12, 2023
1 parent dad9819 commit e79a755
Show file tree
Hide file tree
Showing 58 changed files with 465 additions and 537 deletions.
221 changes: 122 additions & 99 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,132 @@ ij_formatter_tags_enabled = false
ij_smart_tabs = false
ij_wrap_on_typing = false

# 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}]
ij_continuation_indent_size = 2
ij_kotlin_align_in_columns_case_branch = false
ij_kotlin_align_multiline_binary_operation = false
ij_kotlin_align_multiline_extends_list = false
ij_kotlin_align_multiline_method_parentheses = false
ij_kotlin_align_multiline_parameters = false
ij_kotlin_align_multiline_parameters_in_calls = false
ij_kotlin_allow_trailing_comma = false
ij_kotlin_allow_trailing_comma_on_call_site = false
ij_kotlin_assignment_wrap = normal
ij_kotlin_blank_lines_after_class_header = 0
ij_kotlin_blank_lines_around_block_when_branches = 0
ij_kotlin_blank_lines_before_declaration_with_comment_or_annotation_on_separate_line = 1
ij_kotlin_block_comment_at_first_column = true
ij_kotlin_call_parameters_new_line_after_left_paren = true
ij_kotlin_call_parameters_right_paren_on_new_line = true
ij_kotlin_call_parameters_wrap = normal
ij_kotlin_catch_on_new_line = false
ij_kotlin_class_annotation_wrap = split_into_lines
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
ij_kotlin_continuation_indent_for_chained_calls = true
ij_kotlin_continuation_indent_for_expression_bodies = false
ij_kotlin_continuation_indent_in_argument_lists = true
ij_kotlin_continuation_indent_in_elvis = true
ij_kotlin_continuation_indent_in_if_conditions = true
ij_kotlin_continuation_indent_in_parameter_lists = false
ij_kotlin_continuation_indent_in_supertype_lists = true
ij_kotlin_else_on_new_line = false
ij_kotlin_enum_constants_wrap = split_into_lines
ij_kotlin_extends_list_wrap = on_every_item
ij_kotlin_field_annotation_wrap = normal
ij_kotlin_finally_on_new_line = false
ij_kotlin_if_rparen_on_new_line = true
ij_kotlin_import_nested_classes = true
ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^
ij_kotlin_insert_whitespaces_in_simple_one_line_method = true
ij_kotlin_keep_blank_lines_before_right_brace = 0
ij_kotlin_keep_blank_lines_in_code = 1
ij_kotlin_keep_blank_lines_in_declarations = 1
ij_kotlin_keep_first_column_comment = true
ij_kotlin_keep_indents_on_empty_lines = false
ij_kotlin_keep_line_breaks = true
ij_kotlin_lbrace_on_next_line = false
ij_kotlin_line_comment_add_space = true
ij_kotlin_line_comment_at_first_column = false
ij_kotlin_method_annotation_wrap = normal
ij_kotlin_method_call_chain_wrap = on_every_item
ij_kotlin_method_parameters_new_line_after_left_paren = true
ij_kotlin_method_parameters_right_paren_on_new_line = true
ij_kotlin_method_parameters_wrap = split_into_lines
ij_kotlin_name_count_to_use_star_import = 999
ij_kotlin_name_count_to_use_star_import_for_members = 999
ij_kotlin_parameter_annotation_wrap = off
ij_kotlin_space_after_comma = true
ij_kotlin_space_after_extend_colon = true
ij_kotlin_space_after_type_colon = true
ij_kotlin_space_before_catch_parentheses = true
ij_kotlin_space_before_comma = false
ij_kotlin_space_before_extend_colon = true
ij_kotlin_space_before_for_parentheses = true
ij_kotlin_space_before_if_parentheses = true
ij_kotlin_space_before_lambda_arrow = true
ij_kotlin_space_before_type_colon = false
ij_kotlin_space_before_when_parentheses = true
ij_kotlin_space_before_while_parentheses = true
ij_kotlin_spaces_around_additive_operators = true
ij_kotlin_spaces_around_assignment_operators = true
ij_kotlin_spaces_around_equality_operators = true
ij_kotlin_spaces_around_function_type_arrow = true
ij_kotlin_spaces_around_logical_operators = true
ij_kotlin_spaces_around_multiplicative_operators = true
ij_kotlin_spaces_around_range = false
ij_kotlin_spaces_around_relational_operators = true
ij_kotlin_spaces_around_unary_operator = false
ij_kotlin_spaces_around_when_arrow = true
ij_kotlin_variable_annotation_wrap = off
ij_kotlin_while_on_new_line = false
ij_kotlin_wrap_elvis_expressions = 1
ij_kotlin_wrap_expression_body_functions = 1
ij_kotlin_wrap_first_method_in_call_chain = false

[{*.yaml,*.yml}]
ij_yaml_keep_indents_on_empty_lines = false
ij_yaml_keep_line_breaks = true
ij_yaml_space_before_colon = true
ij_yaml_spaces_within_braces = true
ij_yaml_spaces_within_brackets = true

[.editorconfig]
ij_editorconfig_align_group_field_declarations = false
ij_editorconfig_space_after_colon = false
# IntelliJ defaults this to true, but that's against the editorconfig spec and ktlint can't actually parse it.
# https://youtrack.jetbrains.com/issue/IDEA-242506
# https://github.com/editorconfig/editorconfig/issues/148
ij_editorconfig_space_after_comma = false
ij_editorconfig_space_before_colon = false
ij_editorconfig_space_before_comma = false
ij_editorconfig_spaces_around_assignment_operators = true

[*.java]
ij_java_align_consecutive_assignments = false
ij_java_align_consecutive_variable_declarations = false
Expand Down Expand Up @@ -270,14 +392,6 @@ ij_properties_keep_blank_lines = false
ij_properties_key_value_delimiter = equals
ij_properties_spaces_around_key_value_delimiter = false

[.editorconfig]
ij_editorconfig_align_group_field_declarations = false
ij_editorconfig_space_after_colon = false
ij_editorconfig_space_after_comma = true
ij_editorconfig_space_before_colon = false
ij_editorconfig_space_before_comma = false
ij_editorconfig_spaces_around_assignment_operators = true

[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.jspx,*.pom,*.rng,*.tagx,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul}]
ij_xml_align_attributes = false
ij_xml_align_text = false
Expand Down Expand Up @@ -483,90 +597,6 @@ 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}]
# noinspection EditorConfigKeyCorrectness
ktlint_disabled_rules = trailing-comma-on-declaration-site,trailing-comma-on-call-site
ij_continuation_indent_size = 2
ij_kotlin_align_in_columns_case_branch = false
ij_kotlin_align_multiline_binary_operation = false
ij_kotlin_align_multiline_extends_list = false
ij_kotlin_align_multiline_method_parentheses = false
ij_kotlin_align_multiline_parameters = false
ij_kotlin_align_multiline_parameters_in_calls = false
ij_kotlin_allow_trailing_comma = false
ij_kotlin_allow_trailing_comma_on_call_site = false
ij_kotlin_assignment_wrap = normal
ij_kotlin_blank_lines_after_class_header = 0
ij_kotlin_blank_lines_around_block_when_branches = 0
ij_kotlin_blank_lines_before_declaration_with_comment_or_annotation_on_separate_line = 1
ij_kotlin_block_comment_at_first_column = true
ij_kotlin_call_parameters_new_line_after_left_paren = true
ij_kotlin_call_parameters_right_paren_on_new_line = true
ij_kotlin_call_parameters_wrap = normal
ij_kotlin_catch_on_new_line = false
ij_kotlin_class_annotation_wrap = split_into_lines
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
ij_kotlin_continuation_indent_for_chained_calls = true
ij_kotlin_continuation_indent_for_expression_bodies = false
ij_kotlin_continuation_indent_in_argument_lists = true
ij_kotlin_continuation_indent_in_elvis = true
ij_kotlin_continuation_indent_in_if_conditions = true
ij_kotlin_continuation_indent_in_parameter_lists = false
ij_kotlin_continuation_indent_in_supertype_lists = true
ij_kotlin_else_on_new_line = false
ij_kotlin_enum_constants_wrap = split_into_lines
ij_kotlin_extends_list_wrap = on_every_item
ij_kotlin_field_annotation_wrap = normal
ij_kotlin_finally_on_new_line = false
ij_kotlin_if_rparen_on_new_line = true
ij_kotlin_import_nested_classes = true
ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^
ij_kotlin_insert_whitespaces_in_simple_one_line_method = true
ij_kotlin_keep_blank_lines_before_right_brace = 0
ij_kotlin_keep_blank_lines_in_code = 1
ij_kotlin_keep_blank_lines_in_declarations = 1
ij_kotlin_keep_first_column_comment = true
ij_kotlin_keep_indents_on_empty_lines = false
ij_kotlin_keep_line_breaks = true
ij_kotlin_lbrace_on_next_line = false
ij_kotlin_line_comment_add_space = true
ij_kotlin_line_comment_at_first_column = false
ij_kotlin_method_annotation_wrap = normal
ij_kotlin_method_call_chain_wrap = on_every_item
ij_kotlin_method_parameters_new_line_after_left_paren = true
ij_kotlin_method_parameters_right_paren_on_new_line = true
ij_kotlin_method_parameters_wrap = split_into_lines
ij_kotlin_name_count_to_use_star_import = 999
ij_kotlin_name_count_to_use_star_import_for_members = 999
ij_kotlin_parameter_annotation_wrap = off
ij_kotlin_space_after_comma = true
ij_kotlin_space_after_extend_colon = true
ij_kotlin_space_after_type_colon = true
ij_kotlin_space_before_catch_parentheses = true
ij_kotlin_space_before_comma = false
ij_kotlin_space_before_extend_colon = true
ij_kotlin_space_before_for_parentheses = true
ij_kotlin_space_before_if_parentheses = true
ij_kotlin_space_before_lambda_arrow = true
ij_kotlin_space_before_type_colon = false
ij_kotlin_space_before_when_parentheses = true
ij_kotlin_space_before_while_parentheses = true
ij_kotlin_spaces_around_additive_operators = true
ij_kotlin_spaces_around_assignment_operators = true
ij_kotlin_spaces_around_equality_operators = true
ij_kotlin_spaces_around_function_type_arrow = true
ij_kotlin_spaces_around_logical_operators = true
ij_kotlin_spaces_around_multiplicative_operators = true
ij_kotlin_spaces_around_range = false
ij_kotlin_spaces_around_relational_operators = true
ij_kotlin_spaces_around_unary_operator = false
ij_kotlin_spaces_around_when_arrow = true
ij_kotlin_variable_annotation_wrap = off
ij_kotlin_while_on_new_line = false
ij_kotlin_wrap_elvis_expressions = 1
ij_kotlin_wrap_expression_body_functions = 1
ij_kotlin_wrap_first_method_in_call_chain = false

[{*.har,*.json}]
tab_width = 4
ij_continuation_indent_size = 8
Expand Down Expand Up @@ -611,10 +641,3 @@ ij_html_space_around_equality_in_attribute = false
ij_html_space_inside_empty_tag = false
ij_html_text_wrap = normal
ij_html_uniform_ident = false

[{*.yaml,*.yml}]
ij_yaml_keep_indents_on_empty_lines = false
ij_yaml_keep_line_breaks = true
ij_yaml_space_before_colon = true
ij_yaml_spaces_within_braces = true
ij_yaml_spaces_within_brackets = true
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
Loading

0 comments on commit e79a755

Please sign in to comment.