Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MJAVADOC-617] Normalize module path so that '..' in the path are res…
…olved (#27) * MJAVADOC-617 Normalize module path so that '..' in the path are resolved 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. * MJAVADOC-617 Add regression test * MJAVADOC-617 Simplify code as suggested by review * MJAVADOC-617 Fix checkstyle problems * MJAVADOC-617 Refactor duplicated code into abstract sub classes - Refactor duplicated code into common new AbstractAggregateMavenProjectStub and AbstractAggregateChildMavenProjectStub classes - Fix toLowerCase without Locale - Simplify method getOverviewSummary and make it static * MJAVADOC-617 improve test assertions
- Loading branch information
Showing
15 changed files
with
497 additions
and
168 deletions.
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
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.