Skip to content

Commit

Permalink
Make KtfmtConfig.ConfigurableStyle#configure public
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler committed Dec 2, 2023
1 parent 28e948e commit 5f840aa
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
2 changes: 2 additions & 0 deletions plugin-gradle/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).

## [Unreleased]
### Fixed
* Make `KtfmtConfig.ConfigurableStyle#configure` public. ([#1926](https://github.com/diffplug/spotless/pull/1926))

## [6.23.2] - 2023-12-01
### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private FormatterStep createStep() {
}

public class ConfigurableStyle {
private void configure(Consumer<KtfmtStep.KtfmtFormattingOptions> optionsConfiguration) {
public void configure(Consumer<KtfmtStep.KtfmtFormattingOptions> optionsConfiguration) {
KtfmtStep.KtfmtFormattingOptions ktfmtFormattingOptions = new KtfmtStep.KtfmtFormattingOptions();
optionsConfiguration.accept(ktfmtFormattingOptions);
options = ktfmtFormattingOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,26 @@ void integrationDiktat() throws IOException {
}

@Test
void integrationKtfmt_dropboxStyle_0_19() throws IOException {
setFile("build.gradle").toLines(
void integrationKtfmtDropboxStyleWithPublicApi() throws IOException {
setFile("build.gradle.kts").toLines(
"plugins {",
" id 'org.jetbrains.kotlin.jvm' version '1.6.21'",
" id 'com.diffplug.spotless'",
" id(\"org.jetbrains.kotlin.jvm\") version \"1.6.21\"",
" id(\"com.diffplug.spotless\")",
"}",
"repositories { mavenCentral() }",
"spotless {",
" kotlin {",
" ktfmt('0.19').dropboxStyle()",
" ktfmt().dropboxStyle().configure {",
" it.setMaxWidth(4)",
" it.setBlockIndent(4)",
" it.setContinuationIndent(4)",
" it.setRemoveUnusedImport(false)",
" }",
" }",
"}");
setFile("src/main/kotlin/basic.kt").toResource("kotlin/ktfmt/basic.dirty");
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/kotlin/basic.kt").sameAsResource("kotlin/ktfmt/basic-dropboxstyle.clean");
assertFile("src/main/kotlin/basic.kt").sameAsResource("kotlin/ktfmt/basic-dropbox-style.clean");
}

@Test
Expand Down
14 changes: 14 additions & 0 deletions testlib/src/main/resources/kotlin/ktfmt/basic-dropbox-style.clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import a.*
import a.b
import a.b.c.*
import kotlinx.android.synthetic.main.layout_name.*

fun main() {
fun name() {
a()
return b
}
println(
";")
println()
}

0 comments on commit 5f840aa

Please sign in to comment.