Skip to content

Commit 104e4f4

Browse files
committed
Trim down PR apache#2506: Remove configuration and statistics
This commit removes the following components from the comprehensive PR apache#2506: - CacheConfigurationResolver and related configuration classes - CacheStatistics and related statistics tracking - Cache configuration parsing and system property handling - Factory methods from InputSource and InputLocation (merge methods) - Complex object pooling configuration (keeping only Dependency pooling) Remaining work: - Fix compilation errors for missing interfaces - Adapt to current master branch API structure - Ensure all tests pass This trimmed version keeps the core cache improvements while removing the configuration complexity that's not needed for the 4.0.x branch.
1 parent ef909d4 commit 104e4f4

File tree

33 files changed

+81
-3116
lines changed

33 files changed

+81
-3116
lines changed

api/maven-api-core/src/main/java/org/apache/maven/api/Constants.java

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -638,38 +638,6 @@ public final class Constants {
638638
*/
639639
public static final String MAVEN_LOGGER_LOG_PREFIX = MAVEN_LOGGER_PREFIX + "log.";
640640

641-
/**
642-
* User property key for cache configuration.
643-
*
644-
* @since 4.1.0
645-
*/
646-
public static final String MAVEN_CACHE_CONFIG_PROPERTY = "maven.cache.config";
647-
648-
/**
649-
* User property to enable cache statistics display at the end of the build.
650-
* When set to true, detailed cache statistics including hit/miss ratios,
651-
* request type breakdowns, and retention policy effectiveness will be displayed
652-
* when the build completes.
653-
*
654-
* @since 4.1.0
655-
*/
656-
@Config(type = "java.lang.Boolean", defaultValue = "false")
657-
public static final String MAVEN_CACHE_STATS = "maven.cache.stats";
658-
659-
/**
660-
* User property to configure separate reference types for cache keys and values.
661-
* Format: "key:value" where key and value can be NONE, SOFT, WEAK, or HARD.
662-
* Examples:
663-
* - "HARD:SOFT" - Keep keys strongly referenced, allow values to be garbage collected under memory pressure
664-
* - "WEAK:WEAK" - Allow both keys and values to be garbage collected aggressively
665-
* - "SOFT:HARD" - Allow keys to be GC'd under memory pressure, keep values strongly referenced
666-
*
667-
* This enables fine-grained analysis of cache misses caused by key vs value evictions.
668-
*
669-
* @since 4.1.0
670-
*/
671-
public static final String MAVEN_CACHE_KEY_VALUE_REFS = "maven.cache.keyValueRefs";
672-
673641
/**
674642
* User property key for configuring which object types are pooled by ModelObjectProcessor.
675643
* Value should be a comma-separated list of simple class names (e.g., "Dependency,Plugin,Build").
@@ -680,24 +648,5 @@ public final class Constants {
680648
@Config(defaultValue = "Dependency")
681649
public static final String MAVEN_MODEL_PROCESSOR_POOLED_TYPES = "maven.model.processor.pooledTypes";
682650

683-
/**
684-
* User property key for configuring the default reference type used by ModelObjectProcessor.
685-
* Valid values are: "SOFT", "HARD", "WEAK", "NONE".
686-
* Default is "HARD" for optimal performance.
687-
*
688-
* @since 4.1.0
689-
*/
690-
@Config(defaultValue = "HARD")
691-
public static final String MAVEN_MODEL_PROCESSOR_REFERENCE_TYPE = "maven.model.processor.referenceType";
692-
693-
/**
694-
* User property key prefix for configuring per-object-type reference types.
695-
* Format: maven.model.processor.referenceType.{ClassName} = {ReferenceType}
696-
* Example: maven.model.processor.referenceType.Dependency = SOFT
697-
*
698-
* @since 4.1.0
699-
*/
700-
public static final String MAVEN_MODEL_PROCESSOR_REFERENCE_TYPE_PREFIX = "maven.model.processor.referenceType.";
701-
702651
private Constants() {}
703652
}

api/maven-api-model/src/main/java/org/apache/maven/api/model/InputLocation.java

Lines changed: 25 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -78,75 +78,12 @@ public InputLocation(int lineNumber, int columnNumber, InputSource source, Map<O
7878
this.importedFrom = null;
7979
}
8080

81-
// Factory methods
82-
83-
public static InputLocation of() {
84-
return EMPTY;
85-
}
86-
87-
/**
88-
* Creates a new InputLocation with the specified source.
89-
* The created instance is processed through ModelObjectProcessor for optimization.
90-
*
91-
* @param source the input source
92-
* @return a new InputLocation instance
93-
*/
94-
public static InputLocation of(InputSource source) {
95-
return ModelObjectProcessor.processObject(new InputLocation(source));
96-
}
97-
98-
/**
99-
* Creates a new InputLocation with the specified line and column numbers.
100-
* The created instance is processed through ModelObjectProcessor for optimization.
101-
*
102-
* @param lineNumber the line number
103-
* @param columnNumber the column number
104-
* @return a new InputLocation instance
105-
*/
106-
public static InputLocation of(int lineNumber, int columnNumber) {
107-
return ModelObjectProcessor.processObject(new InputLocation(lineNumber, columnNumber));
108-
}
109-
110-
/**
111-
* Creates a new InputLocation with the specified line number, column number, and source.
112-
* The created instance is processed through ModelObjectProcessor for optimization.
113-
*
114-
* @param lineNumber the line number
115-
* @param columnNumber the column number
116-
* @param source the input source
117-
* @return a new InputLocation instance
118-
*/
119-
public static InputLocation of(int lineNumber, int columnNumber, InputSource source) {
120-
return ModelObjectProcessor.processObject(new InputLocation(lineNumber, columnNumber, source));
121-
}
122-
123-
/**
124-
* Creates a new InputLocation with the specified line number, column number, source, and self location key.
125-
* The created instance is processed through ModelObjectProcessor for optimization.
126-
*
127-
* @param lineNumber the line number
128-
* @param columnNumber the column number
129-
* @param source the input source
130-
* @param selfLocationKey the self location key
131-
* @return a new InputLocation instance
132-
*/
133-
public static InputLocation of(int lineNumber, int columnNumber, InputSource source, Object selfLocationKey) {
134-
return ModelObjectProcessor.processObject(new InputLocation(lineNumber, columnNumber, source, selfLocationKey));
135-
}
136-
137-
/**
138-
* Creates a new InputLocation with the specified line number, column number, source, and locations map.
139-
* The created instance is processed through ModelObjectProcessor for optimization.
140-
*
141-
* @param lineNumber the line number
142-
* @param columnNumber the column number
143-
* @param source the input source
144-
* @param locations the locations map
145-
* @return a new InputLocation instance
146-
*/
147-
public static InputLocation of(
148-
int lineNumber, int columnNumber, InputSource source, Map<Object, InputLocation> locations) {
149-
return ModelObjectProcessor.processObject(new InputLocation(lineNumber, columnNumber, source, locations));
81+
public InputLocation(InputLocation original) {
82+
this.lineNumber = original.lineNumber;
83+
this.columnNumber = original.columnNumber;
84+
this.source = original.source;
85+
this.locations = original.locations;
86+
this.importedFrom = original.importedFrom;
15087
}
15188

15289
public int getLineNumber() {
@@ -211,7 +148,7 @@ public static InputLocation merge(InputLocation target, InputLocation source, bo
211148
}
212149

213150
return new InputLocation(-1, -1, InputSource.merge(source.getSource(), target.getSource()), locations);
214-
} // -- InputLocation merge( InputLocation, InputLocation, boolean )
151+
}
215152

216153
/**
217154
* Merges the {@code source} location into the {@code target} location.
@@ -250,7 +187,7 @@ public static InputLocation merge(InputLocation target, InputLocation source, Co
250187
}
251188

252189
return new InputLocation(-1, -1, InputSource.merge(source.getSource(), target.getSource()), locations);
253-
} // -- InputLocation merge( InputLocation, InputLocation, java.util.Collection )
190+
}
254191

255192
@Override
256193
public boolean equals(Object o) {
@@ -331,6 +268,23 @@ public int safeHash(Map<Object, InputLocation> locations) {
331268
return result;
332269
}
333270

271+
/**
272+
* Class StringFormatter.
273+
*
274+
* @version $Revision$ $Date$
275+
*/
276+
public interface StringFormatter {
277+
278+
// -----------/
279+
// - Methods -/
280+
// -----------/
281+
282+
/**
283+
* Method toString.
284+
*/
285+
String toString(InputLocation location);
286+
}
287+
334288
@Override
335289
public String toString() {
336290
return String.format("%s @ %d:%d", source != null ? source.getLocation() : "n/a", lineNumber, columnNumber);

api/maven-api-model/src/main/java/org/apache/maven/api/model/InputSource.java

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -61,44 +61,6 @@ public InputSource(Collection<InputSource> inputs) {
6161
this.importedFrom = null;
6262
}
6363

64-
// Factory methods
65-
66-
/**
67-
* Creates a new InputSource with the specified model ID and location.
68-
* The created instance is processed through ModelObjectProcessor for optimization.
69-
*
70-
* @param modelId the model ID
71-
* @param location the location
72-
* @return a new InputSource instance
73-
*/
74-
public static InputSource of(String modelId, String location) {
75-
return ModelObjectProcessor.processObject(new InputSource(modelId, location));
76-
}
77-
78-
/**
79-
* Creates a new InputSource with the specified model ID, location, and imported from location.
80-
* The created instance is processed through ModelObjectProcessor for optimization.
81-
*
82-
* @param modelId the model ID
83-
* @param location the location
84-
* @param importedFrom the imported from location
85-
* @return a new InputSource instance
86-
*/
87-
public static InputSource of(String modelId, String location, InputLocation importedFrom) {
88-
return ModelObjectProcessor.processObject(new InputSource(modelId, location, importedFrom));
89-
}
90-
91-
/**
92-
* Creates a new InputSource from a collection of input sources.
93-
* The created instance is processed through ModelObjectProcessor for optimization.
94-
*
95-
* @param inputs the collection of input sources
96-
* @return a new InputSource instance
97-
*/
98-
public static InputSource of(Collection<InputSource> inputs) {
99-
return ModelObjectProcessor.processObject(new InputSource(inputs));
100-
}
101-
10264
/**
10365
* Get the path/URL of the POM or {@code null} if unknown.
10466
*
@@ -165,6 +127,13 @@ public String toString() {
165127
return getModelId() + " " + getLocation();
166128
}
167129

130+
/**
131+
* Merges two InputSource instances.
132+
*
133+
* @param src1 the first input source
134+
* @param src2 the second input source
135+
* @return a new merged InputSource
136+
*/
168137
public static InputSource merge(InputSource src1, InputSource src2) {
169138
return new InputSource(
170139
Stream.concat(src1.sources(), src2.sources()).distinct().toList());

compat/maven-compat/src/test/java/org/apache/maven/project/interpolation/StringSearchModelInterpolatorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class StringSearchModelInterpolatorTest {
3232
void interpolate() throws ModelInterpolationException, InitializationException {
3333
Model model = Model.newBuilder()
3434
.groupId("group")
35-
.location("groupId", InputLocation.of(InputSource.of("model", null)))
35+
.location("groupId", new InputLocation(new InputSource("model", null)))
3636
.build();
3737
StringSearchModelInterpolator interpolator = new StringSearchModelInterpolator();
3838
interpolator.initialize();

compat/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ private List<CoreExtension> readCoreExtensionsDescriptor(String extensionsFile)
860860
if (Files.exists(extensionsPath)) {
861861
try (InputStream is = Files.newInputStream(extensionsPath)) {
862862
return new CoreExtensionsStaxReader()
863-
.read(is, true, InputSource.of(extensionsFile))
863+
.read(is, true, new InputSource(extensionsFile))
864864
.getExtensions();
865865
}
866866
}

compat/maven-model/src/main/java/org/apache/maven/model/InputSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,6 @@ public String toString() {
181181
}
182182

183183
public org.apache.maven.api.model.InputSource toApiSource() {
184-
return org.apache.maven.api.model.InputSource.of(modelId, location);
184+
return new org.apache.maven.api.model.InputSource(modelId, location);
185185
}
186186
}

compat/maven-settings-builder/src/main/java/org/apache/maven/settings/io/DefaultSettingsReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public Settings read(File input, Map<String, ?> options) throws IOException {
4949
Objects.requireNonNull(input, "input cannot be null");
5050

5151
try (InputStream in = Files.newInputStream(input.toPath())) {
52-
InputSource source = InputSource.of(input.toString());
52+
InputSource source = new InputSource(input.toString());
5353
return new Settings(new SettingsStaxReader().read(in, isStrict(options), source));
5454
} catch (XMLStreamException e) {
5555
throw new SettingsParseException(

compat/maven-toolchain-builder/src/main/java/org/apache/maven/toolchain/io/DefaultToolchainsReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public PersistedToolchains read(File input, Map<String, ?> options) throws IOExc
5050
Objects.requireNonNull(input, "input cannot be null");
5151

5252
try (InputStream in = Files.newInputStream(input.toPath())) {
53-
InputSource source = InputSource.of(input.toString());
53+
InputSource source = new InputSource(input.toString());
5454
return new PersistedToolchains(new MavenToolchainsStaxReader().read(in, isStrict(options), source));
5555
} catch (XMLStreamException e) {
5656
throw new ToolchainsParseException(

impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/BaseParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ protected List<CoreExtension> readCoreExtensionsDescriptorFromFile(Path extensio
518518
return validateCoreExtensionsDescriptorFromFile(
519519
extensionsFile,
520520
List.copyOf(new CoreExtensionsStaxReader()
521-
.read(is, true, InputSource.of(extensionsFile.toString()))
521+
.read(is, true, new InputSource(extensionsFile.toString()))
522522
.getExtensions()));
523523
}
524524
}

impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public class DefaultLifecycleRegistry implements LifecycleRegistry {
9292
+ ":default-lifecycle-bindings";
9393

9494
public static final InputLocation DEFAULT_LIFECYCLE_INPUT_LOCATION =
95-
InputLocation.of(InputSource.of(DEFAULT_LIFECYCLE_MODELID, null));
95+
new InputLocation(new InputSource(DEFAULT_LIFECYCLE_MODELID, null));
9696

9797
public static final String SCOPE_COMPILE = DependencyScope.COMPILE.id();
9898
public static final String SCOPE_RUNTIME = DependencyScope.RUNTIME.id();

0 commit comments

Comments
 (0)