Skip to content

Commit bf67f64

Browse files
authored
Fix bug in Spotless 6.0 related to ktlint bundling (#1013)
2 parents 039d784 + 383b827 commit bf67f64

File tree

7 files changed

+17
-8
lines changed

7 files changed

+17
-8
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1111

1212
## [Unreleased]
1313
### Changed
14+
* Bumped default ktlint from `0.43.0` to `0.43.2`.
1415
* Converted `ktlint` integration to use a compile-only source set. ([#524](https://github.com/diffplug/spotless/issues/524))
1516

1617
## [2.20.1] - 2021-12-01

lib/src/main/java/com/diffplug/spotless/kotlin/KtLintStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class KtLintStep {
3737
// prevent direct instantiation
3838
private KtLintStep() {}
3939

40-
private static final String DEFAULT_VERSION = "0.43.0";
40+
private static final String DEFAULT_VERSION = "0.43.2";
4141
static final String NAME = "ktlint";
4242
static final String PACKAGE_PRE_0_32 = "com.github.shyiko";
4343
static final String PACKAGE = "com.pinterest";

plugin-gradle/CHANGES.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).
44

55
## [Unreleased]
6+
### Changed
7+
* Bumped default ktlint from `0.43.0` to `0.43.2`.
8+
### Fixed
9+
* Fixed problem with ktlint dependency variants ([#993](https://github.com/diffplug/spotless/issues/993))
610

711
## [6.0.1] - 2021-12-01
8-
912
### Changed
1013
* Added `named` option to `licenseHeader` to support alternate license header within same format (like java) ([872](https://github.com/diffplug/spotless/issues/872)).
1114
* Added `onlyIfContentMatches` option to `licenseHeader` to skip license header application based on source file content pattern ([#650](https://github.com/diffplug/spotless/issues/650)).

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import org.gradle.api.Project;
2828
import org.gradle.api.artifacts.Configuration;
29+
import org.gradle.api.attributes.Bundling;
2930

3031
import com.diffplug.common.collect.ImmutableList;
3132
import com.diffplug.spotless.Provisioner;
@@ -76,6 +77,9 @@ private static Provisioner forProject(Project project) {
7677
.forEach(config.getDependencies()::add);
7778
config.setDescription(mavenCoords.toString());
7879
config.setTransitive(withTransitives);
80+
config.attributes(attr -> {
81+
attr.attribute(Bundling.BUNDLING_ATTRIBUTE, project.getObjects().named(Bundling.class, Bundling.EXTERNAL));
82+
});
7983
return config.resolve();
8084
} catch (Exception e) {
8185
String projName = project.getPath().substring(1).replace(':', '/');

plugin-maven/CHANGES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`).
44

55
## [Unreleased]
6+
### Changed
7+
* Bumped default ktlint from `0.43.0` to `0.43.2`.
68

79
## [2.17.5] - 2021-12-01
8-
910
### Changed
1011
* Bump jgit version ([#992](https://github.com/diffplug/spotless/pull/992)).
1112
* jgit `5.10.0.202012080955-r` -> `5.13.0.202109080827-r`

testlib/src/main/java/com/diffplug/spotless/TestProvisioner.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.gradle.api.artifacts.Dependency;
3232
import org.gradle.api.artifacts.ResolveException;
3333
import org.gradle.api.artifacts.dsl.RepositoryHandler;
34+
import org.gradle.api.attributes.Bundling;
3435
import org.gradle.testfixtures.ProjectBuilder;
3536

3637
import com.diffplug.common.base.Errors;
@@ -68,6 +69,9 @@ private static Provisioner createWithRepositories(Consumer<RepositoryHandler> re
6869
Configuration config = project.getConfigurations().detachedConfiguration(deps);
6970
config.setTransitive(withTransitives);
7071
config.setDescription(mavenCoords.toString());
72+
config.attributes(attr -> {
73+
attr.attribute(Bundling.BUNDLING_ATTRIBUTE, project.getObjects().named(Bundling.class, Bundling.EXTERNAL));
74+
});
7175
try {
7276
return config.resolve();
7377
} catch (ResolveException e) {

testlib/src/test/java/com/diffplug/spotless/kotlin/KtLintStepTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package com.diffplug.spotless.kotlin;
1717

18-
import org.junit.jupiter.api.Disabled;
1918
import org.junit.jupiter.api.Test;
2019

2120
import com.diffplug.spotless.FormatterStep;
@@ -29,18 +28,15 @@
2928
* causes these problems. The root is still a gradle bug, but in the meantime we don't
3029
* need to hold up *every* PR with this: https://github.com/gradle/gradle/issues/11752
3130
*/
32-
@Disabled
3331
class KtLintStepTest extends ResourceHarness {
3432
@Test
3533
void behavior() throws Exception {
36-
// Must use jcenter (GONE) because `com.andreapivetta.kolor:kolor:0.0.2` isn't available on mavenCentral.
37-
// It is a dependency of ktlint.
3834
FormatterStep step = KtLintStep.create(TestProvisioner.mavenCentral());
3935
StepHarness.forStep(step)
4036
.testResource("kotlin/ktlint/basic.dirty", "kotlin/ktlint/basic.clean")
4137
.testResourceException("kotlin/ktlint/unsolvable.dirty", assertion -> {
4238
assertion.isInstanceOf(AssertionError.class);
43-
assertion.hasMessage("Error on line: 1, column: 1\n" +
39+
assertion.hasMessage("Error on line: 1, column: 2\n" +
4440
"Wildcard import");
4541
});
4642
}

0 commit comments

Comments
 (0)