Skip to content

Commit 074d42d

Browse files
timoninmaximmichael-o
authored andcommitted
WIP
1 parent 4904e08 commit 074d42d

File tree

8 files changed

+317
-0
lines changed

8 files changed

+317
-0
lines changed

src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,4 +1294,23 @@ public void testHelpfile() throws Exception {
12941294
assertTrue(optionsContent.contains("-helpfile"));
12951295
assertTrue(optionsContent.contains("'" + help.toFile().getAbsolutePath().replaceAll("\\\\", "/") + "'"));
12961296
}
1297+
1298+
/** It should include only single class in javadoc. */
1299+
public void testSubpackagesExcludePackages() throws Exception {
1300+
Path testPom = unit.resolve("subpackages-exclude-packages-test/pom.xml");
1301+
1302+
JavadocReport mojo = lookupMojo(testPom);
1303+
1304+
mojo.execute();
1305+
1306+
Path apidocs = new File(getBasedir(), "target/test/unit/subpackages-exclude-packages-test/target/site/apidocs")
1307+
.toPath();
1308+
1309+
// check if the classes in the specified subpackages were included
1310+
assertThat(apidocs.resolve("org/apache/project/IncludeClass.html")).exists();
1311+
1312+
// check the excluded packages
1313+
assertThat(apidocs.resolve("org/apache/internal")).doesNotExist();
1314+
assertThat(apidocs.resolve("io")).doesNotExist();
1315+
}
12971316
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.plugins.javadoc.stubs;
20+
21+
import java.io.File;
22+
import java.util.ArrayList;
23+
import java.util.List;
24+
25+
import org.apache.maven.model.Build;
26+
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
27+
28+
/** */
29+
public class SubpackagesExcludePackagesTestMavenProjectStub extends MavenProjectStub {
30+
public SubpackagesExcludePackagesTestMavenProjectStub() {
31+
readModel(new File(getBasedir(), "pom.xml"));
32+
33+
setGroupId(getModel().getGroupId());
34+
setArtifactId(getModel().getArtifactId());
35+
setVersion(getModel().getVersion());
36+
37+
setName(getModel().getName());
38+
setUrl(getModel().getUrl());
39+
setPackaging(getModel().getPackaging());
40+
41+
Build build = new Build();
42+
build.setFinalName(getName());
43+
build.setDirectory(super.getBasedir() + "/target/test/unit/subpackages-exclude-packages-test/target");
44+
setBuild(build);
45+
46+
List<String> compileSourceRoots = new ArrayList<>();
47+
compileSourceRoots.add(getBasedir() + "/src/main/java");
48+
setCompileSourceRoots(compileSourceRoots);
49+
}
50+
51+
/** {@inheritDoc} */
52+
@Override
53+
public File getBasedir() {
54+
return new File(super.getBasedir() + "/src/test/resources/unit/subpackages-exclude-packages-test");
55+
}
56+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22+
<modelVersion>4.0.0</modelVersion>
23+
24+
<groupId>org.apache.maven.plugins.maven-javadoc-plugin.unit</groupId>
25+
<artifactId>subpackages-exclude-packages-test</artifactId>
26+
<version>1.0-SNAPSHOT</version>
27+
<packaging>jar</packaging>
28+
29+
<build>
30+
<plugins>
31+
<plugin>
32+
<groupId>org.apache.maven.plugins</groupId>
33+
<artifactId>maven-javadoc-plugin</artifactId>
34+
35+
<configuration>
36+
<project implementation="org.apache.maven.plugins.javadoc.stubs.SubpackagesExcludePackagesTestMavenProjectStub"/>
37+
38+
<outputDirectory>${basedir}/target/test/unit/subpackages-exclude-packages-test/target/site/apidocs</outputDirectory>
39+
<javadocOptionsDir>${basedir}/target/test/unit/subpackages-exclude-packages-test/target/javadoc-bundle-options</javadocOptionsDir>
40+
41+
<!-- Comment the next line, and javadoc will skip all subpackages under "internal" package -->
42+
<subpackages>org.apache</subpackages>
43+
44+
<excludePackageNames>
45+
org.apache.internal
46+
:org.apache.internal.*
47+
</excludePackageNames>
48+
49+
<debug>true</debug>
50+
51+
<reactorProjects>
52+
<project implementation="org.apache.maven.plugins.javadoc.stubs.SubpackagesExcludePackagesTestMavenProjectStub"/>
53+
</reactorProjects>
54+
55+
</configuration>
56+
</plugin>
57+
</plugins>
58+
</build>
59+
</project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package io;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
/**
23+
* Class to be excluded.
24+
*/
25+
public class ExcludeIoClass
26+
{
27+
/**
28+
* Sample method that prints out the parameter string.
29+
*
30+
* @param str The string value to be printed.
31+
*/
32+
public void sampleMethod( String str )
33+
{
34+
System.out.println( str );
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package org.apache.internal;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
import java.io.File;
23+
import java.io.IOException;
24+
25+
/**
26+
* Class to be excluded.
27+
*/
28+
public class ExcludeInternalClass
29+
{
30+
/**
31+
* Sample method that prints out the parameter string.
32+
*
33+
* @param str The string value to be printed.
34+
*/
35+
public void sampleMethod( String str )
36+
{
37+
System.out.println( str );
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.apache.internal.subpackage;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
/**
23+
* Class to be excluded.
24+
*/
25+
public class ExcludeInternalSubClass
26+
{
27+
/**
28+
* Sample method that prints out the parameter string.
29+
*
30+
* @param str The string value to be printed.
31+
*/
32+
public void sampleMethod( String str )
33+
{
34+
System.out.println( str );
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.apache.internal.subpackage.subsubpackage;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
/**
23+
* Class to be excluded.
24+
*/
25+
public class ExcludeInternalSubSubClass
26+
{
27+
/**
28+
* Sample method that prints out the parameter string.
29+
*
30+
* @param str The string value to be printed.
31+
*/
32+
public void sampleMethod( String str )
33+
{
34+
System.out.println( str );
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.apache.project;
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
/**
23+
* Class to be included.
24+
*/
25+
public class IncludeClass
26+
{
27+
/**
28+
* Sample method that prints out the parameter string.
29+
*
30+
* @param str The string value to be printed.
31+
*/
32+
public void sampleMethod( String str )
33+
{
34+
System.out.println( str );
35+
}
36+
}

0 commit comments

Comments
 (0)