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
Changes from 3 commits
0cda525
5f6d44c
437d736
0faa689
793f6f7
cc66703
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,15 +232,7 @@ public void testAggregateJavadocResources() | |
File apidocs = new File( getBasedir(), "target/test/unit/aggregate-resources-test/target/site/apidocs" ); | ||
|
||
// Test overview | ||
File overviewSummary; | ||
if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isBefore( "11" ) ) | ||
{ | ||
overviewSummary = new File( apidocs, "overview-summary.html" ); | ||
} | ||
else | ||
{ | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. toLowerCase needs a locale |
||
|
@@ -257,4 +249,30 @@ public void testAggregateJavadocResources() | |
assertTrue( overview.contains( "<img src=\"doc-files/maven-feather.png\" alt=\"Maven\">" ) ); | ||
assertTrue( new File( apidocs, "resources/test/doc-files/maven-feather.png" ).exists() ); | ||
} | ||
|
||
public void testAggregateWithModulsNotInSubFolders() throws Exception | ||
{ | ||
File testPom = new File( unit, "aggregate-modules-not-in-subfolders-test/all/pom.xml"); | ||
JavadocReport mojo = lookupMojo( testPom ); | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
assertTrue( getOverviewSummary(apidocs).exists() ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems checkstyle does not run on test classes ... |
||
} | ||
|
||
private File getOverviewSummary(File apidocs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. static |
||
{ | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. return new File... |
||
} | ||
else | ||
{ | ||
overviewSummary = new File( apidocs, "index.html" ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return new File... |
||
} | ||
return overviewSummary; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package org.apache.maven.plugins.javadoc.stubs; | ||
|
||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import org.apache.maven.artifact.Artifact; | ||
import org.apache.maven.model.Build; | ||
import org.apache.maven.plugin.testing.stubs.MavenProjectStub; | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Is this you? |
||
*/ | ||
public class AggregateNotInSubFolderProject1TestMavenProjectStub | ||
extends MavenProjectStub | ||
{ | ||
public AggregateNotInSubFolderProject1TestMavenProjectStub() | ||
{ | ||
readModel( new File( getBasedir(), "pom.xml" ) ); | ||
|
||
setGroupId( Objects.toString( getModel().getGroupId(), getModel().getParent().getGroupId() ) ); | ||
setArtifactId( getModel().getArtifactId() ); | ||
setVersion( Objects.toString( getModel().getVersion(), getModel().getParent().getVersion() ) ); | ||
setName( getModel().getName() ); | ||
setUrl( getModel().getUrl() ); | ||
setPackaging( getModel().getPackaging() ); | ||
|
||
setExecutionRoot( true ); | ||
|
||
Artifact artifact = new JavadocPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() ); | ||
artifact.setArtifactHandler( new DefaultArtifactHandlerStub() ); | ||
setArtifact( artifact ); | ||
|
||
Build build = new Build(); | ||
build.setFinalName( getModel().getArtifactId() ); | ||
build.setSourceDirectory( getBasedir() + "/src/main/java" ); | ||
build.setDirectory( super.getBasedir() + "/target/test/unit/aggregate-modules-not-in-subfolders-test/project1/target" ); | ||
setBuild( build ); | ||
|
||
List<String> compileSourceRoots = new ArrayList<>(); | ||
compileSourceRoots.add( getBasedir().getAbsolutePath() + "/src/main/java" ); | ||
setCompileSourceRoots( compileSourceRoots ); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public File getBasedir() | ||
{ | ||
return new File( super.getBasedir() + "/src/test/resources/unit/aggregate-modules-not-in-subfolders-test/project1" ); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public MavenProject getExecutionProject() | ||
{ | ||
return this; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package org.apache.maven.plugins.javadoc.stubs; | ||
|
||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import org.apache.maven.artifact.Artifact; | ||
import org.apache.maven.model.Build; | ||
import org.apache.maven.plugin.testing.stubs.MavenProjectStub; | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. you? |
||
*/ | ||
public class AggregateNotInSubFolderProject2TestMavenProjectStub | ||
extends MavenProjectStub | ||
{ | ||
public AggregateNotInSubFolderProject2TestMavenProjectStub() | ||
{ | ||
readModel( new File( getBasedir(), "pom.xml" ) ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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? |
||
|
||
setGroupId( Objects.toString( getModel().getGroupId(), getModel().getParent().getGroupId() ) ); | ||
setArtifactId( getModel().getArtifactId() ); | ||
setVersion( Objects.toString( getModel().getVersion(), getModel().getParent().getVersion() ) ); | ||
setName( getModel().getName() ); | ||
setUrl( getModel().getUrl() ); | ||
setPackaging( getModel().getPackaging() ); | ||
|
||
setExecutionRoot( true ); | ||
|
||
Artifact artifact = new JavadocPluginArtifactStub( getGroupId(), getArtifactId(), getVersion(), getPackaging() ); | ||
artifact.setArtifactHandler( new DefaultArtifactHandlerStub() ); | ||
setArtifact( artifact ); | ||
|
||
Build build = new Build(); | ||
build.setFinalName( getModel().getArtifactId() ); | ||
build.setSourceDirectory( getBasedir() + "/src/main/java" ); | ||
build.setDirectory( super.getBasedir() + "/target/test/unit/aggregate-modules-not-in-subfolders-test/project2/target" ); | ||
setBuild( build ); | ||
|
||
List<String> compileSourceRoots = new ArrayList<>(); | ||
compileSourceRoots.add( getBasedir() + "/src/main/java" ); | ||
setCompileSourceRoots( compileSourceRoots ); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public File getBasedir() | ||
{ | ||
return new File( super.getBasedir() + "/src/test/resources/unit/aggregate-modules-not-in-subfolders-test/project2" ); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public MavenProject getExecutionProject() | ||
{ | ||
return this; | ||
} | ||
} |
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.