Skip to content

Commit

Permalink
Drop unused parameter ${localRepository}.
Browse files Browse the repository at this point in the history
Not only it is unused, but starting with Maven 3.9.1
it will cause a WARNING, making plugin look bad.

For details, see here:
https://issues.apache.org/jira/browse/MNG-7706
  • Loading branch information
cstamas committed Feb 23, 2023
1 parent 4d8bb2f commit f7bbca0
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ public class JApiCmpMojo extends AbstractMojo {
private RepositorySystemSession repoSession;
@org.apache.maven.plugins.annotations.Parameter(defaultValue = "${project.remoteProjectRepositories}", readonly = true)
private List<RemoteRepository> remoteRepos;
@org.apache.maven.plugins.annotations.Parameter(defaultValue = "${localRepository}")
private ArtifactRepository localRepository;
@org.apache.maven.plugins.annotations.Parameter(defaultValue = "${project.remoteArtifactRepositories}")
private List<ArtifactRepository> artifactRepositories;
@org.apache.maven.plugins.annotations.Parameter(defaultValue = "${project}")
Expand All @@ -103,7 +101,7 @@ public class JApiCmpMojo extends AbstractMojo {
private Options options;

public void execute() throws MojoExecutionException, MojoFailureException {
MavenParameters mavenParameters = new MavenParameters(this.artifactRepositories, this.localRepository,
MavenParameters mavenParameters = new MavenParameters(this.artifactRepositories,
this.mavenProject, this.mojoExecution, this.versionRangeWithProjectVersion, this.repoSystem, this.repoSession,
this.remoteRepos);
PluginParameters pluginParameters = new PluginParameters(this.skip, this.newVersion, this.oldVersion, this.parameter, this.dependencies, Optional.of(
Expand Down Expand Up @@ -903,7 +901,6 @@ private Set<Artifact> resolveArtifact(Dependency dependency, MavenParameters mav
}

private Set<Artifact> resolveArtifact(Artifact artifact, MavenParameters mavenParameters, PluginParameters pluginParameters, ConfigurationVersion configurationVersion) throws MojoFailureException {
notNull(mavenParameters.getLocalRepository(), "Maven parameter localRepository should be provided by maven container.");
notNull(mavenParameters.getRepoSystem(), "Maven parameter repoSystem should be provided by maven container.");
notNull(mavenParameters.getRepoSession(), "Maven parameter repoSession should be provided by maven container.");
ArtifactRequest request = new ArtifactRequest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private JApiCmpMojo getMojo() {
return this.mojo;
}
this.mojo = new JApiCmpMojo();
this.mavenParameters = new MavenParameters(this.artifactRepositories, this.localRepository,
this.mavenParameters = new MavenParameters(this.artifactRepositories,
this.mavenProject, this.mojoExecution, this.versionRangeWithProjectVersion, this.repoSystem, this.repoSession,
this.remoteRepos);
this.pluginParameters = new PluginParameters(this.skip, this.newVersion, this.oldVersion, this.parameter, this.dependencies, Optional.<File>absent(), Optional.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@

public class MavenParameters {
private final List<ArtifactRepository> artifactRepositories;
private final ArtifactRepository localRepository;
private final MavenProject mavenProject;
private final MojoExecution mojoExecution;
private final String versionRangeWithProjectVersion;
private final RepositorySystem repoSystem;
private final RepositorySystemSession repoSession;
private final List<RemoteRepository> remoteRepos;

public MavenParameters(final List<ArtifactRepository> artifactRepositories, final ArtifactRepository localRepository,
public MavenParameters(final List<ArtifactRepository> artifactRepositories,
final MavenProject mavenProject, final MojoExecution mojoExecution, final String versionRangeWithProjectVersion,
final RepositorySystem repoSystem, final RepositorySystemSession repoSession, final List<RemoteRepository> remoteRepos) {
this.artifactRepositories = artifactRepositories;
this.localRepository = localRepository;
this.mavenProject = mavenProject;
this.mojoExecution = mojoExecution;
this.versionRangeWithProjectVersion = versionRangeWithProjectVersion;
Expand All @@ -36,10 +34,6 @@ public List<ArtifactRepository> getArtifactRepositories() {
return artifactRepositories;
}

public ArtifactRepository getLocalRepository() {
return localRepository;
}

public MavenProject getMavenProject() {
return mavenProject;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void testMavenProjectNameIsNotAvailable() {

private MavenParameters createMavenParameters() {
RemoteRepository remoteRepository = new RemoteRepository.Builder("id", "type", "http://example.org").build();
return new MavenParameters(new ArrayList<ArtifactRepository>(), mock(ArtifactRepository.class),
return new MavenParameters(new ArrayList<ArtifactRepository>(),
new MavenProject(), mock(MojoExecution.class), "", mock(RepositorySystem.class), mock(
RepositorySystemSession.class), Collections.singletonList(remoteRepository));
}
Expand Down

0 comments on commit f7bbca0

Please sign in to comment.