Skip to content

Commit 4b1679f

Browse files
committed
Apply code formatting and upgrade spotless tooling
- Upgrade spotless-maven-plugin from 2.44.5 to 3.0.0 - Upgrade palantir-java-format from 2.56.0 to 2.81.0 for Java 25 support - Run mvn spotless:apply to format code Addresses review feedback on PR #389.
1 parent a2c3c4a commit 4b1679f

File tree

5 files changed

+51
-34
lines changed

5 files changed

+51
-34
lines changed

pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ under the License.
6464
<minimalMavenBuildVersion>3.9.0</minimalMavenBuildVersion>
6565
<minimalJavaBuildVersion>11</minimalJavaBuildVersion>
6666
<classWorldsVersion>2.6.0</classWorldsVersion>
67+
<version.spotless-maven-plugin>3.0.0</version.spotless-maven-plugin>
6768

6869
<!-- default maven version, will be overridden by maven3 profile -->
6970
<mavenVersion>4.0.0-alpha-8</mavenVersion>
@@ -427,6 +428,17 @@ under the License.
427428
</execution>
428429
</executions>
429430
</plugin>
431+
<plugin>
432+
<groupId>com.diffplug.spotless</groupId>
433+
<artifactId>spotless-maven-plugin</artifactId>
434+
<configuration>
435+
<java>
436+
<palantirJavaFormat>
437+
<version>2.81.0</version>
438+
</palantirJavaFormat>
439+
</java>
440+
</configuration>
441+
</plugin>
430442
</plugins>
431443
</build>
432444

src/main/java/org/apache/maven/buildcache/xml/CacheConfigImpl.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.apache.maven.buildcache.xml.config.Exclude;
4949
import org.apache.maven.buildcache.xml.config.Executables;
5050
import org.apache.maven.buildcache.xml.config.ExecutionConfigurationScan;
51-
import org.apache.maven.buildcache.xml.config.ExecutionControl;
5251
import org.apache.maven.buildcache.xml.config.ExecutionIdsList;
5352
import org.apache.maven.buildcache.xml.config.GoalReconciliation;
5453
import org.apache.maven.buildcache.xml.config.GoalsList;
@@ -262,7 +261,8 @@ private GoalReconciliation findReconciliationConfig(MojoExecution mojoExecution)
262261
}
263262

264263
// First check explicit configuration
265-
if (cacheConfig.getExecutionControl() != null && cacheConfig.getExecutionControl().getReconcile() != null) {
264+
if (cacheConfig.getExecutionControl() != null
265+
&& cacheConfig.getExecutionControl().getReconcile() != null) {
266266
List<GoalReconciliation> explicitConfigs =
267267
cacheConfig.getExecutionControl().getReconcile().getPlugins();
268268
for (GoalReconciliation config : explicitConfigs) {
@@ -281,7 +281,9 @@ private GoalReconciliation findReconciliationConfig(MojoExecution mojoExecution)
281281
"Auto-generated reconciliation config for {}:{} with {} functional parameters",
282282
plugin.getArtifactId(),
283283
goal,
284-
autoGenerated.getReconciles() != null ? autoGenerated.getReconciles().size() : 0);
284+
autoGenerated.getReconciles() != null
285+
? autoGenerated.getReconciles().size()
286+
: 0);
285287
}
286288
return autoGenerated;
287289
}
@@ -382,7 +384,8 @@ private GoalReconciliation generateReconciliationFromParameters(Plugin plugin, S
382384

383385
// Collect all functional parameters
384386
List<TrackedProperty> functionalProperties = new ArrayList<>();
385-
for (PluginParameterDefinition.ParameterDefinition param : goalDef.getParameters().values()) {
387+
for (PluginParameterDefinition.ParameterDefinition param :
388+
goalDef.getParameters().values()) {
386389
if (param.isFunctional()) {
387390
TrackedProperty property = new TrackedProperty();
388391
property.setPropertyName(param.getName());

src/main/java/org/apache/maven/buildcache/xml/PluginParameterLoader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ public PluginParameterDefinition load(String artifactId, String pluginVersion) {
7979

8080
if (bestMatch != null) {
8181
definitions.put(cacheKey, bestMatch);
82-
LOGGER.info("Loaded parameter definition for {}:{} (minVersion: {}): {} goals, {} total parameters",
82+
LOGGER.info(
83+
"Loaded parameter definition for {}:{} (minVersion: {}): {} goals, {} total parameters",
8384
artifactId,
8485
pluginVersion != null ? pluginVersion : "any",
8586
bestMatch.getMinVersion() != null ? bestMatch.getMinVersion() : "none",

src/test/java/org/apache/maven/buildcache/xml/AutoTrackingFunctionalParametersTest.java

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@
1818
*/
1919
package org.apache.maven.buildcache.xml;
2020

21-
import org.apache.maven.buildcache.xml.config.TrackedProperty;
22-
import org.junit.jupiter.api.Test;
23-
24-
import java.util.List;
2521
import java.util.Set;
2622
import java.util.stream.Collectors;
2723

24+
import org.junit.jupiter.api.Test;
25+
2826
import static org.junit.jupiter.api.Assertions.assertNotNull;
2927
import static org.junit.jupiter.api.Assertions.assertTrue;
3028

@@ -41,59 +39,63 @@ void testMavenCompilerPluginAutoTracksAllFunctionalParameters() {
4139

4240
PluginParameterLoader loader = new PluginParameterLoader();
4341
PluginParameterDefinition def = loader.load("maven-compiler-plugin");
44-
42+
4543
assertNotNull(def, "Should load maven-compiler-plugin definition");
46-
44+
4745
PluginParameterDefinition.GoalParameterDefinition compileGoal = def.getGoal("compile");
4846
assertNotNull(compileGoal, "compile goal should exist");
49-
47+
5048
// Get all functional parameter names from the XML definition
5149
Set<String> functionalParams = compileGoal.getParameters().values().stream()
5250
.filter(PluginParameterDefinition.ParameterDefinition::isFunctional)
5351
.map(PluginParameterDefinition.ParameterDefinition::getName)
5452
.collect(Collectors.toSet());
55-
53+
5654
// Verify we have more than just the original 3 from defaults.xml
57-
assertTrue(functionalParams.size() > 3,
55+
assertTrue(
56+
functionalParams.size() > 3,
5857
"Should have more than 3 functional parameters (was: " + functionalParams.size() + ")");
59-
58+
6059
// Verify the original 3 are included
6160
assertTrue(functionalParams.contains("source"), "Should include 'source' parameter");
6261
assertTrue(functionalParams.contains("target"), "Should include 'target' parameter");
6362
assertTrue(functionalParams.contains("release"), "Should include 'release' parameter");
64-
63+
6564
// Verify additional functional parameters are included (these were NOT in defaults.xml)
66-
assertTrue(functionalParams.contains("encoding"),
65+
assertTrue(
66+
functionalParams.contains("encoding"),
6767
"Should include 'encoding' parameter (auto-tracked, not in old defaults.xml)");
68-
assertTrue(functionalParams.contains("debug"),
68+
assertTrue(
69+
functionalParams.contains("debug"),
6970
"Should include 'debug' parameter (auto-tracked, not in old defaults.xml)");
70-
assertTrue(functionalParams.contains("compilerArgs"),
71+
assertTrue(
72+
functionalParams.contains("compilerArgs"),
7173
"Should include 'compilerArgs' parameter (auto-tracked, not in old defaults.xml)");
72-
assertTrue(functionalParams.contains("annotationProcessorPaths"),
74+
assertTrue(
75+
functionalParams.contains("annotationProcessorPaths"),
7376
"Should include 'annotationProcessorPaths' parameter (auto-tracked, not in old defaults.xml)");
7477
}
7578

7679
@Test
7780
void testMavenInstallPluginAutoTracksAllFunctionalParameters() {
7881
PluginParameterLoader loader = new PluginParameterLoader();
7982
PluginParameterDefinition def = loader.load("maven-install-plugin");
80-
83+
8184
assertNotNull(def, "Should load maven-install-plugin definition");
82-
85+
8386
PluginParameterDefinition.GoalParameterDefinition installGoal = def.getGoal("install");
8487
assertNotNull(installGoal, "install goal should exist");
85-
88+
8689
// Get all functional parameter names
8790
Set<String> functionalParams = installGoal.getParameters().values().stream()
8891
.filter(PluginParameterDefinition.ParameterDefinition::isFunctional)
8992
.map(PluginParameterDefinition.ParameterDefinition::getName)
9093
.collect(Collectors.toSet());
91-
94+
9295
// The old defaults.xml had NO properties listed for maven-install-plugin
9396
// Now auto-tracking should track all functional parameters
94-
assertTrue(functionalParams.size() > 0,
95-
"Should auto-track functional parameters (old defaults.xml had 0)");
96-
97+
assertTrue(functionalParams.size() > 0, "Should auto-track functional parameters (old defaults.xml had 0)");
98+
9799
// Verify key functional parameters are tracked
98100
assertTrue(functionalParams.contains("file"), "Should track 'file' parameter");
99101
assertTrue(functionalParams.contains("groupId"), "Should track 'groupId' parameter");
@@ -105,22 +107,22 @@ void testMavenInstallPluginAutoTracksAllFunctionalParameters() {
105107
void testBehavioralParametersNotAutoTracked() {
106108
PluginParameterLoader loader = new PluginParameterLoader();
107109
PluginParameterDefinition def = loader.load("maven-compiler-plugin");
108-
110+
109111
assertNotNull(def);
110-
112+
111113
PluginParameterDefinition.GoalParameterDefinition compileGoal = def.getGoal("compile");
112114
assertNotNull(compileGoal);
113-
115+
114116
// Get all behavioral parameter names
115117
Set<String> behavioralParams = compileGoal.getParameters().values().stream()
116118
.filter(PluginParameterDefinition.ParameterDefinition::isBehavioral)
117119
.map(PluginParameterDefinition.ParameterDefinition::getName)
118120
.collect(Collectors.toSet());
119-
121+
120122
// Verify behavioral parameters exist in the definition
121123
assertTrue(behavioralParams.contains("verbose"), "Definition should include 'verbose' as behavioral");
122124
assertTrue(behavioralParams.contains("fork"), "Definition should include 'fork' as behavioral");
123-
125+
124126
// Note: The auto-generation logic in CacheConfigImpl.generateReconciliationFromParameters()
125127
// filters to only include functional parameters, so behavioral ones won't be tracked
126128
}

src/test/java/org/apache/maven/buildcache/xml/PluginParameterValidationTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ void testDefaultReconciliationParametersAreValid() {
104104

105105
ParameterDefinition param = compileGoal.getParameter(paramName);
106106
assertTrue(
107-
param.isFunctional(),
108-
"Default parameter '" + paramName + "' should be FUNCTIONAL, not BEHAVIORAL");
107+
param.isFunctional(), "Default parameter '" + paramName + "' should be FUNCTIONAL, not BEHAVIORAL");
109108
}
110109

111110
// Verify testCompile goal has same parameters

0 commit comments

Comments
 (0)