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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0cda525
MJAVADOC-617 Normalize module path so that '..' in the path are resolved
weissreto 5f6d44c
MJAVADOC-617 Add regression test
weissreto 437d736
MJAVADOC-617 Simplify code as suggested by review
weissreto 0faa689
MJAVADOC-617 Fix checkstyle problems
weissreto 793f6f7
MJAVADOC-617 Refactor duplicated code into abstract sub classes
weissreto cc66703
MJAVADOC-617 improve test assertions
weissreto File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
import java.io.FileReader; | ||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Locale; | ||
|
||
import org.apache.maven.execution.MavenSession; | ||
import org.apache.maven.model.Plugin; | ||
|
@@ -232,18 +233,10 @@ 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(); | ||
String overview = readFile( overviewSummary ).toLowerCase( Locale.ENGLISH ); | ||
assertTrue( overview.contains( "<a href=\"resources/test/package-summary.html\">resources.test</a>" ) ); | ||
assertTrue( overview.contains( ">blabla</" ) ); | ||
assertTrue( overview.contains( "<a href=\"resources/test2/package-summary.html\">resources.test2</a>" ) ); | ||
|
@@ -257,4 +250,25 @@ 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() ); | ||
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. exists --> isFile? |
||
} | ||
|
||
private static File getOverviewSummary(File apidocs) | ||
{ | ||
if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isBefore( "11" ) ) | ||
{ | ||
return new File( apidocs, "overview-summary.html" ); | ||
} | ||
return new File( apidocs, "index.html" ); | ||
} | ||
|
||
} |
82 changes: 82 additions & 0 deletions
82
...t/java/org/apache/maven/plugins/javadoc/stubs/AbstractAggregateChildMavenProjectStub.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
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:reto.weiss@axonivy.com">Reto Weiss</a> | ||
*/ | ||
public class AbstractAggregateChildMavenProjectStub | ||
extends MavenProjectStub | ||
{ | ||
private String baseDir; | ||
|
||
public AbstractAggregateChildMavenProjectStub(String baseDir, String pomFileName, String targetDirectory) | ||
{ | ||
this.baseDir = baseDir; | ||
readModel( new File( getBasedir(), pomFileName ) ); | ||
|
||
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() + targetDirectory ); | ||
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() + baseDir ); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public MavenProject getExecutionProject() | ||
{ | ||
return this; | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
src/test/java/org/apache/maven/plugins/javadoc/stubs/AbstractAggregateMavenProjectStub.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
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.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
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:reto.weiss@axonivy.com">Reto Weiss</a> | ||
*/ | ||
public class AbstractAggregateMavenProjectStub | ||
extends MavenProjectStub | ||
{ | ||
private final String baseDir; | ||
private final String[] projects; | ||
public AbstractAggregateMavenProjectStub(String baseDir, String pomFileName, String targetDirectory, String... projects) | ||
{ | ||
this.baseDir = baseDir; | ||
this.projects = projects; | ||
readModel( new File( getBasedir(), pomFileName) ); | ||
|
||
setGroupId( getModel().getGroupId() ); | ||
setArtifactId( getModel().getArtifactId() ); | ||
setVersion( getModel().getVersion() ); | ||
setName( getModel().getName() ); | ||
setUrl( getModel().getUrl() ); | ||
setPackaging( getModel().getPackaging() ); | ||
|
||
setExecutionRoot( true ); | ||
|
||
Build build = new Build(); | ||
build.setFinalName( getModel().getArtifactId() ); | ||
build.setSourceDirectory( getBasedir() + "/src/main/java" ); | ||
build.setDirectory( super.getBasedir() + targetDirectory ); | ||
setBuild( build ); | ||
|
||
List<String> compileSourceRoots = new ArrayList<>(); | ||
setCompileSourceRoots( compileSourceRoots ); | ||
} | ||
|
||
@Override | ||
public File getBasedir() | ||
{ | ||
return new File( super.getBasedir() + baseDir); | ||
} | ||
|
||
@Override | ||
public MavenProject getExecutionProject() | ||
{ | ||
return this; | ||
} | ||
|
||
@Override | ||
public List<String> getModules() | ||
{ | ||
return Arrays.asList( projects ); | ||
} | ||
|
||
@Override | ||
public Set<Artifact> getDependencyArtifacts() | ||
{ | ||
return Collections.emptySet(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ache/maven/plugins/javadoc/stubs/AggregateNotInSubFolderProject1TestMavenProjectStub.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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. | ||
*/ | ||
|
||
/** | ||
* @author <a href="mailto:reto.weiss@axonivy.com">Reto Weiss</a> | ||
*/ | ||
public class AggregateNotInSubFolderProject1TestMavenProjectStub | ||
extends AbstractAggregateChildMavenProjectStub | ||
{ | ||
public AggregateNotInSubFolderProject1TestMavenProjectStub() | ||
{ | ||
super( "/src/test/resources/unit/aggregate-modules-not-in-subfolders-test/project1", | ||
"pom.xml", | ||
"/target/test/unit/aggregate-modules-not-in-subfolders-test/project1/target" ); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ache/maven/plugins/javadoc/stubs/AggregateNotInSubFolderProject2TestMavenProjectStub.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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. | ||
*/ | ||
|
||
/** | ||
* @author <a href="mailto:reto.weiss@axonivy.com">Reto Weiss</a> | ||
*/ | ||
public class AggregateNotInSubFolderProject2TestMavenProjectStub | ||
extends AbstractAggregateChildMavenProjectStub | ||
{ | ||
public AggregateNotInSubFolderProject2TestMavenProjectStub() | ||
{ | ||
super( "/src/test/resources/unit/aggregate-modules-not-in-subfolders-test/project2", | ||
"pom.xml", | ||
"/target/test/unit/aggregate-modules-not-in-subfolders-test/project2/target"); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...a/org/apache/maven/plugins/javadoc/stubs/AggregateNotInSubFolderTestMavenProjectStub.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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. | ||
*/ | ||
|
||
/** | ||
* @author <a href="mailto:reto.weiss@axonivy.com">Reto Weiss</a> | ||
*/ | ||
public class AggregateNotInSubFolderTestMavenProjectStub | ||
extends AbstractAggregateMavenProjectStub | ||
{ | ||
public AggregateNotInSubFolderTestMavenProjectStub() | ||
{ | ||
super( "/src/test/resources/unit/aggregate-modules-not-in-subfolders-test/all", | ||
"pom.xml", | ||
"/target/test/unit/aggregate-modules-not-in-subfolders-test/target", | ||
"../project1", | ||
"../project2"); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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