Skip to content

Commit

Permalink
Prepare for Doxia 2.0.0
Browse files Browse the repository at this point in the history
This also fixes JXR-169
  • Loading branch information
michael-o committed Nov 12, 2023
1 parent 0e94f5b commit fbffcf7
Show file tree
Hide file tree
Showing 33 changed files with 257 additions and 195 deletions.
8 changes: 4 additions & 4 deletions maven-jxr-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven.jxr</groupId>
<artifactId>jxr</artifactId>
<version>3.3.2-SNAPSHOT</version>
<version>4.0.0-M1-SNAPSHOT</version>
</parent>

<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -88,12 +88,12 @@ under the License.
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
<version>3.1.1</version>
<version>4.0.0-M8</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
<version>3.2.0</version>
<version>4.0.0-M11</version>
</dependency>

<!-- shared utils -->
Expand Down Expand Up @@ -152,7 +152,7 @@ under the License.
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http-lightweight</artifactId>
<version>3.5.1</version>
<version>3.5.3</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.apache.maven.jxr.pacman.FileManager;
import org.apache.maven.jxr.pacman.PackageManager;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
Expand Down Expand Up @@ -73,10 +74,7 @@ public abstract class AbstractJxrReport extends AbstractMavenReport {
/**
* String used at the bottom of the Xref HTML files.
*/
@Parameter(
property = "bottom",
defaultValue =
"Copyright &#169; {inceptionYear}&#x2013;{currentYear} {organizationName}. All rights reserved.")
@Parameter(property = "bottom", defaultValue = "\u00A9 {inceptionYear}\u2013{currentYear} {organizationName}")
private String bottom;

// CHECKSTYLE_ON: LineLength
Expand Down Expand Up @@ -111,12 +109,6 @@ public abstract class AbstractJxrReport extends AbstractMavenReport {
@Parameter
private ArrayList<String> includes;

/**
* The projects in the reactor for aggregation report.
*/
@Parameter(defaultValue = "${reactorProjects}", readonly = true)
protected List<MavenProject> reactorProjects;

/**
* Whether to skip this execution.
*
Expand Down Expand Up @@ -258,12 +250,12 @@ private String getBottomText() {

if (inceptionYear != null) {
if (inceptionYear.equals(year)) {
theBottom = StringUtils.replace(theBottom, "{inceptionYear}&#x2013;", "");
theBottom = StringUtils.replace(theBottom, "{inceptionYear}\u2013", "");
} else {
theBottom = StringUtils.replace(theBottom, "{inceptionYear}", inceptionYear);
}
} else {
theBottom = StringUtils.replace(theBottom, "{inceptionYear}&#x2013;", "");
theBottom = StringUtils.replace(theBottom, "{inceptionYear}\u2013", "");
}

if (project.getOrganization() == null) {
Expand Down Expand Up @@ -359,14 +351,18 @@ protected MavenProject getProject() {
return project;
}

/**
* Returns the Maven session.
* @return Maven session
*/
protected MavenSession getSession() {
return session;
}

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

protected MojoExecution getMojoExecution() {
return mojoExecution;
}

/**
* Returns the correct resource bundle according to the locale.
*
Expand Down Expand Up @@ -395,7 +391,6 @@ protected boolean canGenerateReport(List<String> sourceDirs) {
@Override
protected void executeReport(Locale locale) throws MavenReportException {
if (skip) {
getLog().info("Skipping JXR.");
return;
}
List<String> sourceDirs = constructSourceDirs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ protected List<String> getSourceRoots() {

List<String> l = new ArrayList<>();

if (!"pom".equals(getProject().getPackaging().toLowerCase(Locale.US))) {
if (!"pom".equals(getProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
l.addAll(sourceDirs);
}

if (getProject().getExecutionProject() != null) {
if (!"pom".equals(getProject().getExecutionProject().getPackaging().toLowerCase(Locale.US))) {
if (!"pom".equals(getProject().getExecutionProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
l.addAll(getProject().getExecutionProject().getCompileSourceRoots());
}
}
Expand All @@ -97,12 +97,12 @@ protected List<String> getSourceRoots() {
protected List<String> getSourceRoots(MavenProject project) {
List<String> l = new ArrayList<>();

if (!"pom".equals(project.getPackaging().toLowerCase(Locale.US))) {
if (!"pom".equals(project.getPackaging().toLowerCase(Locale.ENGLISH))) {
l.addAll(project.getCompileSourceRoots());
}

if (project.getExecutionProject() != null) {
if (!"pom".equals(project.getExecutionProject().getPackaging().toLowerCase(Locale.US))) {
if (!"pom".equals(project.getExecutionProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
l.addAll(project.getExecutionProject().getCompileSourceRoots());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ public class JxrTestReport extends AbstractJxrReport {
protected List<String> getSourceRoots() {
List<String> l = new ArrayList<>();

if (!"pom".equals(getProject().getPackaging().toLowerCase(Locale.US))) {
if (!"pom".equals(getProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
l.addAll(sourceDirs);
}

if (getProject().getExecutionProject() != null) {
if (!"pom".equals(getProject().getExecutionProject().getPackaging().toLowerCase(Locale.US))) {
if (!"pom".equals(getProject().getExecutionProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
l.addAll(getProject().getExecutionProject().getTestCompileSourceRoots());
}
}
Expand All @@ -79,7 +79,7 @@ protected List<String> getSourceRoots(MavenProject project) {
List<String> l = new ArrayList<>();

if (project.getExecutionProject() != null) {
if (!"pom".equals(project.getExecutionProject().getPackaging().toLowerCase(Locale.US))) {
if (!"pom".equals(project.getExecutionProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
l.addAll(project.getExecutionProject().getTestCompileSourceRoots());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Collections;
import java.util.List;

import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
Expand Down Expand Up @@ -112,8 +118,17 @@ protected AbstractJxrReport createReportMojo(String goal, File pluginXmlFile) th
repoSession.setLocalRepositoryManager(new SimpleLocalRepositoryManagerFactory()
.newInstance(repoSession, new LocalRepository(artifactStubFactory.getWorkingDir())));

List<MavenProject> reactorProjects =
mojo.getReactorProjects() != null ? mojo.getReactorProjects() : Collections.emptyList();

setVariableValueToObject(mojo, "mojoExecution", getMockMojoExecution());
setVariableValueToObject(mojo, "session", legacySupport.getSession());
setVariableValueToObject(mojo, "remoteRepositories", mojo.getProject().getRemoteArtifactRepositories());
setVariableValueToObject(mojo, "repoSession", legacySupport.getRepositorySession());
setVariableValueToObject(mojo, "reactorProjects", reactorProjects);
setVariableValueToObject(
mojo, "remoteProjectRepositories", mojo.getProject().getRemoteProjectRepositories());
setVariableValueToObject(
mojo, "siteDirectory", new File(mojo.getProject().getBasedir(), "src/site"));
return mojo;
}

Expand All @@ -139,4 +154,22 @@ protected File generateReport(AbstractJxrReport mojo, File pluginXmlFile) throws
protected String readFile(File xrefTestDir, String fileName) throws IOException {
return new String(Files.readAllBytes(xrefTestDir.toPath().resolve(fileName)));
}

private MojoExecution getMockMojoExecution() {
MojoDescriptor md = new MojoDescriptor();
md.setGoal(getGoal());

MojoExecution me = new MojoExecution(md);

PluginDescriptor pd = new PluginDescriptor();
Plugin p = new Plugin();
p.setGroupId("org.apache.maven.plugins");
p.setArtifactId("maven-jxr-plugin");
pd.setPlugin(p);
md.setPluginDescriptor(pd);

return me;
}

protected abstract String getGoal();
}
Loading

0 comments on commit fbffcf7

Please sign in to comment.