Skip to content

Commit b286bec

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. # Conflicts: # impl/maven-impl/src/main/java/org/apache/maven/impl/cache/DefaultRequestCache.java # impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelObjectPool.java # impl/maven-impl/src/test/java/org/apache/maven/impl/cache/ReferenceTypeStatisticsTest.java
1 parent e831f43 commit b286bec

22 files changed

+335
-3166
lines changed

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

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -638,66 +638,5 @@ 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-
673-
/**
674-
* User property key for configuring which object types are pooled by ModelObjectProcessor.
675-
* Value should be a comma-separated list of simple class names (e.g., "Dependency,Plugin,Build").
676-
* Default is "Dependency" for backward compatibility.
677-
*
678-
* @since 4.1.0
679-
*/
680-
@Config(defaultValue = "Dependency")
681-
public static final String MAVEN_MODEL_PROCESSOR_POOLED_TYPES = "maven.model.processor.pooledTypes";
682-
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-
702641
private Constants() {}
703642
}

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

Lines changed: 40 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -84,102 +84,25 @@ public static InputLocation of() {
8484
return EMPTY;
8585
}
8686

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-
*/
9487
public static InputLocation of(InputSource source) {
95-
return ModelObjectProcessor.processObject(new InputLocation(source));
88+
return new InputLocation(0, 0, source);
9689
}
9790

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-
*/
10691
public static InputLocation of(int lineNumber, int columnNumber) {
107-
return ModelObjectProcessor.processObject(new InputLocation(lineNumber, columnNumber));
92+
return new InputLocation(lineNumber, columnNumber);
10893
}
10994

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-
*/
11995
public static InputLocation of(int lineNumber, int columnNumber, InputSource source) {
120-
return ModelObjectProcessor.processObject(new InputLocation(lineNumber, columnNumber, source));
96+
return new InputLocation(lineNumber, columnNumber, source);
12197
}
12298

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-
*/
13399
public static InputLocation of(int lineNumber, int columnNumber, InputSource source, Object selfLocationKey) {
134-
return ModelObjectProcessor.processObject(new InputLocation(lineNumber, columnNumber, source, selfLocationKey));
100+
return new InputLocation(lineNumber, columnNumber, source, selfLocationKey);
135101
}
136102

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-
*/
147103
public static InputLocation of(
148104
int lineNumber, int columnNumber, InputSource source, Map<Object, InputLocation> locations) {
149-
return ModelObjectProcessor.processObject(new InputLocation(lineNumber, columnNumber, source, locations));
150-
}
151-
152-
public int getLineNumber() {
153-
return lineNumber;
154-
}
155-
156-
public int getColumnNumber() {
157-
return columnNumber;
158-
}
159-
160-
public InputSource getSource() {
161-
return source;
162-
}
163-
164-
@Override
165-
public InputLocation getLocation(Object key) {
166-
return locations != null ? locations.get(key) : null;
167-
}
168-
169-
public Map<Object, InputLocation> getLocations() {
170-
return locations;
171-
}
172-
173-
/**
174-
* Gets the parent InputLocation where this InputLocation may have been imported from.
175-
* Can return {@code null}.
176-
*
177-
* @return InputLocation
178-
* @since 4.0.0
179-
*/
180-
@Override
181-
public InputLocation getImportedFrom() {
182-
return importedFrom;
105+
return new InputLocation(lineNumber, columnNumber, source, locations);
183106
}
184107

185108
/**
@@ -211,7 +134,7 @@ public static InputLocation merge(InputLocation target, InputLocation source, bo
211134
}
212135

213136
return new InputLocation(-1, -1, InputSource.merge(source.getSource(), target.getSource()), locations);
214-
} // -- InputLocation merge( InputLocation, InputLocation, boolean )
137+
}
215138

216139
/**
217140
* Merges the {@code source} location into the {@code target} location.
@@ -250,7 +173,40 @@ public static InputLocation merge(InputLocation target, InputLocation source, Co
250173
}
251174

252175
return new InputLocation(-1, -1, InputSource.merge(source.getSource(), target.getSource()), locations);
253-
} // -- InputLocation merge( InputLocation, InputLocation, java.util.Collection )
176+
}
177+
178+
public int getLineNumber() {
179+
return lineNumber;
180+
}
181+
182+
public int getColumnNumber() {
183+
return columnNumber;
184+
}
185+
186+
public InputSource getSource() {
187+
return source;
188+
}
189+
190+
@Override
191+
public InputLocation getLocation(Object key) {
192+
return locations != null ? locations.get(key) : null;
193+
}
194+
195+
public Map<Object, InputLocation> getLocations() {
196+
return locations;
197+
}
198+
199+
/**
200+
* Gets the parent InputLocation where this InputLocation may have been imported from.
201+
* Can return {@code null}.
202+
*
203+
* @return InputLocation
204+
* @since 4.0.0
205+
*/
206+
@Override
207+
public InputLocation getImportedFrom() {
208+
return importedFrom;
209+
}
254210

255211
@Override
256212
public boolean equals(Object o) {

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

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -63,42 +63,6 @@ public InputSource(Collection<InputSource> inputs) {
6363

6464
// Factory methods
6565

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-
10266
/**
10367
* Get the path/URL of the POM or {@code null} if unknown.
10468
*
@@ -165,6 +129,56 @@ public String toString() {
165129
return getModelId() + " " + getLocation();
166130
}
167131

132+
/**
133+
* Creates a new InputSource with the specified model ID and location.
134+
*
135+
* @param modelId the model ID
136+
* @param location the location
137+
* @return a new InputSource
138+
*/
139+
public static InputSource of(String modelId, String location) {
140+
return new InputSource(modelId, location);
141+
}
142+
143+
/**
144+
* Creates a new InputSource with the specified location.
145+
*
146+
* @param location the location
147+
* @return a new InputSource
148+
*/
149+
public static InputSource of(String location) {
150+
return new InputSource(null, location);
151+
}
152+
153+
/**
154+
* Creates a new InputSource with the specified model ID, location, and imported from location.
155+
*
156+
* @param modelId the model ID
157+
* @param location the location
158+
* @param importedFrom the imported from location
159+
* @return a new InputSource
160+
*/
161+
public static InputSource of(String modelId, String location, InputLocation importedFrom) {
162+
return new InputSource(modelId, location, importedFrom);
163+
}
164+
165+
/**
166+
* Creates a new InputSource from a collection of input sources.
167+
*
168+
* @param inputs the collection of input sources
169+
* @return a new InputSource
170+
*/
171+
public static InputSource of(Collection<InputSource> inputs) {
172+
return new InputSource(inputs);
173+
}
174+
175+
/**
176+
* Merges two InputSource instances.
177+
*
178+
* @param src1 the first input source
179+
* @param src2 the second input source
180+
* @return a new merged InputSource
181+
*/
168182
public static InputSource merge(InputSource src1, InputSource src2) {
169183
return new InputSource(
170184
Stream.concat(src1.sources(), src2.sources()).distinct().toList());

0 commit comments

Comments
 (0)