Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
timoninmaxim committed Jun 20, 2024
1 parent aa0a666 commit 8edeca7
Show file tree
Hide file tree
Showing 8 changed files with 316 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1294,4 +1294,22 @@ public void testHelpfile() throws Exception {
assertTrue(optionsContent.contains("-helpfile"));
assertTrue(optionsContent.contains("'" + help.toFile().getAbsolutePath().replaceAll("\\\\", "/") + "'"));
}

/** It should include only single class in javadoc. */
public void testSubpackagesExcludePackages() throws Exception {
Path testPom = unit.resolve("subpackages-exclude-packages-test/pom.xml");

JavadocReport mojo = lookupMojo(testPom);

mojo.execute();

Path apidocs = new File(getBasedir(), "target/test/unit/subpackages-exclude-packages-test/target/site/apidocs").toPath();

// check if the classes in the specified subpackages were included
assertThat(apidocs.resolve("org/apache/project/IncludeClass.html")).exists();

// check the excluded packages
assertThat(apidocs.resolve("org/apache/internal")).doesNotExist();
assertThat(apidocs.resolve("io")).doesNotExist();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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.
*/
package org.apache.maven.plugins.javadoc.stubs;

import org.apache.maven.model.Build;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/** */
public class SubpackagesExcludePackagesTestMavenProjectStub extends MavenProjectStub {
public SubpackagesExcludePackagesTestMavenProjectStub() {
readModel(new File(getBasedir(), "pom.xml"));

setGroupId(getModel().getGroupId());
setArtifactId(getModel().getArtifactId());
setVersion(getModel().getVersion());

setName(getModel().getName());
setUrl(getModel().getUrl());
setPackaging(getModel().getPackaging());

Build build = new Build();
build.setFinalName(getName());
build.setDirectory(super.getBasedir() + "/target/test/unit/subpackages-exclude-packages-test/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/subpackages-exclude-packages-test");
}
}
59 changes: 59 additions & 0 deletions src/test/resources/unit/subpackages-exclude-packages-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!--
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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.plugins.maven-javadoc-plugin.unit</groupId>
<artifactId>subpackages-exclude-packages-test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>

<configuration>
<project implementation="org.apache.maven.plugins.javadoc.stubs.SubpackagesExcludePackagesTestMavenProjectStub"/>

<outputDirectory>${basedir}/target/test/unit/subpackages-exclude-packages-test/target/site/apidocs</outputDirectory>
<javadocOptionsDir>${basedir}/target/test/unit/subpackages-exclude-packages-test/target/javadoc-bundle-options</javadocOptionsDir>

<!-- Comment the next line, and javadoc will skip all subpackages under "internal" package -->
<subpackages>org.apache</subpackages>

<excludePackageNames>
org.apache.internal
:org.apache.internal.*
</excludePackageNames>

<debug>true</debug>

<reactorProjects>
<project implementation="org.apache.maven.plugins.javadoc.stubs.SubpackagesExcludePackagesTestMavenProjectStub"/>
</reactorProjects>

</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io;

/*
* 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.
*/

/**
* Class to be excluded.
*/
public class ExcludeIoClass
{
/**
* Sample method that prints out the parameter string.
*
* @param str The string value to be printed.
*/
public void sampleMethod( String str )
{
System.out.println( str );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.apache.internal;

/*
* 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.io.IOException;

/**
* Class to be excluded.
*/
public class ExcludeInternalClass
{
/**
* Sample method that prints out the parameter string.
*
* @param str The string value to be printed.
*/
public void sampleMethod( String str )
{
System.out.println( str );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.apache.internal.subpackage;

/*
* 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.
*/

/**
* Class to be excluded.
*/
public class ExcludeInternalSubClass
{
/**
* Sample method that prints out the parameter string.
*
* @param str The string value to be printed.
*/
public void sampleMethod( String str )
{
System.out.println( str );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.apache.internal.subpackage.subsubpackage;

/*
* 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.
*/

/**
* Class to be excluded.
*/
public class ExcludeInternalSubSubClass
{
/**
* Sample method that prints out the parameter string.
*
* @param str The string value to be printed.
*/
public void sampleMethod( String str )
{
System.out.println( str );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.apache.project;

/*
* 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.
*/

/**
* Class to be included.
*/
public class IncludeClass
{
/**
* Sample method that prints out the parameter string.
*
* @param str The string value to be printed.
*/
public void sampleMethod( String str )
{
System.out.println( str );
}
}

0 comments on commit 8edeca7

Please sign in to comment.