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-617] Normalize module path so that '..' in the path are resolved #27
Conversation
On line 2403 a path is removed from a map. The given path may not be normalized but the pathes in the map are. This leads to the fact that the project for the given path is not found. And therefore no javadoc for the project is generated. By normalizing the module path on line 2396 the code works event if the module path has '..' in it.
I see that this project is active. The javadoc plugin version 3.1.1 has this bug, @weissreto has proposed a fix. Is the team considering a merge and release of a new version? Thanks in advance for any info. |
@chrisinmtown yes the project is hopefully still alive :) I will check this issue as soon as I have cycles |
Thanks @eolivelli for the quick reply. |
@@ -2393,7 +2393,7 @@ protected void executeReport( Locale unusedLocale ) | |||
List<Path> modulePaths = new LinkedList<>(); | |||
for ( String module : aggregatedProject.getModules() ) | |||
{ | |||
modulePaths.add( new File( aggregatedProject.getBasedir(), module ).toPath() ); | |||
modulePaths.add( new File( aggregatedProject.getBasedir(), module ).toPath().normalize() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably use Paths.get here and avoid the File class completely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have simpified code to use only class Path and not File.
Added also a regression test for the issue
@@ -1,5 +1,43 @@ | |||
package org.apache.maven.plugins.javadoc; | |||
|
|||
import static org.apache.maven.plugins.javadoc.JavadocUtil.isEmpty; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a not a well known class so static imports should probably be avoided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Elliotte
Sorry I messed up this commit, because my IDE reorganized the whole import section of this file. I reverted that in my last commit. I could squash the commits to get a clearer history if that is recommended. However I have not introduced this static import in this commit here I only moved it around.
Do I still have to refactor this static import? This will introduce some additional changes to this PR that are not relevant to the issue I try to fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that the imports were reorganized. If this is existing code, no need to fix it here. I don't know if maven follows any conventions for import ordering, but absent that it's best not to reorder imports to avoid churn.
{ | ||
overviewSummary = new File( apidocs, "index.html" ); | ||
} | ||
File overviewSummary = getOverviewSummary(apidocs); | ||
|
||
assertTrue( overviewSummary.exists() ); | ||
String overview = readFile( overviewSummary ).toLowerCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toLowerCase needs a locale
mojo.execute(); | ||
|
||
File apidocs = new File( getBasedir(), "target/test/unit/aggregate-modules-not-in-subfolders-test/target/site/apidocs" ); | ||
assertTrue(apidocs.exists()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertTrue( apidocs.exists() );
|
||
File apidocs = new File( getBasedir(), "target/test/unit/aggregate-modules-not-in-subfolders-test/target/site/apidocs" ); | ||
assertTrue(apidocs.exists()); | ||
assertTrue( getOverviewSummary(apidocs).exists() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
( apidocs )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems checkstyle does not run on test classes ...
Will fix
File overviewSummary; | ||
if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isBefore( "11" ) ) | ||
{ | ||
overviewSummary = new File( apidocs, "overview-summary.html" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return new File...
is shorter and avoids an uninitialized variable.
} | ||
else | ||
{ | ||
overviewSummary = new File( apidocs, "index.html" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return new File...
assertTrue( getOverviewSummary(apidocs).exists() ); | ||
} | ||
|
||
private File getOverviewSummary(File apidocs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static
import org.apache.maven.project.MavenProject; | ||
|
||
/** | ||
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this you?
import org.apache.maven.project.MavenProject; | ||
|
||
/** | ||
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you?
{ | ||
public AggregateNotInSubFolderProject2TestMavenProjectStub() | ||
{ | ||
readModel( new File( getBasedir(), "pom.xml" ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of duplicate code here that could probably be refactored into a common location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that there is alot of duplicated code. I copied them from older test classes that made the same thing. Will refactor all this code.
However, why do I need this stub classes at all? I tried to avoid them but then the test seems not to work correctly?
- Refactor duplicated code into common new AbstractAggregateMavenProjectStub and AbstractAggregateChildMavenProjectStub classes - Fix toLowerCase without Locale - Simplify method getOverviewSummary and make it static
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some nits
mojo.execute(); | ||
|
||
File apidocs = new File( getBasedir(), "target/test/unit/aggregate-modules-not-in-subfolders-test/target/site/apidocs" ); | ||
assertTrue( apidocs.exists() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apidocs.isDirectory() would be slightly stronger test
|
||
File apidocs = new File( getBasedir(), "target/test/unit/aggregate-modules-not-in-subfolders-test/target/site/apidocs" ); | ||
assertTrue( apidocs.exists() ); | ||
assertTrue( getOverviewSummary( apidocs ).exists() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exists --> isFile?
Hi Elliotte Thanks a lot for reviewing and approving my PR. Thanks for any advise. Regards |
Thanks a lot for your help |
On line 2403 a path is removed from a map. The given path may not be normalized but the pathes in the map are. This leads to the fact that the project for the given path is not found. And therefore no javadoc for the project is generated.
By normalizing the module path on line 2396 the code works event if the module path has '..' in it.
Following this checklist to help us incorporate your
contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
[MJAVADOC-XXX] - Fixes bug in ApproximateQuantiles
,where you replace
MJAVADOC-XXX
with the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
mvn clean verify
to make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.