11package studio .o7 .remora ;
22
33import com .github .jengelman .gradle .plugins .shadow .ShadowPlugin ;
4- import com .github .spotbugs .snom .Confidence ;
5- import com .github .spotbugs .snom .Effort ;
6- import com .github .spotbugs .snom .SpotBugsExtension ;
7- import com .github .spotbugs .snom .SpotBugsPlugin ;
8- import com .github .spotbugs .snom .SpotBugsTask ;
94import lombok .NonNull ;
105import net .thebugmc .gradle .sonatypepublisher .CentralPortalExtension ;
116import net .thebugmc .gradle .sonatypepublisher .PublishingType ;
1813import org .gradle .api .logging .Logger ;
1914import org .gradle .api .plugins .ExtensionContainer ;
2015import org .gradle .api .plugins .JavaLibraryPlugin ;
21- import org .gradle .api .plugins .quality .*;
2216import org .gradle .api .publish .PublishingExtension ;
2317import org .gradle .api .tasks .bundling .Jar ;
2418import org .gradle .plugins .signing .SigningExtension ;
2721import studio .o7 .remora .extensions .InformationExtension ;
2822import studio .o7 .remora .plugin .PaperPlugins ;
2923import studio .o7 .remora .plugins .RemoraPlugins ;
30- import studio .o7 .remora .utils .ConfigUtils ;
3124
3225import java .net .URI ;
3326import java .time .Instant ;
@@ -41,16 +34,13 @@ public static InformationExtension setupExtension(@NonNull Logger logger, @NonNu
4134 }
4235
4336 public static void applyNecessaryPlugins (@ NonNull Logger logger , @ NonNull Project project ) {
44- logger .info ("Applying necessary plugins `java-library`, `shadow`, `build-constants`, `checkstyle`, `spotbugs`, `pmd`, and `sonatype-central-publisher`" );
37+ logger .info ("Applying necessary plugins `java-library`, `shadow`, `build-constants` and `sonatype-central-publisher`" );
4538
4639 var pluginManager = project .getPluginManager ();
4740
4841 pluginManager .apply (JavaLibraryPlugin .class );
4942 pluginManager .apply (ShadowPlugin .class );
5043 pluginManager .apply (BuildConstantsPlugin .class );
51- pluginManager .apply (CheckstylePlugin .class );
52- pluginManager .apply (SpotBugsPlugin .class );
53- pluginManager .apply (PmdPlugin .class );
5444 pluginManager .apply (SonatypeCentralPortalPublisherPlugin .class );
5545 }
5646
@@ -111,53 +101,6 @@ public static void applyMavenPublishPluginConfiguration(@NonNull Logger logger,
111101 });
112102 }
113103
114- public static void applyCheckstyle (@ NonNull Logger logger , @ NonNull Project project ) {
115- project .getExtensions ().configure (CheckstyleExtension .class , checkstyle -> {
116- logger .info ("Configuring extension `checkstyle`" );
117- checkstyle .setToolVersion ("12.1.2" );
118- checkstyle .setIgnoreFailures (false );
119- });
120-
121- project .getTasks ().withType (Checkstyle .class , task -> {
122- task .doFirst (_ -> task .setConfigFile (ConfigUtils .getConfig (project , "checkstyle.xml" )));
123- });
124- }
125-
126- public static void applyPmd (@ NonNull Logger logger , @ NonNull Project project ) {
127- project .getExtensions ().configure (PmdExtension .class , pmd -> {
128- logger .info ("Configuring extension `pmd`" );
129- pmd .setToolVersion ("7.18.0" );
130- pmd .setIgnoreFailures (true );
131-
132- pmd .setConsoleOutput (true );
133- });
134-
135- project .getTasks ().withType (Pmd .class , task -> task .doFirst (_ -> {
136- var files = project .files (ConfigUtils .getConfig (project , "pmd-ruleset.xml" ));
137- task .setRuleSetFiles (files );
138- }));
139- }
140-
141- public static void applySpotBugs (@ NonNull Logger logger , @ NonNull Project project ) {
142- var generateConfigs = project .getTasks ().register ("generateSpotbugsExludeConfig" , task -> {
143- task .doLast (_ -> ConfigUtils .getConfig (project , "findbugs-exclude.xml" ));
144- });
145-
146- project .getExtensions ().configure (SpotBugsExtension .class , spotBugs -> {
147- logger .info ("Configuring extension `spotBugs`" );
148- spotBugs .getToolVersion ().set ("4.9.8" );
149- spotBugs .getEffort ().set (Effort .MAX );
150- spotBugs .getReportLevel ().set (Confidence .MEDIUM );
151- });
152-
153- project .getTasks ().withType (SpotBugsTask .class ).configureEach (task -> {
154- task .dependsOn (generateConfigs );
155- logger .info ("Configuring task `spotBugs`" );
156- task .setIgnoreFailures (true );
157- task .getExcludeFilter ().set (ConfigUtils .getConfig (project , "findbugs-exclude.xml" ));
158- });
159- }
160-
161104 @ Override
162105 public void apply (Project project ) {
163106 var logger = project .getLogger ();
@@ -179,30 +122,6 @@ public void apply(Project project) {
179122
180123 RemoraPlugins .applyBuildConstants (logger , project );
181124
182- if (!isDisabled ("checkstyle" )) {
183- applyCheckstyle (logger , project );
184- } else {
185- logger .lifecycle ("Skipping Checkstyle (disabled via env/property)" );
186- project .getTasks ().withType (Checkstyle .class )
187- .configureEach (task -> task .setEnabled (false ));
188- }
189-
190- if (!isDisabled ("pmd" )) {
191- applyPmd (logger , project );
192- } else {
193- logger .lifecycle ("Skipping PMD (disabled via env/property)" );
194- project .getTasks ().withType (Pmd .class )
195- .configureEach (task -> task .setEnabled (false ));
196- }
197-
198- if (!isDisabled ("spotbugs" )) {
199- applySpotBugs (logger , project );
200- } else {
201- logger .lifecycle ("Skipping SpotBugs (disabled via env/property)" );
202- project .getTasks ().withType (SpotBugsTask .class )
203- .configureEach (task -> task .setEnabled (false ));
204- }
205-
206125 applyManifest (project );
207126 }
208127
@@ -214,12 +133,4 @@ public static void applyManifest(@NonNull Project project) {
214133 "Remora" , "Build with o7studios Remora"
215134 ))));
216135 }
217-
218- private static boolean isDisabled (String name ) {
219- if ("true" .equalsIgnoreCase (System .getProperty ("remora.skip-" + name ))) {
220- return true ;
221- }
222-
223- return "true" .equalsIgnoreCase (System .getenv ("REMORA_SKIP_" + name .toUpperCase ()));
224- }
225136}
0 commit comments