Skip to content

Commit ba7c1fd

Browse files
committed
Convert Gradle plugin from Groovy to Java
Replace existing Groovy code with Java since the Groovy Eclipse tooling currently forces the use of an old jdt plugin which has formatter bugs. Fixes gh-4113
1 parent 09395f9 commit ba7c1fd

20 files changed

+1665
-229
lines changed

spring-boot-tools/spring-boot-gradle-plugin/pom.xml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,30 +54,6 @@
5454
<scope>provided</scope>
5555
</dependency>
5656
</dependencies>
57-
<build>
58-
<sourceDirectory>src/main/groovy</sourceDirectory>
59-
<plugins>
60-
<plugin>
61-
<groupId>org.apache.maven.plugins</groupId>
62-
<artifactId>maven-compiler-plugin</artifactId>
63-
<configuration>
64-
<compilerId>groovy-eclipse-compiler</compilerId>
65-
</configuration>
66-
<dependencies>
67-
<dependency>
68-
<groupId>org.codehaus.groovy</groupId>
69-
<artifactId>groovy-eclipse-compiler</artifactId>
70-
<version>2.8.0-01</version>
71-
</dependency>
72-
<dependency>
73-
<groupId>org.codehaus.groovy</groupId>
74-
<artifactId>groovy-eclipse-batch</artifactId>
75-
<version>2.1.8-01</version>
76-
</dependency>
77-
</dependencies>
78-
</plugin>
79-
</plugins>
80-
</build>
8157
<repositories>
8258
<repository>
8359
<id>gradle</id>

spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/SpringBootPlugin.groovy

Lines changed: 0 additions & 66 deletions
This file was deleted.

spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/SpringBootPluginExtension.groovy

Lines changed: 0 additions & 133 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright 2012-2015 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.gradle;
18+
19+
import org.gradle.api.Action;
20+
import org.gradle.api.Plugin;
21+
import org.gradle.api.Project;
22+
import org.gradle.api.Task;
23+
import org.gradle.api.plugins.ApplicationPlugin;
24+
import org.gradle.api.plugins.BasePlugin;
25+
import org.gradle.api.plugins.JavaPlugin;
26+
import org.gradle.api.tasks.compile.JavaCompile;
27+
import org.springframework.boot.gradle.agent.AgentPluginFeatures;
28+
import org.springframework.boot.gradle.exclude.ExcludePluginFeatures;
29+
import org.springframework.boot.gradle.repackage.RepackagePluginFeatures;
30+
import org.springframework.boot.gradle.resolve.ResolvePluginFeatures;
31+
import org.springframework.boot.gradle.run.RunPluginFeatures;
32+
33+
/**
34+
* Gradle 'Spring Boot' {@link Plugin}.
35+
*
36+
* @author Phillip Webb
37+
* @author Dave Syer
38+
*/
39+
class SpringBootPlugin implements Plugin<Project> {
40+
41+
@Override
42+
public void apply(Project project) {
43+
project.getPlugins().apply(BasePlugin.class);
44+
project.getExtensions().create("springBoot", SpringBootPluginExtension.class);
45+
project.getConfigurations().create(VersionManagedDependencies.CONFIGURATION);
46+
project.getPlugins().apply(JavaPlugin.class);
47+
project.getPlugins().apply(ApplicationPlugin.class);
48+
new AgentPluginFeatures().apply(project);
49+
new RepackagePluginFeatures().apply(project);
50+
new RunPluginFeatures().apply(project);
51+
new ResolvePluginFeatures().apply(project);
52+
new ExcludePluginFeatures().apply(project);
53+
project.getTasks().withType(JavaCompile.class).all(new SetUtf8EncodingAction());
54+
}
55+
56+
private static class SetUtf8EncodingAction implements Action<JavaCompile> {
57+
58+
@Override
59+
public void execute(final JavaCompile compile) {
60+
compile.doFirst(new Action<Task>() {
61+
62+
@Override
63+
@SuppressWarnings("deprecation")
64+
public void execute(Task t) {
65+
if (compile.getOptions().getEncoding() == null) {
66+
compile.getOptions().setEncoding("UTF-8");
67+
}
68+
}
69+
70+
});
71+
}
72+
73+
}
74+
75+
}

0 commit comments

Comments
 (0)