Skip to content

Commit 46ac3dc

Browse files
LA-Tothabstractdog
authored andcommitted
TEZ-4387: use new doclet API in Java 17+
1 parent e2f1baf commit 46ac3dc

18 files changed

Lines changed: 945 additions & 0 deletions

File tree

tez-tools/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,25 @@
5050
<module>tez-tfile-parser</module>
5151
</modules>
5252
</profile>
53+
<profile>
54+
<id>jdk8-16</id>
55+
<activation>
56+
<jdk>[8,16]</jdk>
57+
</activation>
58+
<modules>
59+
<module>tez-javadoc-tools-base-jdk8</module>
60+
</modules>
61+
</profile>
62+
<profile>
63+
<id>jdk17plus</id>
64+
<activation>
65+
<!-- JDK9 starts strong encapsulation of Java internals, JDK17 removes/hides those -->
66+
<jdk>[17,)</jdk>
67+
</activation>
68+
<modules>
69+
<module>tez-javadoc-tools-base</module>
70+
</modules>
71+
</profile>
5372
</profiles>
5473

5574
</project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!--
2+
Licensed under the Apache License, Version 2.0 (the "License");
3+
you may not use this file except in compliance with the License.
4+
You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License. See accompanying LICENSE file.
13+
-->
14+
<FindBugsFilter>
15+
16+
<Match>
17+
<Class name="org.apache.tez.tools.javadoc.model.ConfigProperty"/>
18+
<Field name="validValues"/>
19+
<Bug pattern="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/>
20+
</Match>
21+
22+
</FindBugsFilter>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License. See accompanying LICENSE file.
14+
-->
15+
16+
<project xmlns="http://maven.apache.org/POM/4.0.0"
17+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19+
<modelVersion>4.0.0</modelVersion>
20+
<parent>
21+
<groupId>org.apache.tez</groupId>
22+
<artifactId>tez-tools</artifactId>
23+
<version>0.10.5-SNAPSHOT</version>
24+
</parent>
25+
<artifactId>tez-javadoc-tools-base-jdk8</artifactId>
26+
27+
<dependencies>
28+
<dependency>
29+
<groupId>org.slf4j</groupId>
30+
<artifactId>slf4j-api</artifactId>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.apache.tez</groupId>
34+
<artifactId>tez-api</artifactId>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.apache.hadoop</groupId>
38+
<artifactId>hadoop-annotations</artifactId>
39+
</dependency>
40+
<dependency>
41+
<groupId>commons-lang</groupId>
42+
<artifactId>commons-lang</artifactId>
43+
</dependency>
44+
</dependencies>
45+
46+
<profiles>
47+
<profile>
48+
<id>platform-macosx</id>
49+
<activation>
50+
<file>
51+
<exists>${java.home}/../Classes/classes.jar</exists>
52+
</file>
53+
</activation>
54+
<dependencies>
55+
<dependency>
56+
<groupId>com.sun</groupId>
57+
<artifactId>tools</artifactId>
58+
<version>${java.version}</version>
59+
<scope>system</scope>
60+
<systemPath>${java.home}/../Classes/classes.jar</systemPath>
61+
</dependency>
62+
</dependencies>
63+
</profile>
64+
<profile>
65+
<id>other-os</id>
66+
<activation>
67+
<file>
68+
<exists>${java.home}/../lib/tools.jar</exists>
69+
</file>
70+
</activation>
71+
<dependencies>
72+
<dependency>
73+
<groupId>com.sun</groupId>
74+
<artifactId>tools</artifactId>
75+
<version>${java.version}</version>
76+
<scope>system</scope>
77+
<systemPath>${java.home}/../lib/tools.jar</systemPath>
78+
</dependency>
79+
</dependencies>
80+
</profile>
81+
</profiles>
82+
83+
84+
<build>
85+
<plugins>
86+
<plugin>
87+
<groupId>org.apache.rat</groupId>
88+
<artifactId>apache-rat-plugin</artifactId>
89+
</plugin>
90+
<plugin>
91+
<groupId>org.apache.maven.plugins</groupId>
92+
<artifactId>maven-deploy-plugin</artifactId>
93+
<configuration>
94+
<skip>true</skip>
95+
</configuration>
96+
</plugin>
97+
<plugin>
98+
<artifactId>maven-javadoc-plugin</artifactId>
99+
<configuration>
100+
<excludePackageNames>org.apache.tez.tools.javadoc.doclet</excludePackageNames>
101+
</configuration>
102+
</plugin>
103+
</plugins>
104+
</build>
105+
106+
</project>

tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java renamed to tez-tools/tez-javadoc-tools-base-jdk8/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java

File renamed without changes.

tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java renamed to tez-tools/tez-javadoc-tools-base-jdk8/src/main/java/org/apache/tez/tools/javadoc/model/Config.java

File renamed without changes.

tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java renamed to tez-tools/tez-javadoc-tools-base-jdk8/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java

File renamed without changes.
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
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, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.tez.tools.javadoc.util;
20+
21+
import java.io.File;
22+
import java.io.FileNotFoundException;
23+
import java.io.FileOutputStream;
24+
import java.io.IOException;
25+
import java.io.OutputStreamWriter;
26+
import java.io.PrintWriter;
27+
28+
import org.apache.tez.dag.api.TezException;
29+
import org.apache.tez.tools.javadoc.model.Config;
30+
import org.apache.tez.tools.javadoc.model.ConfigProperty;
31+
32+
public class HtmlWriter extends Writer {
33+
34+
private static final String DEFAULT_STYLESHEET = "default-stylesheet.css";
35+
36+
public void write(Config config) throws IOException {
37+
PrintWriter out = null;
38+
39+
if (config.configName == null || config.configName.isEmpty()) {
40+
throw new RuntimeException("Config Name is null or empty");
41+
}
42+
43+
try {
44+
File file = new File(config.configName + ".html");
45+
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
46+
47+
out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"no\" ?>");
48+
out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"");
49+
out.println(" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
50+
51+
out.println("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
52+
53+
out.println("<head>");
54+
out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />");
55+
out.println("<title>" + config.configName + "</title>");
56+
// out.println("<link rel='stylesheet' type='text/css' href=' " + config.getStyleSheet() + "'/>");
57+
out.println("</head>");
58+
59+
out.println("<style>");
60+
out.println("table");
61+
out.println("{");
62+
out.println(" background-color: #000;");
63+
out.println(" border-spacing: 1px;");
64+
out.println(" margin: 0 auto 0 auto;");
65+
out.println("}");
66+
out.println("th");
67+
out.println("{");
68+
out.println(" background-color: #fff;");
69+
out.println(" padding: 5px;");
70+
out.println(" margin: 1px;");
71+
out.println("}");
72+
out.println("td");
73+
out.println("{");
74+
out.println(" background-color: #fff;");
75+
out.println(" padding: 2px;");
76+
out.println("}");
77+
out.println("table, th, td {");
78+
out.println(" border: 1px solid black;");
79+
out.println("}");
80+
out.println("tr.tr_private td");
81+
out.println("{");
82+
out.println(" background-color: #FF4500;");
83+
out.println(" padding: 2px;");
84+
out.println("}");
85+
out.println("tr.tr_evolve_unstable td");
86+
out.println("{");
87+
out.println(" background-color: #FFFFE0;");
88+
out.println(" padding: 2px;");
89+
out.println("}");
90+
out.println("th.th_private");
91+
out.println("{");
92+
out.println(" background-color: #FF4500;");
93+
out.println("}");
94+
out.println("th.th_evolve_unstable");
95+
out.println("{");
96+
out.println(" background-color: #FFFFE0;");
97+
out.println("}");
98+
99+
out.println("</style>");
100+
101+
out.println("<body>");
102+
103+
out.println("<div id=\"wrapper\">");
104+
out.println("<div id=\"container\">");
105+
106+
out.println("<h1>" + config.configName + "</h1>");
107+
out.println("<hr />");
108+
109+
out.println("<table>");
110+
out.println("<tr>");
111+
out.println("<th>" + "Property Name" + "</th>");
112+
out.println("<th>" + "Default Value" + "</th>");
113+
out.println("<th>" + "Description" + "</th>");
114+
out.println("<th>" + "Type" + "</th>");
115+
// out.println("<th>" + "Valid Values" + "</th>");
116+
out.println("<th class=\"th_private\">" + "Is Private?" + "</th>");
117+
out.println("<th class=\"th_evolve_unstable\">" + "Is Unstable?" + "</th>");
118+
out.println("<th class=\"th_evolve_unstable\">" + "Is Evolving?" + "</th>");
119+
out.println("</tr>");
120+
121+
for (ConfigProperty configProperty : config.configProperties.values()) {
122+
if (!isValidConfigProperty(configProperty)) {
123+
continue;
124+
}
125+
126+
String altClass = "";
127+
if (configProperty.isPrivate) {
128+
altClass = "class=\"tr_private\"";
129+
} else if (configProperty.isEvolving || configProperty.isUnstable) {
130+
altClass = "class=\"tr_evolve_unstable\"";
131+
}
132+
133+
out.println("<tr " + altClass + ">");
134+
out.println("<td>" + configProperty.propertyName + "</td>");
135+
out.println("<td>" + configProperty.defaultValue + "</td>");
136+
out.println("<td>" + configProperty.description + "</td>");
137+
out.println("<td>" + configProperty.type + "</td>");
138+
// Re-enable after adding values
139+
// out.println("<td>" + configProperty.validValues + "</td>");
140+
141+
out.println("<td class=\"" + (configProperty.isPrivate ? "td_private_true" : "td_private_false") + "\">" + configProperty.isPrivate + "</td>");
142+
out.println("<td class=\"" + (configProperty.isEvolving ? "td_evolve_true" : "td_evolve_false") + "\">" + configProperty.isEvolving + "</td>");
143+
out.println("<td class=\"" + (configProperty.isUnstable ? "td_unstable_true" : "td_unstable_false") + "\">" + configProperty.isUnstable + "</td>");
144+
out.println("</tr>");
145+
}
146+
147+
out.println("</table>");
148+
149+
out.println("</div>");
150+
out.println("</div>");
151+
out.println("</body>");
152+
out.println("</html>");
153+
} finally {
154+
if (out != null) {
155+
out.close();
156+
}
157+
}
158+
}
159+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.tez.tools.javadoc.util;
20+
21+
import java.io.IOException;
22+
23+
import org.apache.tez.tools.javadoc.model.Config;
24+
import org.apache.tez.tools.javadoc.model.ConfigProperty;
25+
26+
public abstract class Writer {
27+
28+
public abstract void write(Config config) throws IOException;
29+
30+
public boolean isValidConfigProperty(ConfigProperty configProperty) {
31+
if (!configProperty.isValidConfigProp) {
32+
return false;
33+
}
34+
if (configProperty.propertyName == null || configProperty.propertyName.isEmpty()) {
35+
return false;
36+
}
37+
return true;
38+
}
39+
}

0 commit comments

Comments
 (0)