From 4cfc0e4bf33ccb98aba066226d7d8f14119b9aab Mon Sep 17 00:00:00 2001 From: ckunki Date: Tue, 15 Oct 2024 17:31:15 +0200 Subject: [PATCH] Used javax.inject.Inject See https://maven.apache.org/maven-jsr330.html#how-to-use-jsr-330-in-plugins --- .../projectkeeper/MavenProjectCrawlerMojo.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/maven-project-crawler/src/main/java/com/exasol/projectkeeper/MavenProjectCrawlerMojo.java b/maven-project-crawler/src/main/java/com/exasol/projectkeeper/MavenProjectCrawlerMojo.java index c7083104..35937e6e 100644 --- a/maven-project-crawler/src/main/java/com/exasol/projectkeeper/MavenProjectCrawlerMojo.java +++ b/maven-project-crawler/src/main/java/com/exasol/projectkeeper/MavenProjectCrawlerMojo.java @@ -1,5 +1,6 @@ package com.exasol.projectkeeper; +import javax.inject.Inject; import java.io.File; import java.util.HashMap; import java.util.Map; @@ -9,7 +10,7 @@ import org.apache.maven.plugins.annotations.*; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuilder; -import org.apache.maven.project.DefaultProjectBuilder; // new +// import org.apache.maven.project.DefaultProjectBuilder; // new import org.apache.maven.repository.RepositorySystem; import com.exasol.errorreporting.ExaError; @@ -26,20 +27,30 @@ */ @Mojo(name = "crawl", requiresProject = false) public class MavenProjectCrawlerMojo extends AbstractMojo { + private static final String PROPERTY_PROJECTS_TO_CRAWL = "projectsToCrawl"; - @Parameter(property = "repositorySystem") + // @Component + // @Parameter(property = "repositorySystem") RepositorySystem repositorySystem; @Parameter(property = PROPERTY_PROJECTS_TO_CRAWL, required = true) private String projectsToCrawl; + // @Component // @Parameter(property = "projectBuilder", required = true) - private ProjectBuilder mavenProjectBuilder = new DefaultProjectBuilder(); + // private ProjectBuilder mavenProjectBuilder = new DefaultProjectBuilder(); + private ProjectBuilder mavenProjectBuilder; @Parameter(defaultValue = "${session}", readonly = true) private MavenSession session; + @Inject + public MavenProjectCrawlerMojo(RepositorySystem repositorySystem, ProjectBuilder mavenProjectBuilder) { + this.repositorySystem = repositorySystem; + this.mavenProjectBuilder = mavenProjectBuilder; + } + // [impl -> dsn~eclipse-prefs-java-version~1] @Override public void execute() {