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 Feb 12, 2023
1 parent cf99987 commit 3ae6d03
Show file tree
Hide file tree
Showing 18 changed files with 165 additions and 81 deletions.
6 changes: 3 additions & 3 deletions maven-jxr-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven.jxr</groupId>
<artifactId>jxr</artifactId>
<version>3.3.1-SNAPSHOT</version>
<version>4.0.0-M1-SNAPSHOT</version>
</parent>

<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -89,12 +89,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-M4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
<version>3.2.0</version>
<version>4.0.0-M4</version>
</dependency>

<!-- shared utils -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public abstract class AbstractJxrReport
/**
* 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 = "&#169; {inceptionYear}&#x2013;{currentYear} {organizationName}" )
private String bottom;

// CHECKSTYLE_ON: LineLength
Expand Down Expand Up @@ -111,12 +111,6 @@ public abstract class AbstractJxrReport
@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 @@ -418,15 +412,16 @@ protected MavenProject getProject()
return project;
}

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

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

/**
* Returns the correct resource bundle according to the locale.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ 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 @@ -108,14 +108,14 @@ 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 @@ -65,14 +65,14 @@ 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 @@ -88,7 +88,7 @@ protected List<String> getSourceRoots( MavenProject project )

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 @@ -22,6 +22,8 @@
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.plugin.LegacySupport;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
Expand Down Expand Up @@ -125,8 +127,12 @@ protected AbstractJxrReport createReportMojo( String goal, File pluginXmlFile )
(DefaultRepositorySystemSession) legacySupport.getRepositorySession();
repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory().newInstance( repoSession, new LocalRepository( artifactStubFactory.getWorkingDir() ) ) );

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ public void testJdk4Configuration()

//check if there's a link to the javadoc files
String str = readFile( xrefDir, "def/configuration/AppSample.html" );
assertTrue( str.toLowerCase( Locale.US ).contains( "/apidocs/def/configuration/appsample.html\"" ) );
assertTrue( str.toLowerCase( Locale.ENGLISH ).contains( "/apidocs/def/configuration/appsample.html\"" ) );

str = readFile( xrefDir, "def/configuration/App.html" );
assertTrue( str.toLowerCase( Locale.US ).contains( "/apidocs/def/configuration/app.html\"" ) );
assertTrue( str.toLowerCase( Locale.ENGLISH ).contains( "/apidocs/def/configuration/app.html\"" ) );

// check if encoding is UTF-8, the default value
assertTrue( str.contains( "text/html; charset=UTF-8" ) );
Expand Down Expand Up @@ -141,10 +141,10 @@ public void testJdk6Configuration()

//check if there's a link to the javadoc files
String str = readFile( xrefDir, "def/configuration/AppSample.html" );
assertTrue( str.toLowerCase( Locale.US ).contains( "/apidocs/def/configuration/appsample.html\"" ) );
assertTrue( str.toLowerCase( Locale.ENGLISH ).contains( "/apidocs/def/configuration/appsample.html\"" ) );

str = readFile( xrefDir, "def/configuration/App.html" );
assertTrue( str.toLowerCase( Locale.US ).contains( "/apidocs/def/configuration/app.html\"" ) );
assertTrue( str.toLowerCase( Locale.ENGLISH ).contains( "/apidocs/def/configuration/app.html\"" ) );

// check if encoding is UTF-8, the default value
assertTrue( str.contains( "text/html; charset=UTF-8" ) );
Expand Down Expand Up @@ -184,10 +184,10 @@ public void testJdk7Configuration()

//check if there's a link to the javadoc files
String str = readFile( xrefDir, "def/configuration/AppSample.html" );
assertTrue( str.toLowerCase( Locale.US ).contains( "/apidocs/def/configuration/appsample.html\"" ) );
assertTrue( str.toLowerCase( Locale.ENGLISH ).contains( "/apidocs/def/configuration/appsample.html\"" ) );

str = readFile( xrefDir, "def/configuration/App.html" );
assertTrue( str.toLowerCase( Locale.US ).contains( "/apidocs/def/configuration/app.html\"" ) );
assertTrue( str.toLowerCase( Locale.ENGLISH ).contains( "/apidocs/def/configuration/app.html\"" ) );

// check if encoding is UTF-8, the default value
assertTrue( str.contains( "text/html; charset=UTF-8" ) );
Expand Down Expand Up @@ -260,11 +260,11 @@ public void testNoJavadocLink()

//check if there's a link to the javadoc files
String str = readFile( xrefDir, "nojavadoclink/configuration/AppSample.html" );
assertEquals( str.toLowerCase( Locale.US ).indexOf( "/apidocs/nojavadoclink/configuration/appsample.html\"" ),
assertEquals( str.toLowerCase( Locale.ENGLISH ).indexOf( "/apidocs/nojavadoclink/configuration/appsample.html\"" ),
-1 );

str = readFile( xrefDir, "nojavadoclink/configuration/App.html" );
assertEquals( str.toLowerCase( Locale.US ).indexOf( "/apidocs/nojavadoclink/configuration/app.html\"" ), -1 );
assertEquals( str.toLowerCase( Locale.ENGLISH ).indexOf( "/apidocs/nojavadoclink/configuration/app.html\"" ), -1 );

str = readFile( xrefDir, "nojavadoclink/configuration/sample/Sample.html" );
assertEquals( str.toLowerCase().indexOf( "/apidocs/nojavadoclink/configuration/sample/sample.html\"" ), -1 );
Expand Down Expand Up @@ -312,10 +312,10 @@ public void testNoJavadocDir()

//check if there's a link to the javadoc files
String str = readFile( xrefDir, "nojavadocdir/test/AppSample.html" );
assertTrue( str.toLowerCase( Locale.US ).contains( "/apidocs/nojavadocdir/test/appsample.html" ) );
assertTrue( str.toLowerCase( Locale.ENGLISH ).contains( "/apidocs/nojavadocdir/test/appsample.html" ) );

str = readFile( xrefDir, "nojavadocdir/test/App.html" );
assertTrue( str.toLowerCase( Locale.US ).contains( "/apidocs/nojavadocdir/test/app.html" ) );
assertTrue( str.toLowerCase( Locale.ENGLISH ).contains( "/apidocs/nojavadocdir/test/app.html" ) );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;

import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -33,7 +34,7 @@
* @author <a href="mailto:[email protected]">Maria Odea Ching</a>
*/
public class AggregateTestMavenProjectStub
extends MavenProjectStub
extends JxrProjectStub
{
private List<ReportPlugin> reportPlugins = new ArrayList<>();

Expand All @@ -45,7 +46,7 @@ public AggregateTestMavenProjectStub()
try
{
model = pomReader.read( new FileReader(
getBasedir() + "/src/test/resources/unit/aggregate-test/aggregate-test-plugin-config.xml" ) );
getBasedir() + "/" + getPOM() ) );
setModel( model );
}
catch ( Exception ignored )
Expand All @@ -61,7 +62,7 @@ public AggregateTestMavenProjectStub()

String basedir = getBasedir().getAbsolutePath();
List<String> compileSourceRoots = new ArrayList<>();
compileSourceRoots.add( basedir + "/src/test/resources/unit/aggregate-test/aggregate/test" );
compileSourceRoots.add( basedir + "/aggregate/test" );
setCompileSourceRoots( compileSourceRoots );

//set the report plugins
Expand All @@ -78,4 +79,14 @@ public List<ReportPlugin> getReportPlugins()
{
return reportPlugins;
}

@Override
public File getBasedir() {
return new File( super.getBasedir() + "/aggregate-test" );
}

@Override
protected String getPOM() {
return "aggregate-test-plugin-config.xml";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.apache.maven.model.Model;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;

import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -33,7 +33,7 @@
* @author <a href="mailto:[email protected]">Maria Odea Ching</a>
*/
public class DefaultConfigurationMavenProjectStub
extends MavenProjectStub
extends JxrProjectStub
{
private List<ReportPlugin> reportPlugins = new ArrayList<>();

Expand All @@ -45,7 +45,7 @@ public DefaultConfigurationMavenProjectStub()
try
{
model = pomReader.read( new FileReader( getBasedir() +
"/src/test/resources/unit/default-configuration/default-configuration-plugin-config.xml" ) );
"/" + getPOM() ) );
setModel( model );
}
catch ( Exception ignored )
Expand All @@ -61,7 +61,7 @@ public DefaultConfigurationMavenProjectStub()

String basedir = getBasedir().getAbsolutePath();
List<String> compileSourceRoots = new ArrayList<>();
compileSourceRoots.add( basedir + "/src/test/resources/unit/default-configuration/def/configuration" );
compileSourceRoots.add( basedir + "/def/configuration" );
setCompileSourceRoots( compileSourceRoots );

//set the report plugins
Expand All @@ -79,4 +79,13 @@ public List<ReportPlugin> getReportPlugins()
return reportPlugins;
}

@Override
public File getBasedir() {
return new File( super.getBasedir() + "/default-configuration" );
}

@Override
protected String getPOM() {
return "default-configuration-plugin-config.xml";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;

import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -43,8 +44,7 @@ public ExcludeConfigurationMavenProjectStub()

try
{
model = pomReader.read( new FileReader( getBasedir() +
"/src/test/resources/unit/exclude-configuration/exclude-configuration-plugin-config.xml" ) );
model = pomReader.read( new FileReader( getBasedir() + "/" + getPOM() ) );
setModel( model );
}
catch ( Exception ignored )
Expand All @@ -60,7 +60,7 @@ public ExcludeConfigurationMavenProjectStub()

String basedir = getBasedir().getAbsolutePath();
List<String> compileSourceRoots = new ArrayList<>();
compileSourceRoots.add( basedir + "/src/test/resources/unit/exclude-configuration/exclude/configuration" );
compileSourceRoots.add( basedir + "/exclude/configuration" );
setCompileSourceRoots( compileSourceRoots );

// set the report plugins
Expand All @@ -77,4 +77,14 @@ public List<ReportPlugin> getReportPlugins()
{
return reportPlugins;
}

@Override
public File getBasedir() {
return new File( super.getBasedir() + "/exclude-configuration" );
}

@Override
protected String getPOM() {
return "exclude-configuration-plugin-config.xml";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;

import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -43,8 +44,7 @@ public IncludeConfigurationMavenProjectStub()

try
{
model = pomReader.read( new FileReader( getBasedir() +
"/src/test/resources/unit/include-configuration/include-configuration-plugin-config.xml" ) );
model = pomReader.read( new FileReader( getBasedir() + "/" + getPOM() ) );
setModel( model );
}
catch ( Exception ignored )
Expand All @@ -61,7 +61,7 @@ public IncludeConfigurationMavenProjectStub()
String basedir = getBasedir().getAbsolutePath();
List<String> compileSourceRoots = new ArrayList<>();
compileSourceRoots.add(
basedir + "/src/test/resources/unit/include-configuration/include/configuration" );
basedir + "/include/configuration" );
setCompileSourceRoots( compileSourceRoots );

// set the report plugins
Expand All @@ -78,4 +78,14 @@ public List<ReportPlugin> getReportPlugins()
{
return reportPlugins;
}

@Override
public File getBasedir() {
return new File( super.getBasedir() + "/include-configuration" );
}

@Override
protected String getPOM() {
return "include-configuration-plugin-config.xml";
}
}
Loading

0 comments on commit 3ae6d03

Please sign in to comment.