Skip to content

Commit 5042ae9

Browse files
committed
More test fixes for post-buildscript-repo, especially switching to the new kotlin plugin.
1 parent e55aebf commit 5042ae9

File tree

6 files changed

+27
-33
lines changed

6 files changed

+27
-33
lines changed

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/Antlr4ExtensionTest.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,10 @@ class Antlr4ExtensionTest extends GradleIntegrationHarness {
2424
@Test
2525
void applyUsingDefaultVersion() throws IOException {
2626
String[] buildScript = {
27-
"buildscript {",
28-
" repositories {",
29-
" mavenCentral()",
30-
" }",
31-
"}",
3227
"plugins {",
3328
" id 'com.diffplug.spotless'",
3429
"}",
30+
"repositories { mavenCentral() }",
3531
"spotless {",
3632
" antlr4 {",
3733
" target 'src/main/antlr4/**/*.g4'",
@@ -45,14 +41,10 @@ void applyUsingDefaultVersion() throws IOException {
4541
@Test
4642
void applyUsingCustomVersion() throws IOException {
4743
String[] buildScript = {
48-
"buildscript {",
49-
" repositories {",
50-
" mavenCentral()",
51-
" }",
52-
"}",
5344
"plugins {",
5445
" id 'com.diffplug.spotless'",
5546
"}",
47+
"repositories { mavenCentral() }",
5648
"spotless {",
5749
" antlr4 {",
5850
" target 'src/main/antlr4/**/*.g4'",

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinExtensionTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class KotlinExtensionTest extends GradleIntegrationHarness {
3232
void integration() throws IOException {
3333
setFile("build.gradle").toLines(
3434
"plugins {",
35-
" id 'nebula.kotlin' version '1.3.72'",
35+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
3636
" id 'com.diffplug.spotless'",
3737
"}",
3838
"repositories { mavenCentral() }",
@@ -69,7 +69,7 @@ void integrationDiktat() throws IOException {
6969
void integrationKtfmt() throws IOException {
7070
setFile("build.gradle").toLines(
7171
"plugins {",
72-
" id 'nebula.kotlin' version '1.3.72'",
72+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
7373
" id 'com.diffplug.spotless'",
7474
"}",
7575
"repositories { mavenCentral() }",
@@ -88,7 +88,7 @@ void integrationKtfmt() throws IOException {
8888
void integrationKtfmt_dropboxStyle_0_18() throws IOException {
8989
setFile("build.gradle").toLines(
9090
"plugins {",
91-
" id 'nebula.kotlin' version '1.3.72'",
91+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
9292
" id 'com.diffplug.spotless'",
9393
"}",
9494
"repositories { mavenCentral() }",
@@ -107,7 +107,7 @@ void integrationKtfmt_dropboxStyle_0_18() throws IOException {
107107
void integrationKtfmt_dropboxStyle_0_19() throws IOException {
108108
setFile("build.gradle").toLines(
109109
"plugins {",
110-
" id 'nebula.kotlin' version '1.3.72'",
110+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
111111
" id 'com.diffplug.spotless'",
112112
"}",
113113
"repositories { mavenCentral() }",
@@ -125,13 +125,13 @@ void integrationKtfmt_dropboxStyle_0_19() throws IOException {
125125
void testWithIndentation() throws IOException {
126126
setFile("build.gradle").toLines(
127127
"plugins {",
128-
" id 'nebula.kotlin' version '1.3.72'",
128+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
129129
" id 'com.diffplug.spotless'",
130130
"}",
131131
"repositories { mavenCentral() }",
132132
"spotless {",
133133
" kotlin {",
134-
" ktlint('0.21.0').userData(['indent_size': '6'])",
134+
" ktlint('0.32.0').userData(['indent_size': '6'])",
135135
" }",
136136
"}");
137137
setFile("src/main/kotlin/basic.kt").toResource("kotlin/ktlint/basic.dirty");
@@ -143,7 +143,7 @@ void testWithIndentation() throws IOException {
143143
void testWithHeader() throws IOException {
144144
setFile("build.gradle").toLines(
145145
"plugins {",
146-
" id 'nebula.kotlin' version '1.3.72'",
146+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
147147
" id 'com.diffplug.spotless'",
148148
"}",
149149
"repositories { mavenCentral() }",
@@ -163,7 +163,7 @@ void testWithHeader() throws IOException {
163163
void testWithHeaderKtfmt() throws IOException {
164164
setFile("build.gradle").toLines(
165165
"plugins {",
166-
" id 'nebula.kotlin' version '1.3.72'",
166+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
167167
" id 'com.diffplug.spotless'",
168168
"}",
169169
"repositories { mavenCentral() }",
@@ -182,7 +182,7 @@ void testWithHeaderKtfmt() throws IOException {
182182
void testWithCustomHeaderSeparator() throws IOException {
183183
setFile("build.gradle").toLines(
184184
"plugins {",
185-
" id 'nebula.kotlin' version '1.3.72'",
185+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
186186
" id 'com.diffplug.spotless'",
187187
"}",
188188
"repositories { mavenCentral() }",
@@ -202,7 +202,7 @@ void testWithCustomHeaderSeparator() throws IOException {
202202
void testWithCustomHeaderSeparatorKtfmt() throws IOException {
203203
setFile("build.gradle").toLines(
204204
"plugins {",
205-
" id 'nebula.kotlin' version '1.3.72'",
205+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
206206
" id 'com.diffplug.spotless'",
207207
"}",
208208
"repositories { mavenCentral() }",
@@ -221,7 +221,7 @@ void testWithCustomHeaderSeparatorKtfmt() throws IOException {
221221
void testWithNonStandardYearSeparator() throws IOException {
222222
setFile("build.gradle").toLines(
223223
"plugins {",
224-
" id 'nebula.kotlin' version '1.3.72'",
224+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
225225
" id 'com.diffplug.spotless'",
226226
"}",
227227
"repositories { mavenCentral() }",
@@ -248,7 +248,7 @@ void testWithNonStandardYearSeparator() throws IOException {
248248
void testWithNonStandardYearSeparatorKtfmt() throws IOException {
249249
setFile("build.gradle").toLines(
250250
"plugins {",
251-
" id 'nebula.kotlin' version '1.3.72'",
251+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
252252
" id 'com.diffplug.spotless'",
253253
"}",
254254
"repositories { mavenCentral() }",

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinGradleExtensionTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void integration_script_in_subdir() throws IOException {
3838
private void testInDirectory(final String directory) throws IOException {
3939
setFile("build.gradle").toLines(
4040
"plugins {",
41-
" id 'nebula.kotlin' version '1.3.72'",
41+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
4242
" id 'com.diffplug.spotless'",
4343
"}",
4444
"repositories { mavenCentral() }",
@@ -61,7 +61,7 @@ private void testInDirectory(final String directory) throws IOException {
6161
void integration_default() throws IOException {
6262
setFile("build.gradle").toLines(
6363
"plugins {",
64-
" id 'nebula.kotlin' version '1.3.72'",
64+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
6565
" id 'com.diffplug.spotless'",
6666
"}",
6767
"repositories { mavenCentral() }",
@@ -98,13 +98,13 @@ void integration_default_diktat() throws IOException {
9898
void integration_pinterest() throws IOException {
9999
setFile("build.gradle").toLines(
100100
"plugins {",
101-
" id 'nebula.kotlin' version '1.3.72'",
101+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
102102
" id 'com.diffplug.spotless'",
103103
"}",
104104
"repositories { mavenCentral() }",
105105
"spotless {",
106106
" kotlinGradle {",
107-
" ktlint('0.21.0')",
107+
" ktlint('0.32.0')",
108108
" }",
109109
"}");
110110
setFile("configuration.gradle.kts").toResource("kotlin/ktlint/basic.dirty");
@@ -116,7 +116,7 @@ void integration_pinterest() throws IOException {
116116
void indentStep() throws IOException {
117117
setFile("build.gradle").toLines(
118118
"plugins {",
119-
" id 'nebula.kotlin' version '1.3.72'",
119+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
120120
" id 'com.diffplug.spotless'",
121121
"}",
122122
"repositories { mavenCentral() }",
@@ -134,7 +134,7 @@ void indentStep() throws IOException {
134134
void integration_ktfmt() throws IOException {
135135
setFile("build.gradle").toLines(
136136
"plugins {",
137-
" id 'nebula.kotlin' version '1.3.72'",
137+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
138138
" id 'com.diffplug.spotless'",
139139
"}",
140140
"repositories { mavenCentral() }",
@@ -153,7 +153,7 @@ void integration_ktfmt() throws IOException {
153153
void integration_ktfmt_with_dropbox_style() throws IOException {
154154
setFile("build.gradle").toLines(
155155
"plugins {",
156-
" id 'nebula.kotlin' version '1.3.72'",
156+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
157157
" id 'com.diffplug.spotless'",
158158
"}",
159159
"repositories { mavenCentral() }",
@@ -171,7 +171,7 @@ void integration_ktfmt_with_dropbox_style() throws IOException {
171171
void integration_lint_script_files_without_top_level_declaration() throws IOException {
172172
setFile("build.gradle").toLines(
173173
"plugins {",
174-
" id 'nebula.kotlin' version '1.3.72'",
174+
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
175175
" id 'com.diffplug.spotless'",
176176
"}",
177177
"repositories { mavenCentral() }",

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/MultiProjectAfterEvaluate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class MultiProjectAfterEvaluate extends GradleIntegrationHarness {
2525
@Test
2626
void failureDoesntTriggerAll() throws IOException {
2727
setFile("settings.gradle").toLines("include 'sub'");
28-
setFile("build.gradle").toLines("buildscript { repositories { mavenCentral() }}");
28+
setFile("build.gradle").toLines("repositories { mavenCentral() }");
2929
setFile("sub/build.gradle")
3030
.toLines(
3131
"plugins {",

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/SpotlessPluginRedirectTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void redirectPluginOldGradle() throws IOException {
5454
" > We have moved from 'com.diffplug.gradle.spotless'",
5555
" to 'com.diffplug.spotless'",
5656
" To migrate:",
57-
" - Upgrade gradle to 6.1 or newer (you're on 5.0)",
57+
" - Upgrade gradle to 6.1.1 or newer (you're on 5.0)",
5858
" - Test your build with: id 'com.diffplug.gradle.spotless' version '4.5.1'"));
5959
}
6060

@@ -68,6 +68,6 @@ void realPluginOldGradle() throws IOException {
6868
Assertions.assertThat(gradleRunner().withGradleVersion(GradleVersionSupport.JRE_11.version)
6969
.buildAndFail().getOutput().replace("\r", ""))
7070
.contains(StringPrinter.buildStringFromLines(
71-
"Spotless requires Gradle 6.1 or newer, this was 5.0"));
71+
"Spotless requires Gradle 6.1.1 or newer, this was 5.0"));
7272
}
7373
}

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/WithinBlockTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ void genericFormatTest() throws IOException {
2626
// it does, and it doesn't need `it`
2727
setFile("build.gradle").toLines(
2828
"plugins { id 'com.diffplug.spotless' }",
29+
"repositories { mavenCentral() }",
2930
"import com.diffplug.gradle.spotless.JavaExtension",
3031
"spotless {",
3132
" format 'customJava', JavaExtension, {",
@@ -43,6 +44,7 @@ void withinBlocksTourDeForce() throws IOException {
4344
// but down here, we need `it`, or it will bind to the parent context, why?
4445
setFile("build.gradle").toLines(
4546
"plugins { id 'com.diffplug.spotless' }",
47+
"repositories { mavenCentral() }",
4648
"import com.diffplug.gradle.spotless.JavaExtension",
4749
"spotless {",
4850
" format 'docs', {",

0 commit comments

Comments
 (0)