test: Introduce a test harnessing predeclared deps · diffplug/spotless@4010e8b (original) (raw)

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
1 1 /*
2 - * Copyright 2016-2025 DiffPlug
2 + * Copyright 2016-2026 DiffPlug
3 3 *
4 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 5 * you may not use this file except in compliance with the License.
@@ -137,6 +137,36 @@ public void predeclaredOrdering() throws IOException {
137 137 .contains("Could not find method spotlessPredeclare() for arguments");
138 138 }
139 139
140 +@Test
141 +public void predeclaredDepsRegression() throws IOException {
142 +setFile("settings.gradle").toContent("include 'sub'");
143 +setFile("build.gradle").toLines(
144 +"plugins { id 'com.diffplug.spotless' }",
145 +"repositories { mavenCentral() }",
146 +"spotless {",
147 +" predeclareDeps()",
148 +" java {",
149 +" target file('test.java')",
150 +" googleJavaFormat('1.17.0')",
151 +" }",
152 +"}",
153 +"spotlessPredeclare {",
154 +" java { googleJavaFormat('1.17.0') }",
155 +"}");
156 +setFile("test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
157 +setFile("sub/build.gradle").toLines(
158 +"plugins { id 'com.diffplug.spotless' }",
159 +"repositories { mavenCentral() }",
160 +"spotless {",
161 +" java {",
162 +" target file('test.java')",
163 +" googleJavaFormat('1.17.0')",
164 +" }",
165 +"}");
166 +setFile("sub/test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
167 +gradleRunner().withGradleVersion("8.14").withArguments("spotlessApply").build();
168 + }
169 +
140 170 @Test
141 171 public void predeclaredUndeclared() throws IOException {
142 172 setFile("build.gradle").toLines(