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

[MJAVADOC-782] Align read-only parameters naming with other plugins #251

Merged
merged 1 commit into from
Nov 26, 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 @@ -328,8 +328,8 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
@Parameter(defaultValue = "${project}", readonly = true, required = true)
protected MavenProject project;

@Parameter(defaultValue = "${mojoExecution}", readonly = true)
private MojoExecution mojo;
@Parameter(defaultValue = "${mojoExecution}", readonly = true, required = true)
protected MojoExecution mojoExecution;

/**
* Specify if the Javadoc plugin should operate in offline mode. If maven is run in offline
Expand Down Expand Up @@ -421,8 +421,8 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
/**
* The projects in the reactor for aggregation report.
*/
@Parameter(property = "reactorProjects", readonly = true)
private List<MavenProject> reactorProjects;
@Parameter(defaultValue = "${reactorProjects}", required = true, readonly = true)
protected List<MavenProject> reactorProjects;

/**
* Set this to <code>true</code> to debug the Javadoc plugin. With this, <code>javadoc.bat(or.sh)</code>,
Expand Down Expand Up @@ -1828,7 +1828,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
abstract void doExecute() throws MojoExecutionException, MojoFailureException;

protected final void verifyRemovedParameter(String paramName) {
Xpp3Dom configDom = mojo.getConfiguration();
Xpp3Dom configDom = mojoExecution.getConfiguration();
if (configDom != null) {
if (configDom.getChild(paramName) != null) {
throw new IllegalArgumentException(
Expand All @@ -1838,7 +1838,7 @@ protected final void verifyRemovedParameter(String paramName) {
}

private void verifyReplacedParameter(String oldParamName, String newParamNew) {
Xpp3Dom configDom = mojo.getConfiguration();
Xpp3Dom configDom = mojoExecution.getConfiguration();
if (configDom != null) {
if (configDom.getChild(oldParamName) != null) {
throw new IllegalArgumentException("parameter '" + oldParamName + "' has been replaced with "
Expand Down Expand Up @@ -6042,6 +6042,10 @@ protected void logError(String message, Throwable t) {
}
}

protected List<MavenProject> getReactorProjects() {
return reactorProjects;
}

/**
* @param prefix The prefix of the exception.
* @param e The exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ protected void setUp() throws Exception {
private JavadocReport lookupMojo(File testPom) throws Exception {
JavadocReport mojo = (JavadocReport) lookupMojo("aggregate", testPom);

MojoExecution mojoExec = new MojoExecution(new Plugin(), "aggregate", null);
setVariableValueToObject(mojo, "mojo", mojoExec);
Plugin p = new Plugin();
p.setGroupId("org.apache.maven.plugins");
p.setArtifactId("maven-javadoc-plugin");
MojoExecution mojoExecution = new MojoExecution(p, "aggregate", null);

setVariableValueToObject(mojo, "mojoExecution", mojoExecution);

MavenProject currentProject = new MavenProjectStub();
currentProject.setGroupId("GROUPID");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ public class JavadocJarTest extends AbstractMojoTestCase {
private JavadocJar lookupMojo(File testPom) throws Exception {
JavadocJar mojo = (JavadocJar) lookupMojo("jar", testPom);

MojoExecution mojoExec = new MojoExecution(new Plugin(), "javadoc", null);
Plugin p = new Plugin();
p.setGroupId("org.apache.maven.plugins");
p.setArtifactId("maven-javadoc-plugin");
MojoExecution mojoExecution = new MojoExecution(p, "jar", null);

setVariableValueToObject(mojo, "mojo", mojoExec);
setVariableValueToObject(mojo, "mojoExecution", mojoExecution);

MavenProject currentProject = new MavenProjectStub();
currentProject.setGroupId("GROUPID");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -113,17 +114,23 @@ protected void tearDown() throws Exception {
private JavadocReport lookupMojo(Path testPom) throws Exception {
JavadocReport mojo = (JavadocReport) lookupMojo("javadoc", testPom.toFile());

MojoExecution mojoExec = new MojoExecution(new Plugin(), "javadoc", null);
Plugin p = new Plugin();
p.setGroupId("org.apache.maven.plugins");
p.setArtifactId("maven-javadoc-plugin");
MojoExecution mojoExecution = new MojoExecution(p, "javadoc", null);

setVariableValueToObject(mojo, "mojo", mojoExec);
setVariableValueToObject(mojo, "mojoExecution", mojoExecution);

MavenProject currentProject = new MavenProjectStub();
currentProject.setGroupId("GROUPID");
currentProject.setArtifactId("ARTIFACTID");

List<MavenProject> reactorProjects =
mojo.getReactorProjects() != null ? mojo.getReactorProjects() : Collections.emptyList();
MavenSession session = newMavenSession(currentProject);
setVariableValueToObject(mojo, "session", session);
setVariableValueToObject(mojo, "repoSession", session.getRepositorySession());
setVariableValueToObject(mojo, "reactorProjects", reactorProjects);
return mojo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ public void testTestJavadoc() throws Exception {
new File(getBasedir(), "src/test/resources/unit/test-javadoc-test/test-javadoc-test-plugin-config.xml");
TestJavadocReport mojo = (TestJavadocReport) lookupMojo("test-javadoc", testPom);

MojoExecution mojoExec = new MojoExecution(new Plugin(), "test-javadoc", null);
Plugin p = new Plugin();
p.setGroupId("org.apache.maven.plugins");
p.setArtifactId("maven-javadoc-plugin");
MojoExecution mojoExecution = new MojoExecution(p, "test-javadoc", null);

setVariableValueToObject(mojo, "mojo", mojoExec);
setVariableValueToObject(mojo, "mojoExecution", mojoExecution);

MavenProject currentProject = new MavenProjectStub();
currentProject.setGroupId("GROUPID");
Expand Down