diff --git a/tez-tools/pom.xml b/tez-tools/pom.xml index bffe9abc5d..78d0c1f2b3 100644 --- a/tez-tools/pom.xml +++ b/tez-tools/pom.xml @@ -50,6 +50,25 @@ tez-tfile-parser + + jdk8-16 + + [8,16] + + + tez-javadoc-tools-base-jdk8 + + + + jdk17plus + + + [17,) + + + tez-javadoc-tools-base + + diff --git a/tez-tools/tez-javadoc-tools-base-jdk8/findbugs-exclude.xml b/tez-tools/tez-javadoc-tools-base-jdk8/findbugs-exclude.xml new file mode 100644 index 0000000000..ad8f6e4ce4 --- /dev/null +++ b/tez-tools/tez-javadoc-tools-base-jdk8/findbugs-exclude.xml @@ -0,0 +1,22 @@ + + + + + + + + + + diff --git a/tez-tools/tez-javadoc-tools-base-jdk8/pom.xml b/tez-tools/tez-javadoc-tools-base-jdk8/pom.xml new file mode 100644 index 0000000000..31c84c0d92 --- /dev/null +++ b/tez-tools/tez-javadoc-tools-base-jdk8/pom.xml @@ -0,0 +1,106 @@ + + + + + 4.0.0 + + org.apache.tez + tez-tools + 0.10.2-SNAPSHOT + + tez-javadoc-tools-base-jdk8 + + + + org.slf4j + slf4j-api + + + org.apache.tez + tez-api + + + org.apache.hadoop + hadoop-annotations + + + commons-lang + commons-lang + + + + + + platform-macosx + + + ${java.home}/../Classes/classes.jar + + + + + com.sun + tools + ${java.version} + system + ${java.home}/../Classes/classes.jar + + + + + other-os + + + ${java.home}/../lib/tools.jar + + + + + com.sun + tools + ${java.version} + system + ${java.home}/../lib/tools.jar + + + + + + + + + + org.apache.rat + apache-rat-plugin + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + maven-javadoc-plugin + + org.apache.tez.tools.javadoc.doclet + + + + + + diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java b/tez-tools/tez-javadoc-tools-base-jdk8/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java similarity index 100% rename from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java rename to tez-tools/tez-javadoc-tools-base-jdk8/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java b/tez-tools/tez-javadoc-tools-base-jdk8/src/main/java/org/apache/tez/tools/javadoc/model/Config.java similarity index 100% rename from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java rename to tez-tools/tez-javadoc-tools-base-jdk8/src/main/java/org/apache/tez/tools/javadoc/model/Config.java diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java b/tez-tools/tez-javadoc-tools-base-jdk8/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java similarity index 100% rename from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java rename to tez-tools/tez-javadoc-tools-base-jdk8/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java b/tez-tools/tez-javadoc-tools-base-jdk8/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java similarity index 100% rename from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java rename to tez-tools/tez-javadoc-tools-base-jdk8/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java b/tez-tools/tez-javadoc-tools-base-jdk8/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java similarity index 100% rename from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java rename to tez-tools/tez-javadoc-tools-base-jdk8/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java b/tez-tools/tez-javadoc-tools-base-jdk8/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java similarity index 100% rename from tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java rename to tez-tools/tez-javadoc-tools-base-jdk8/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java diff --git a/tez-tools/tez-javadoc-tools-base/findbugs-exclude.xml b/tez-tools/tez-javadoc-tools-base/findbugs-exclude.xml new file mode 100644 index 0000000000..ad8f6e4ce4 --- /dev/null +++ b/tez-tools/tez-javadoc-tools-base/findbugs-exclude.xml @@ -0,0 +1,22 @@ + + + + + + + + + + diff --git a/tez-tools/tez-javadoc-tools-base/pom.xml b/tez-tools/tez-javadoc-tools-base/pom.xml new file mode 100644 index 0000000000..ca5680d000 --- /dev/null +++ b/tez-tools/tez-javadoc-tools-base/pom.xml @@ -0,0 +1,78 @@ + + + + + 4.0.0 + + org.apache.tez + tez-tools + 0.10.2-SNAPSHOT + + tez-javadoc-tools-base + + + + org.slf4j + slf4j-api + + + org.apache.tez + tez-api + + + org.apache.hadoop + hadoop-annotations + + + commons-lang + commons-lang + + + + + + + + + org.apache.rat + apache-rat-plugin + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + maven-javadoc-plugin + + org.apache.tez.tools.javadoc.doclet + + + + org.apache.maven.plugins + maven-compiler-plugin + + 9 + 9 + + + + + + diff --git a/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java b/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java new file mode 100644 index 0000000000..b418163129 --- /dev/null +++ b/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java @@ -0,0 +1,284 @@ +/** + * 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.doclet; + +import com.sun.source.util.DocTrees; +import jdk.javadoc.doclet.Doclet; +import jdk.javadoc.doclet.DocletEnvironment; +import jdk.javadoc.doclet.Reporter; +import org.apache.hadoop.classification.InterfaceAudience.Private; +import org.apache.hadoop.classification.InterfaceStability.Evolving; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.tez.common.annotation.ConfigurationClass; +import org.apache.tez.common.annotation.ConfigurationProperty; +import org.apache.tez.tools.javadoc.model.Config; +import org.apache.tez.tools.javadoc.model.ConfigProperty; +import org.apache.tez.tools.javadoc.util.HtmlWriter; +import org.apache.tez.tools.javadoc.util.XmlWriter; + +import javax.lang.model.SourceVersion; +import javax.lang.model.element.*; +import javax.tools.Diagnostic; +import java.io.IOException; +import java.util.*; + +public class ConfigStandardDoclet implements Doclet { + + private static boolean debugMode = false; + + Reporter reporter; + + @Override + public void init(Locale locale, Reporter reporter) { + this.reporter = reporter; + } + + @Override + public String getName() { + return "Tez"; + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.RELEASE_9; + } + + private void logMessage(String message) { + if (!debugMode) { + return; + } + reporter.print(Diagnostic.Kind.NOTE, message); + } + + @Override + public boolean run(DocletEnvironment docEnv) { + logMessage("Running doclet " + ConfigStandardDoclet.class.getSimpleName()); + DocTrees docTrees = docEnv.getDocTrees(); + for (Element element : docEnv.getIncludedElements()) { + if (element.getKind().equals(ElementKind.CLASS) && element instanceof TypeElement) { + processDoc(docTrees, (TypeElement) element); + } + } + + return true; + } + + private void processDoc(DocTrees docTrees, TypeElement doc) { + logMessage("Parsing : " + doc); + if (!doc.getKind().equals(ElementKind.CLASS)) { + logMessage("Ignoring non-class: " + doc); + return; + } + + List annotations = doc.getAnnotationMirrors(); + boolean isConfigClass = false; + String templateName = null; + for (AnnotationMirror annotation : annotations) { + logMessage("Checking annotation: " + annotation.getAnnotationType()); + if (annotation.getAnnotationType().asElement().toString().equals( + ConfigurationClass.class.getName())) { + isConfigClass = true; + Map elementValues = annotation.getElementValues(); + for (Map.Entry element : elementValues.entrySet()) { + if (element.getKey().getSimpleName().toString().equals("templateFileName")) { + templateName = stripQuotes(element.getValue().getValue().toString()); + } + } + break; + } + } + + if (!isConfigClass) { + logMessage("Ignoring non-config class: " + doc); + return; + } + + logMessage("Processing config class: " + doc); + Config config = new Config(doc.getSimpleName().toString(), templateName); + Map configProperties = config.configProperties; + + processElements(docTrees, doc, configProperties); + + 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); + } + } + + private void processElements(DocTrees docTrees, TypeElement doc, Map configProperties) { + List elements = doc.getEnclosedElements(); + for (Element f : elements) { + if (!(f instanceof VariableElement)) { + continue; + } + + if (!f.getKind().equals(ElementKind.FIELD)) { + continue; + } + + VariableElement field = (VariableElement) f; + + if (field.getModifiers().contains(Modifier.PRIVATE)) { + logMessage("Skipping private field: " + field); + continue; + } + if (field.getModifiers().contains(Modifier.STATIC)) { + logMessage("Skipping non-static field: " + field); + continue; + } + + String fieldName = field.getSimpleName().toString(); + if (fieldName.endsWith("_PREFIX")) { + logMessage("Skipping non-config prefix constant field: " + field); + continue; + } + if (fieldName.equals("TEZ_SITE_XML")) { + logMessage("Skipping constant field: " + field); + continue; + } + + if (fieldName.endsWith("_DEFAULT")) { + + String name = fieldName.substring(0, + fieldName.lastIndexOf("_DEFAULT")); + if (!configProperties.containsKey(name)) { + configProperties.put(name, new ConfigProperty()); + } + ConfigProperty configProperty = configProperties.get(name); + if (field.getConstantValue() == null) { + String val = field.getConstantValue().toString(); + logMessage("Got null constant value" + + ", name=" + name + + ", field=" + fieldName + + ", val=" + val); + configProperty.defaultValue = val; + } else { + configProperty.defaultValue = field.getConstantValue().toString(); + } + configProperty.inferredType = field.getSimpleName().toString(); + + if (name.equals("TEZ_AM_STAGING_DIR") && configProperty.defaultValue != null) { + String defaultValue = configProperty.defaultValue; + defaultValue = defaultValue.replace(System.getProperty("user.name"), "${user.name}"); + configProperty.defaultValue = defaultValue; + } + + continue; + } + + if (!configProperties.containsKey(fieldName)) { + configProperties.put(fieldName, new ConfigProperty()); + } + ConfigProperty configProperty = configProperties.get(fieldName); + configProperty.propertyName = field.getConstantValue().toString(); + + List annotationDescs = field.getAnnotationMirrors(); + + for (AnnotationMirror annotationDesc : annotationDescs) { + String elementFqName = annotationDesc.getAnnotationType().asElement().toString(); + if (elementFqName.equals( + Private.class.getCanonicalName())) { + configProperty.isPrivate = true; + } + if (elementFqName.equals( + Unstable.class.getCanonicalName())) { + configProperty.isUnstable = true; + } + if (elementFqName.equals( + Evolving.class.getCanonicalName())) { + configProperty.isEvolving = true; + } + if (elementFqName.equals( + ConfigurationProperty.class.getCanonicalName())) { + configProperty.isValidConfigProp = true; + + for (Map.Entry element : annotationDesc.getElementValues().entrySet()) { + if (element.getKey().getSimpleName().toString().equals("type")) { + configProperty.type = stripQuotes(element.getValue().getValue().toString()); + } else { + logMessage("Unhandled annotation property: " + element.getKey().getSimpleName()); + } + } + } + } + + configProperty.description = docTrees.getDocCommentTree(field).getFullBody().toString(); + } + } + + private static String stripQuotes(String s) { + if (s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"') { + return s.substring(1, s.length() - 1); + } + return s; + } + + @Override + public Set getSupportedOptions() { + Option[] options = { + new Option() { + private final List someOption = Arrays.asList( + "-debug", + "--debug" + ); + + @Override + public int getArgumentCount() { + return 0; + } + + @Override + public String getDescription() { + return "Debug mode"; + } + + @Override + public Option.Kind getKind() { + return Kind.STANDARD; + } + + @Override + public List getNames() { + return someOption; + } + + @Override + public String getParameters() { + return ""; + } + + @Override + public boolean process(String opt, List arguments) { + debugMode = true; + return true; + } + } + }; + return new HashSet<>(Arrays.asList(options)); + } +} diff --git a/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/model/Config.java b/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/model/Config.java new file mode 100644 index 0000000000..604d48ac5e --- /dev/null +++ b/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/model/Config.java @@ -0,0 +1,40 @@ +/** + * 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.model; + +import java.util.Map; +import java.util.TreeMap; + +public class Config { + + public final String templateName; + public final String configName; + public Map configProperties; + + public Config(String configName, String templateName) { + this.configName = configName; + this.templateName = templateName; + this.configProperties = new TreeMap(); + } + + public Config() { + this(null, null); + } + +} diff --git a/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java b/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java new file mode 100644 index 0000000000..89490c4a51 --- /dev/null +++ b/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java @@ -0,0 +1,47 @@ +/** + * 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.model; + +public class ConfigProperty { + + public String propertyName; + public String defaultValue; + public String description; + public String type = "string"; + public boolean isPrivate = false; + public boolean isUnstable = false; + public boolean isEvolving = false; + public boolean isValidConfigProp = false; + public String[] validValues; + public String inferredType; + + @Override + public String toString() { + return "name=" + propertyName + + ", defaultValue=" + defaultValue + + ", description=" + description + + ", type=" + type + + ", inferredType=" + inferredType + + ", private=" + isPrivate + + ", validValues=" + (validValues == null ? "null" : validValues) + + ", isConfigProp=" + isValidConfigProp; + } +} + + diff --git a/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java b/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java new file mode 100644 index 0000000000..4b531e87e5 --- /dev/null +++ b/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java @@ -0,0 +1,161 @@ +/** + * 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(""); + out.println(""); + + out.println(""); + + out.println(""); + out.println(""); + out.println(""+ config.configName +""); +// out.println(""); + out.println(""); + + out.println(""); + + out.println(""); + + out.println("
"); + out.println("
"); + + out.println("

"+ config.configName +"

"); + out.println("
"); + + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + // out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + + 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(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + // Re-enable after adding values + // out.println(""); + + out.println(""); + out.println(""); + out.println(""); + out.println(""); + } + + out.println("
" + "Property Name" + "" + "Default Value" + "" + "Description" + "" + "Type" + "" + "Valid Values" + "" + "Is Private?" + "" + "Is Unstable?" + "" + "Is Evolving?" + "
" + configProperty.propertyName + "" + configProperty.defaultValue + "" + configProperty.description + "" + configProperty.type + "" + configProperty.validValues + "" + configProperty.isPrivate + "" + configProperty.isEvolving + "" + configProperty.isUnstable + "
"); + + out.println("
"); + out.println("
"); + out.println(""); + out.println(""); + + } finally { + if (out != null) { + out.close(); + } + } + } + +} diff --git a/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java b/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java new file mode 100644 index 0000000000..cfb0c92738 --- /dev/null +++ b/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java @@ -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; + } +} diff --git a/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java b/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java new file mode 100644 index 0000000000..1c4b735451 --- /dev/null +++ b/tez-tools/tez-javadoc-tools-base/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java @@ -0,0 +1,99 @@ +/** + * 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.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; + +import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.tez.tools.javadoc.model.Config; +import org.apache.tez.tools.javadoc.model.ConfigProperty; + +public class XmlWriter extends Writer { + + 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"); + } + + String fileName = config.templateName == null || + config.templateName.isEmpty() ? config.configName : config.templateName; + if (!fileName.endsWith(".xml")) { + fileName += ".xml"; + } + + try { + File file = new File(fileName); + out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); + + out.println(""); + out.println(""); + out.println(); + out.println(""); + out.println(); + out.println(""); + + for (ConfigProperty configProperty : config.configProperties.values()) { + if (!isValidConfigProperty(configProperty)) { + continue; + } + out.println(); + out.println(" "); + out.println(" " + configProperty.propertyName + ""); + if (configProperty.defaultValue != null && !configProperty.defaultValue.isEmpty()) { + out.println(" " + configProperty.defaultValue + ""); + } + if (configProperty.description != null && !configProperty.description.isEmpty()) { + out.println(" " + StringEscapeUtils.escapeXml(configProperty.description) + + ""); + } + if (configProperty.type != null && !configProperty.type.isEmpty()) { + out.println(" " + configProperty.type + ""); + } + if (configProperty.isUnstable) { + out.println(" true"); + } + if (configProperty.isEvolving) { + out.println(" true"); + } + if (configProperty.isPrivate) { + out.println(" true"); + } + out.println(" "); + } + + out.println(); + out.println(""); + + } finally { + if (out != null) { + out.close(); + } + } + } + + +} diff --git a/tez-tools/tez-javadoc-tools/pom.xml b/tez-tools/tez-javadoc-tools/pom.xml index 6b0546674b..cb416129cf 100644 --- a/tez-tools/tez-javadoc-tools/pom.xml +++ b/tez-tools/tez-javadoc-tools/pom.xml @@ -78,6 +78,33 @@ + + jdk8-16 + + [8,16] + + + + org.apache.tez + tez-javadoc-tools-base-jdk8 + ${project.version} + + + + + jdk17plus + + + [17,) + + + + org.apache.tez + tez-javadoc-tools-base + ${project.version} + + +