Skip to content

Commit

Permalink
TEZ-4387: use new doclet API in Java 17+
Browse files Browse the repository at this point in the history
  • Loading branch information
LA-Toth authored and abstractdog committed Dec 23, 2024
1 parent fd6f152 commit 7fb0997
Show file tree
Hide file tree
Showing 25 changed files with 1,366 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
build:
strategy:
matrix:
java-version: [8, 11]
java-version: [8, 11, 17]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
19 changes: 19 additions & 0 deletions tez-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@
<module>tez-tfile-parser</module>
</modules>
</profile>
<profile>
<id>jdk8-16</id>
<activation>
<jdk>[8,16]</jdk>
</activation>
<modules>
<module>tez-javadoc-tools-base-jdk8</module>
</modules>
</profile>
<profile>
<id>jdk17plus</id>
<activation>
<!-- JDK9 starts strong encapsulation of Java internals, JDK17 removes/hides those -->
<jdk>[17,)</jdk>
</activation>
<modules>
<module>tez-javadoc-tools-base</module>
</modules>
</profile>
</profiles>

</project>
28 changes: 28 additions & 0 deletions tez-tools/tez-javadoc-tools-base-jdk8/findbugs-exclude.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--
Licensed 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. See accompanying LICENSE file.
-->
<FindBugsFilter>

<Match>
<Class name="org.apache.tez.tools.javadoc.model.ConfigProperty"/>
<Field name="description"/>
<Bug pattern="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/>
</Match>

<Match>
<Class name="org.apache.tez.tools.javadoc.model.ConfigProperty"/>
<Field name="validValues"/>
<Bug pattern="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/>
</Match>

</FindBugsFilter>
106 changes: 106 additions & 0 deletions tez-tools/tez-javadoc-tools-base-jdk8/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed 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. See accompanying LICENSE file.
-->

<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>
<parent>
<groupId>org.apache.tez</groupId>
<artifactId>tez-tools</artifactId>
<version>0.10.5-SNAPSHOT</version>
</parent>
<artifactId>tez-javadoc-tools-base-jdk8</artifactId>

<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tez</groupId>
<artifactId>tez-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-annotations</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
</dependencies>

<profiles>
<profile>
<id>platform-macosx</id>
<activation>
<file>
<exists>${java.home}/../Classes/classes.jar</exists>
</file>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>${java.version}</version>
<scope>system</scope>
<systemPath>${java.home}/../Classes/classes.jar</systemPath>
</dependency>
</dependencies>
</profile>
<profile>
<id>other-os</id>
<activation>
<file>
<exists>${java.home}/../lib/tools.jar</exists>
</file>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>${java.version}</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
</profiles>


<build>
<plugins>
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<excludePackageNames>org.apache.tez.tools.javadoc.doclet</excludePackageNames>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
Expand All @@ -21,6 +21,15 @@
import java.io.IOException;
import java.util.Map;

import com.sun.javadoc.AnnotationDesc;
import com.sun.javadoc.AnnotationDesc.ElementValuePair;
import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.DocErrorReporter;
import com.sun.javadoc.FieldDoc;
import com.sun.javadoc.LanguageVersion;
import com.sun.javadoc.RootDoc;
import com.sun.tools.doclets.standard.Standard;

import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Evolving;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
Expand All @@ -31,21 +40,13 @@
import org.apache.tez.tools.javadoc.util.HtmlWriter;
import org.apache.tez.tools.javadoc.util.XmlWriter;

import com.sun.javadoc.AnnotationDesc;
import com.sun.javadoc.AnnotationDesc.ElementValuePair;
import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.DocErrorReporter;
import com.sun.javadoc.FieldDoc;
import com.sun.javadoc.LanguageVersion;
import com.sun.javadoc.RootDoc;
import com.sun.tools.doclets.standard.Standard;

public final class ConfigStandardDoclet {

private static final String DEBUG_SWITCH = "-debug";
private static boolean debugMode = false;

private ConfigStandardDoclet() {}
private ConfigStandardDoclet() {
}

public static LanguageVersion languageVersion() {
return LanguageVersion.JAVA_1_5;
Expand Down Expand Up @@ -144,16 +145,16 @@ private static void processDoc(ClassDoc doc) {
+ ", name=" + name
+ ", field=" + field.name()
+ ", val=" + field.constantValueExpression());
configProperty.defaultValue = field.constantValueExpression();
configProperty.setDefaultValue(field.constantValueExpression());
} else {
configProperty.defaultValue = field.constantValue().toString();
configProperty.setDefaultValue(field.constantValue().toString());
}
configProperty.inferredType = field.type().simpleTypeName();
configProperty.setInferredType(field.type().simpleTypeName());

if (name.equals("TEZ_AM_STAGING_DIR") && configProperty.defaultValue != null) {
String defaultValue = configProperty.defaultValue;
if (name.equals("TEZ_AM_STAGING_DIR") && configProperty.getDefaultValue() != null) {
String defaultValue = configProperty.getDefaultValue();
defaultValue = defaultValue.replace(System.getProperty("user.name"), "${user.name}");
configProperty.defaultValue = defaultValue;
configProperty.setDefaultValue(defaultValue);
}

continue;
Expand All @@ -164,61 +165,57 @@ private static void processDoc(ClassDoc doc) {
configProperties.put(name, new ConfigProperty());
}
ConfigProperty configProperty = configProperties.get(name);
configProperty.propertyName = field.constantValue().toString();
configProperty.setPropertyName(field.constantValue().toString());

AnnotationDesc[] annotationDescs = field.annotations();

for (AnnotationDesc annotationDesc : annotationDescs) {

if (annotationDesc.annotationType().qualifiedTypeName().equals(
Private.class.getCanonicalName())) {
configProperty.isPrivate = true;
configProperty.setPrivate(true);
}
if (annotationDesc.annotationType().qualifiedTypeName().equals(
Unstable.class.getCanonicalName())) {
configProperty.isUnstable = true;
configProperty.setUnstable(true);
}
if (annotationDesc.annotationType().qualifiedTypeName().equals(
Evolving.class.getCanonicalName())) {
configProperty.isEvolving = true;
configProperty.setEvolving(true);
}
if (annotationDesc.annotationType().qualifiedTypeName().equals(
ConfigurationProperty.class.getCanonicalName())) {
configProperty.isValidConfigProp = true;
configProperty.setValidConfigProp(true);

for (ElementValuePair element : annotationDesc.elementValues()) {
if (element.element().name().equals("type")) {
configProperty.type = stripQuotes(element.value().toString());
configProperty.setType(stripQuotes(element.value().toString()));
} else {
logMessage("Unhandled annotation property: " + element.element().name());
}
}
}
}

configProperty.description = field.commentText();

}

HtmlWriter writer = new HtmlWriter();
try {
writer.write(config);
} catch (IOException e) {
throw new RuntimeException(e);
}
HtmlWriter writer = new HtmlWriter();
try {
writer.write(config);
} catch (IOException e) {
throw new RuntimeException(e);
}

XmlWriter xmlWriter = new XmlWriter();
try {
xmlWriter.write(config);
} catch (IOException e) {
throw new RuntimeException(e);
XmlWriter xmlWriter = new XmlWriter();
try {
xmlWriter.write(config);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

}

private static String stripQuotes(String s) {
if (s.charAt(0) == '"' && s.charAt(s.length()-1) == '"') {
return s.substring(1, s.length()-1);
if (s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"') {
return s.substring(1, s.length() - 1);
}
return s;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* 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.
*/

@Private
package org.apache.tez.tools.javadoc.doclet;

import org.apache.hadoop.classification.InterfaceAudience.Private;
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* 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
*
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
Expand Down Expand Up @@ -36,5 +36,4 @@ public Config(String configName, String templateName) {
public Config() {
this(null, null);
}

}
Loading

0 comments on commit 7fb0997

Please sign in to comment.