Skip to content

[MJAVADOC-685] Deprecate parameter "stylesheet" #162

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

Merged
merged 2 commits into from
Sep 20, 2022
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 @@ -20,7 +20,6 @@
*/

import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.archiver.MavenArchiver;
import org.apache.maven.artifact.Artifact;
Expand Down Expand Up @@ -205,20 +204,11 @@ public abstract class AbstractJavadocMojo
protected static final String FILES_FILE_NAME = "files";

/**
* The current class directory
*/
private static final String RESOURCE_DIR = ClassUtils.getPackageName( JavadocReport.class ).replace( '.', '/' );

/**
* Default css file name
* Default css file name, used as file name in the output directory for the temporary custom stylesheet file
* loaded from classloader resources.
*/
private static final String DEFAULT_CSS_NAME = "stylesheet.css";

/**
* Default location for css
*/
private static final String RESOURCE_CSS_DIR = RESOURCE_DIR + "/css";

private static final String PACKAGE_LIST = "package-list";
private static final String ELEMENT_LIST = "element-list";

Expand Down Expand Up @@ -1255,12 +1245,13 @@ public abstract class AbstractJavadocMojo

/**
* Specifies whether the stylesheet to be used is the <code>maven</code>'s javadoc stylesheet or
* <code>java</code>'s default stylesheet when a <i>stylesheetfile</i> parameter is not specified.
* <code>java</code>'s default stylesheet when a {@link #stylesheetfile} parameter is not specified.
* <br/>
* Possible values: <code>maven<code> or <code>java</code>.
* <br/>
* @deprecated This is no longer evaluated, instead use {@link #addStylesheets} to customize the CSS.
*/
@Parameter( property = "stylesheet", defaultValue = "java" )
@Deprecated
private String stylesheet;

/**
Expand Down Expand Up @@ -2908,11 +2899,11 @@ private String getBottomText()
/**
* Method to get the stylesheet path file to be used by the Javadoc Tool.
* <br/>
* If the {@code stylesheetfile} is empty, return the file as String definded by {@code stylesheet} value.
* If the {@link #stylesheetfile} is empty, return the file as String defined by {@link #stylesheet} value.
* <br/>
* If the {@code stylesheetfile} is defined, return the file as String.
* If the {@link #stylesheetfile} is defined, return the file as String.
* <br/>
* Note: since 2.6, the {@code stylesheetfile} could be a path from a resource in the project source
* Note: since 2.6, the {@link #stylesheetfile} could be a path from a resource in the project source
* directories (i.e. <code>src/main/java</code>, <code>src/main/resources</code> or <code>src/main/javadoc</code>)
* or from a resource in the Javadoc plugin dependencies.
*
Expand All @@ -2930,8 +2921,9 @@ private Optional<File> getStylesheetFile( final File javadocOutputDirectory )
return Optional.empty();
}

// maven, see #copyDefaultStylesheet(File)
return Optional.of( new File( javadocOutputDirectory, DEFAULT_CSS_NAME ) );
getLog().warn( "Parameter 'stylesheet' is no longer evaluated, rather use 'addStylesheets'"
+ " to customize the CSS!" );
return Optional.empty();
}

if ( new File( stylesheetfile ).exists() )
Expand Down Expand Up @@ -4238,18 +4230,6 @@ private void addLinkArguments( List<String> arguments )
private void copyAllResources( File javadocOutputDirectory )
throws MavenReportException
{
// ----------------------------------------------------------------------
// Copy default resources
// ----------------------------------------------------------------------

try
{
copyDefaultStylesheet( javadocOutputDirectory );
}
catch ( IOException e )
{
throw new MavenReportException( "Unable to copy default stylesheet: " + e.getMessage(), e );
}

// ----------------------------------------------------------------------
// Copy javadoc resources
Expand Down Expand Up @@ -4278,34 +4258,6 @@ private void copyAllResources( File javadocOutputDirectory )
copyAdditionalJavadocResources( javadocOutputDirectory );
}

/**
* Copies the {@code DEFAULT_CSS_NAME} css file from the current class
* loader to the <code>outputDirectory</code> only if {@code stylesheetfile} is empty and
* {@code stylesheet} is equals to <code>maven</code>.
*
* @param anOutputDirectory the output directory
* @throws java.io.IOException if any
* @see #DEFAULT_CSS_NAME
* @see JavadocUtil#copyResource(java.net.URL, java.io.File)
*/
private void copyDefaultStylesheet( File anOutputDirectory )
throws IOException
{
if ( StringUtils.isNotEmpty( stylesheetfile ) )
{
return;
}

if ( !stylesheet.equalsIgnoreCase( "maven" ) )
{
return;
}

URL url = getClass().getClassLoader().getResource( RESOURCE_CSS_DIR + "/" + DEFAULT_CSS_NAME );
File outFile = new File( anOutputDirectory, DEFAULT_CSS_NAME );
JavadocUtil.copyResource( url, outFile );
}

/**
* Method that copy all <code>doc-files</code> directories from <code>javadocDirectory</code> of
* the current project or of the projects in the reactor to the <code>outputDirectory</code>.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1284,18 +1284,6 @@ else if ( JavaVersion.JAVA_VERSION.isAtLeast( "10" ) )
String optionsContent = readFile( options );
assertFalse( optionsContent.contains( "-stylesheetfile" ) );

// stylesheet == maven
setVariableValueToObject( mojo, "stylesheet", "maven" );
mojo.execute();

content = readFile( stylesheetfile );
assertTrue( content.contains( "/* Javadoc style sheet */" )
&& content.contains( "Licensed to the Apache Software Foundation (ASF) under one" ) );

optionsContent = readFile( options );
assertTrue( optionsContent.contains( "-stylesheetfile" ) );
assertTrue( optionsContent.contains( "'" + stylesheetfile.toFile().getAbsolutePath().replaceAll( "\\\\", "/" ) + "'" ) );

// stylesheetfile defined as a project resource
setVariableValueToObject( mojo, "stylesheet", null );
setVariableValueToObject( mojo, "stylesheetfile", "com/mycompany/app/javadoc/css/stylesheet.css" );
Expand Down