15
15
*/
16
16
package com .diffplug .spotless .maven .groovy ;
17
17
18
+ import java .io .IOException ;
19
+
18
20
import org .junit .jupiter .api .Test ;
19
21
20
22
import com .diffplug .spotless .maven .MavenIntegrationHarness ;
@@ -23,16 +25,43 @@ class GrEclipseTest extends MavenIntegrationHarness {
23
25
24
26
@ Test
25
27
void testEclipse () throws Exception {
26
- writePomWithGroovySteps (
27
- "<greclipse>" ,
28
- " <file>${basedir}/greclipse.properties</file>" ,
29
- " <version>4.12.0</version>" ,
30
- "</greclipse>" );
31
- setFile ("greclipse.properties" ).toResource ("groovy/greclipse/format/greclipse.properties" );
28
+ writePomWithGrEclipse ();
32
29
33
30
String path = "src/main/groovy/test.groovy" ;
34
31
setFile (path ).toResource ("groovy/greclipse/format/unformatted.test" );
35
32
mavenRunner ().withArguments ("spotless:apply" ).runNoError ();
36
33
assertFile (path ).sameAsResource ("groovy/greclipse/format/formatted.test" );
37
34
}
35
+
36
+ @ Test
37
+ void doesNotFormatJavaFiles () throws Exception {
38
+ writePomWithGrEclipse ();
39
+
40
+ String javaPath = "src/main/java/test.java" ;
41
+ String testJavaPath = "src/test/java/test.java" ;
42
+ setFile (javaPath ).toResource ("java/googlejavaformat/JavaCodeUnformatted.test" );
43
+ setFile (testJavaPath ).toResource ("java/googlejavaformat/JavaCodeUnformatted.test" );
44
+
45
+ String groovyPath = "src/main/groovy/test.groovy" ;
46
+ String testGroovyPath = "src/test/groovy/test.groovy" ;
47
+ setFile (groovyPath ).toResource ("groovy/greclipse/format/unformatted.test" );
48
+ setFile (testGroovyPath ).toResource ("groovy/greclipse/format/unformatted.test" );
49
+
50
+ mavenRunner ().withArguments ("spotless:apply" ).runNoError ();
51
+
52
+ assertFile (javaPath ).sameAsResource ("java/googlejavaformat/JavaCodeUnformatted.test" );
53
+ assertFile (testJavaPath ).sameAsResource ("java/googlejavaformat/JavaCodeUnformatted.test" );
54
+
55
+ assertFile (groovyPath ).sameAsResource ("groovy/greclipse/format/formatted.test" );
56
+ assertFile (testGroovyPath ).sameAsResource ("groovy/greclipse/format/formatted.test" );
57
+ }
58
+
59
+ private void writePomWithGrEclipse () throws IOException {
60
+ writePomWithGroovySteps (
61
+ "<greclipse>" ,
62
+ " <file>${basedir}/greclipse.properties</file>" ,
63
+ " <version>4.19.0</version>" ,
64
+ "</greclipse>" );
65
+ setFile ("greclipse.properties" ).toResource ("groovy/greclipse/format/greclipse.properties" );
66
+ }
38
67
}
0 commit comments