Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move CiModelInterpolator to JSR-330 component #347

Merged
merged 1 commit into from
Mar 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
* under the License.
*/

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

import java.io.File;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
Expand All @@ -42,7 +46,6 @@
import org.apache.maven.model.building.ModelProblemCollector;
import org.apache.maven.model.building.ModelProblemCollectorRequest;
import org.apache.maven.model.interpolation.MavenBuildTimestamp;
import org.apache.maven.model.interpolation.ModelInterpolator;
import org.apache.maven.model.path.PathTranslator;
import org.apache.maven.model.path.UrlNormalizer;
import org.codehaus.plexus.interpolation.AbstractValueSource;
Expand All @@ -60,10 +63,10 @@

/**
* Based on StringSearchModelInterpolator in maven-model-builder.
*
* IMPORTANT: this is a legacy Plexus component, with manually authored descriptor in src/main/resources!
*/
public class CiModelInterpolator implements CiInterpolator, ModelInterpolator {
@Named
@Singleton
public class CiModelInterpolator implements CiInterpolator {

private static final List<String> PROJECT_PREFIXES = Arrays.asList("pom.", "project.");

Expand Down Expand Up @@ -99,15 +102,19 @@ public class CiModelInterpolator implements CiInterpolator, ModelInterpolator {
// There is a protected setter for this one?
private RecursionInterceptor recursionInterceptor;

private PathTranslator pathTranslator;
private final PathTranslator pathTranslator;

private UrlNormalizer urlNormalizer;
private final UrlNormalizer urlNormalizer;

public CiModelInterpolator() {
@Inject
public CiModelInterpolator(PathTranslator pathTranslator, UrlNormalizer urlNormalizer) {
this.pathTranslator = pathTranslator;
this.urlNormalizer = urlNormalizer;
this.interpolator = createInterpolator();
this.recursionInterceptor = new PrefixAwareRecursionInterceptor(PROJECT_PREFIXES);
}

@Override
public Model interpolateModel(
Model model, File projectDir, ModelBuildingRequest config, ModelProblemCollector problems) {
interpolateObject(model, model, projectDir, config, problems);
Expand Down Expand Up @@ -570,7 +577,7 @@ protected final Interpolator getInterpolator() {
return interpolator;
}

class BuildTimestampValueSource extends AbstractValueSource {
static class BuildTimestampValueSource extends AbstractValueSource {
private final MavenBuildTimestamp mavenBuildTimestamp;

BuildTimestampValueSource(Date startTime, Properties properties) {
Expand All @@ -586,7 +593,7 @@ public Object getValue(String expression) {
}
}

class ProblemDetectingValueSource implements ValueSource {
static class ProblemDetectingValueSource implements ValueSource {

private final ValueSource valueSource;

Expand Down Expand Up @@ -628,7 +635,7 @@ public void clearFeedback() {
}
}

class PathTranslatingPostProcessor implements InterpolationPostProcessor {
static class PathTranslatingPostProcessor implements InterpolationPostProcessor {

private final Collection<String> unprefixedPathKeys;
private final File projectDir;
Expand Down Expand Up @@ -659,7 +666,7 @@ public Object execute(String expression, Object value) {
}
}

class UrlNormalizingPostProcessor implements InterpolationPostProcessor {
static class UrlNormalizingPostProcessor implements InterpolationPostProcessor {

private UrlNormalizer normalizer;

Expand Down
22 changes: 0 additions & 22 deletions src/main/resources/META-INF/plexus/components.xml

This file was deleted.