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 e2f1baf commit b2e0a51
Show file tree
Hide file tree
Showing 18 changed files with 945 additions and 0 deletions.
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>
22 changes: 22 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,22 @@
<!--
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="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.2-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
@@ -0,0 +1,159 @@
/**
* 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.tez.tools.javadoc.util;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

import org.apache.tez.dag.api.TezException;
import org.apache.tez.tools.javadoc.model.Config;
import org.apache.tez.tools.javadoc.model.ConfigProperty;

public class HtmlWriter extends Writer {

private static final String DEFAULT_STYLESHEET = "default-stylesheet.css";

public void write(Config config) throws IOException {
PrintWriter out = null;

if (config.configName == null || config.configName.isEmpty()) {
throw new RuntimeException("Config Name is null or empty");
}

try {
File file = new File(config.configName + ".html");
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));

out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"no\" ?>");
out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"");
out.println(" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");

out.println("<html xmlns=\"http://www.w3.org/1999/xhtml\">");

out.println("<head>");
out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />");
out.println("<title>" + config.configName + "</title>");
// out.println("<link rel='stylesheet' type='text/css' href=' " + config.getStyleSheet() + "'/>");
out.println("</head>");

out.println("<style>");
out.println("table");
out.println("{");
out.println(" background-color: #000;");
out.println(" border-spacing: 1px;");
out.println(" margin: 0 auto 0 auto;");
out.println("}");
out.println("th");
out.println("{");
out.println(" background-color: #fff;");
out.println(" padding: 5px;");
out.println(" margin: 1px;");
out.println("}");
out.println("td");
out.println("{");
out.println(" background-color: #fff;");
out.println(" padding: 2px;");
out.println("}");
out.println("table, th, td {");
out.println(" border: 1px solid black;");
out.println("}");
out.println("tr.tr_private td");
out.println("{");
out.println(" background-color: #FF4500;");
out.println(" padding: 2px;");
out.println("}");
out.println("tr.tr_evolve_unstable td");
out.println("{");
out.println(" background-color: #FFFFE0;");
out.println(" padding: 2px;");
out.println("}");
out.println("th.th_private");
out.println("{");
out.println(" background-color: #FF4500;");
out.println("}");
out.println("th.th_evolve_unstable");
out.println("{");
out.println(" background-color: #FFFFE0;");
out.println("}");

out.println("</style>");

out.println("<body>");

out.println("<div id=\"wrapper\">");
out.println("<div id=\"container\">");

out.println("<h1>" + config.configName + "</h1>");
out.println("<hr />");

out.println("<table>");
out.println("<tr>");
out.println("<th>" + "Property Name" + "</th>");
out.println("<th>" + "Default Value" + "</th>");
out.println("<th>" + "Description" + "</th>");
out.println("<th>" + "Type" + "</th>");
// out.println("<th>" + "Valid Values" + "</th>");
out.println("<th class=\"th_private\">" + "Is Private?" + "</th>");
out.println("<th class=\"th_evolve_unstable\">" + "Is Unstable?" + "</th>");
out.println("<th class=\"th_evolve_unstable\">" + "Is Evolving?" + "</th>");
out.println("</tr>");

for (ConfigProperty configProperty : config.configProperties.values()) {
if (!isValidConfigProperty(configProperty)) {
continue;
}

String altClass = "";
if (configProperty.isPrivate) {
altClass = "class=\"tr_private\"";
} else if (configProperty.isEvolving || configProperty.isUnstable) {
altClass = "class=\"tr_evolve_unstable\"";
}

out.println("<tr " + altClass + ">");
out.println("<td>" + configProperty.propertyName + "</td>");
out.println("<td>" + configProperty.defaultValue + "</td>");
out.println("<td>" + configProperty.description + "</td>");
out.println("<td>" + configProperty.type + "</td>");
// Re-enable after adding values
// out.println("<td>" + configProperty.validValues + "</td>");

out.println("<td class=\"" + (configProperty.isPrivate ? "td_private_true" : "td_private_false") + "\">" + configProperty.isPrivate + "</td>");
out.println("<td class=\"" + (configProperty.isEvolving ? "td_evolve_true" : "td_evolve_false") + "\">" + configProperty.isEvolving + "</td>");
out.println("<td class=\"" + (configProperty.isUnstable ? "td_unstable_true" : "td_unstable_false") + "\">" + configProperty.isUnstable + "</td>");
out.println("</tr>");
}

out.println("</table>");

out.println("</div>");
out.println("</div>");
out.println("</body>");
out.println("</html>");
} finally {
if (out != null) {
out.close();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* 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.tez.tools.javadoc.util;

import java.io.IOException;

import org.apache.tez.tools.javadoc.model.Config;
import org.apache.tez.tools.javadoc.model.ConfigProperty;

public abstract class Writer {

public abstract void write(Config config) throws IOException;

public boolean isValidConfigProperty(ConfigProperty configProperty) {
if (!configProperty.isValidConfigProp) {
return false;
}
if (configProperty.propertyName == null || configProperty.propertyName.isEmpty()) {
return false;
}
return true;
}
}
Loading

0 comments on commit b2e0a51

Please sign in to comment.