You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2023/03/13 14:05:45 UTC

[cxf] 01/03: Since we only support java11+, we can simplify build and just build the java11+ version

This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 2d955cf656f11a3de72f200f086fe54448f65fdf
Author: Daniel Kulp <da...@kulp.com>
AuthorDate: Mon Mar 13 09:39:44 2023 -0400

    Since we only support java11+, we can simplify build and just build the java11+ version
---
 maven-plugins/java2wadl-plugin/pom.xml             | 108 -----------
 .../cxf/maven_plugin/javatowadl/DumpJavaDoc.java   | 215 +++++++++++++++------
 .../cxf/maven_plugin/javatowadl/DumpJavaDoc.java   | 194 -------------------
 3 files changed, 151 insertions(+), 366 deletions(-)

diff --git a/maven-plugins/java2wadl-plugin/pom.xml b/maven-plugins/java2wadl-plugin/pom.xml
index 67d566ef3e..183d76662a 100644
--- a/maven-plugins/java2wadl-plugin/pom.xml
+++ b/maven-plugins/java2wadl-plugin/pom.xml
@@ -127,56 +127,6 @@
     </dependencies>
 
     <profiles>
-        <profile>
-            <id>pre-java9</id>
-            <dependencies>
-                <dependency>
-                    <groupId>com.sun</groupId>
-                    <artifactId>tools</artifactId>
-                    <version>1.7.0</version>
-                    <scope>system</scope>
-                    <systemPath>${java.home}/../lib/tools.jar</systemPath>
-                </dependency>
-            </dependencies>
-            <activation>
-                <file>
-                    <exists>${java.home}/../lib/tools.jar</exists>
-                </file>
-            </activation>
-        </profile>
-
-        <profile>
-            <id>ibmjdk</id>
-            <activation>
-                <property>
-                    <name>java.vendor</name>
-                    <value>IBM Corporation</value>
-                </property>
-            </activation>
-            <dependencies>
-                <dependency>
-                    <groupId>xerces</groupId>
-                    <artifactId>xercesImpl</artifactId>
-                </dependency>
-            </dependencies>
-        </profile>
-        <profile>
-            <id>mac-jdk16</id>
-            <activation>
-                <file>
-                    <exists>${java.home}/../Classes/classes.jar</exists>
-                </file>
-            </activation>
-            <dependencies>
-                <dependency>
-                    <groupId>com.sun</groupId>
-                    <artifactId>tools</artifactId>
-                    <version>1.6.0</version>
-                    <scope>system</scope>
-                    <systemPath>${java.home}/../Classes/classes.jar</systemPath>
-                </dependency>
-            </dependencies>
-        </profile>
         <profile>
             <id>setup.eclipse</id>
             <build>
@@ -206,63 +156,5 @@
                 </plugins>
             </build>
         </profile>
-        
-        <profile>
-            <id>jdk13</id>
-              <activation>
-                  <jdk>[13,)</jdk>
-              </activation>
-              <build>
-                  <pluginManagement>
-                      <plugins>
-                          <plugin>
-                              <groupId>org.apache.maven.plugins</groupId>
-                              <artifactId>maven-compiler-plugin</artifactId>
-                              <executions>
-                                  <execution>
-                                    <id>default-jdk13-compile</id>
-                                    <goals>
-                                        <goal>compile</goal>
-                                    </goals>
-                                    <configuration>
-                                        <forceJavacCompilerUse>true</forceJavacCompilerUse>
-                                        <compileSourceRoots>
-                                            <compileSourceRoot>${project.basedir}/src/main/java13</compileSourceRoot>
-                                        </compileSourceRoots>
-                                        <outputDirectory>${project.build.outputDirectory}/META-INF/versions/13</outputDirectory>
-                                    </configuration>
-                              </execution>
-                          </executions>
-                          <configuration>
-                              <release>11</release>
-                          </configuration>
-                      </plugin>
-                      <plugin>
-                          <groupId>org.apache.maven.plugins</groupId>
-                          <artifactId>maven-jar-plugin</artifactId>
-                          <executions>
-                              <execution>
-                                  <id>default-jar</id>
-                                  <configuration>
-                                      <archive>
-                                          <manifestEntries>
-                                              <Multi-Release>true</Multi-Release>
-                                          </manifestEntries>
-                                      </archive>
-                                  </configuration>
-                              </execution>
-                          </executions>
-                      </plugin>
-                      <plugin>
-                          <groupId>org.apache.maven.plugins</groupId>
-                          <artifactId>maven-javadoc-plugin</artifactId>
-                          <configuration>
-                              <release>11</release>
-                          </configuration>
-                      </plugin>
-                  </plugins>
-              </pluginManagement>
-          </build>
-        </profile>
     </profiles>
 </project>
diff --git a/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/DumpJavaDoc.java b/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/DumpJavaDoc.java
index d24a2eaca4..692ec27333 100644
--- a/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/DumpJavaDoc.java
+++ b/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/DumpJavaDoc.java
@@ -22,88 +22,175 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
 import java.util.Properties;
+import java.util.Set;
+import java.util.stream.Collectors;
 
-import com.sun.javadoc.ClassDoc;
-import com.sun.javadoc.DocErrorReporter;
-import com.sun.javadoc.MethodDoc;
-import com.sun.javadoc.ParamTag;
-import com.sun.javadoc.Parameter;
-import com.sun.javadoc.RootDoc;
-import com.sun.javadoc.Tag;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.VariableElement;
+import javax.lang.model.util.Elements;
+import javax.tools.Diagnostic;
 
+import com.sun.source.doctree.DocCommentTree;
+import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.ParamTree;
+import com.sun.source.doctree.ReturnTree;
+import com.sun.source.util.DocTrees;
 
-public final class DumpJavaDoc {
 
-    private DumpJavaDoc() {
 
+import jdk.javadoc.doclet.Doclet;
+import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.doclet.Reporter;
+
+public final class DumpJavaDoc implements Doclet {
+    private String dumpFileName;
+    private Reporter reporter;
+    
+    private final class DumpJavaDocFileOption implements Option {
+        @Override
+        public int getArgumentCount() {
+            return 1;
+        }
+
+        @Override
+        public String getDescription() {
+            return "Specify the file to dump Javadoc for later use";
+        }
+
+        @Override
+        public Kind getKind() {
+            return Kind.STANDARD;
+        }
+
+        @Override
+        public List<String> getNames() {
+            return Collections.singletonList("-dumpJavaDocFile");
+        }
+
+        @Override
+        public String getParameters() {
+            return "theFileToDumpJavaDocForLaterUse";
+        }
+
+        @Override
+        public boolean process(String option, List<String> arguments) {
+            dumpFileName = arguments.get(0);
+            return true;
+        }
+    }
+
+    public DumpJavaDoc() {
+
+    }
+
+    @Override
+    public void init(Locale locale, Reporter r) {
+        this.reporter = r;
     }
 
-    public static boolean start(RootDoc root) throws IOException {
-        String dumpFileName = readOptions(root.options());
-        OutputStream os = Files.newOutputStream(Paths.get(dumpFileName));
-        Properties javaDocMap = new Properties();
-        for (ClassDoc classDoc : root.classes()) {
-            javaDocMap.put(classDoc.toString(), classDoc.commentText());
-            for (MethodDoc method : classDoc.methods()) {
-                javaDocMap.put(method.qualifiedName(), method.commentText());
-                for (ParamTag paramTag : method.paramTags()) {
-                    Parameter[] parameters = method.parameters();
-                    for (int i = 0; i < parameters.length; ++i) {
-                        if (parameters[i].name().equals(paramTag.parameterName())) {
-                            javaDocMap.put(method.qualifiedName() + ".paramCommentTag." + i,
-                                   paramTag.parameterComment());
+    @Override
+    public String getName() {
+        return "DumpJavaDoc";
+    }
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.RELEASE_8;
+    }
+
+    @Override
+    public boolean run(DocletEnvironment docEnv) {
+        final Elements utils = docEnv.getElementUtils();
+        final DocTrees docTrees = docEnv.getDocTrees();
+        
+        try (OutputStream os = Files.newOutputStream(Paths.get(dumpFileName))) {
+            final Properties javaDocMap = new Properties();
+            for (Element element : docEnv.getIncludedElements()) {
+                if (element.getKind() == ElementKind.CLASS) {
+                    final TypeElement classDoc = (TypeElement) element;
+                    final DocCommentTree classCommentTree = docTrees.getDocCommentTree(classDoc);
+                    
+                    if (classCommentTree != null) {
+                        javaDocMap.put(classDoc.toString(), getAllComments(classCommentTree.getFullBody()));
+                    }
+                    
+                    for (Element member: classDoc.getEnclosedElements()) {
+                        // Skip all non-public methods
+                        if (!member.getModifiers().contains(Modifier.PUBLIC)) {
+                            continue;
+                        }
+                        
+                        if (member.getKind() == ElementKind.METHOD) {
+                            final ExecutableElement method = (ExecutableElement) member;
+                            final DocCommentTree methodCommentTree = docTrees.getDocCommentTree(method);
+                            final String qualifiedName = utils.getBinaryName(classDoc) + "." + method.getSimpleName();
+                            
+                            if (methodCommentTree == null) {
+                                javaDocMap.put(qualifiedName, "");
+                            } else  {
+                                javaDocMap.put(qualifiedName, getAllComments(methodCommentTree.getFullBody()));
+                                for (DocTree tree: methodCommentTree.getBlockTags()) {
+                                    if (tree.getKind() == DocTree.Kind.RETURN) {
+                                        final ReturnTree returnTree = (ReturnTree) tree;
+                                        javaDocMap.put(qualifiedName + ".returnCommentTag", 
+                                            getAllComments(returnTree.getDescription()));
+                                    } else if (tree.getKind() == DocTree.Kind.PARAM) {
+                                        final ParamTree paramTree = (ParamTree) tree;
+                                        final int index = getParamIndex(method, paramTree);
+                                        // CHECKSTYLE:OFF
+                                        if (index >= 0) {
+                                            javaDocMap.put(qualifiedName + ".paramCommentTag." + index, 
+                                                getAllComments(paramTree.getDescription()));
+                                        }
+                                        // CHECKSTYLE:ON
+                                    }
+                                }
+                            }
                         }
                     }
                 }
-                Tag[] retTags = method.tags("return");
-                if (retTags != null && retTags.length == 1) {
-                    Tag retTag = method.tags("return")[0];
-                    javaDocMap.put(method.qualifiedName() + "." + "returnCommentTag",
-                                   retTag.text());
-                }
             }
-
+            
+            javaDocMap.store(os, "");
+            os.flush();
+        } catch (final IOException ex) {
+            reporter.print(Diagnostic.Kind.ERROR, ex.getMessage());
         }
-        javaDocMap.store(os, "");
-        os.flush();
-        os.close();
+        
         return true;
     }
-
-    private static String readOptions(String[][] options) {
-        String tagName = null;
-        for (int i = 0; i < options.length; i++) {
-            String[] opt = options[i];
-            if ("-dumpJavaDocFile".equals(opt[0])) {
-                tagName = opt[1];
+    
+    private int getParamIndex(final ExecutableElement method, final ParamTree paramTree) {
+        final List<? extends VariableElement> parameters = method.getParameters();
+        
+        for (int i = 0; i < parameters.size(); ++i) {
+            if (paramTree.getName().getName().contentEquals(parameters.get(i).getSimpleName())) {
+                return i;
             }
-        }
-        return tagName;
+        } 
+        
+        return -1;
     }
 
-    public static int optionLength(String option) {
-        if ("-dumpJavaDocFile".equals(option)) {
-            return 2;
-        }
-        return 0;
+    private String getAllComments(final Collection<? extends DocTree> comments) {
+        return comments
+            .stream()
+            .map(DocTree::toString)
+            .collect(Collectors.joining());
     }
-
-    public static boolean validOptions(String[][] options, DocErrorReporter reporter) {
-        boolean foundTagOption = false;
-        for (int i = 0; i < options.length; i++) {
-            String[] opt = options[i];
-            if ("-dumpJavaDocFile".equals(opt[0])) {
-                if (foundTagOption) {
-                    reporter.printError("Only one -dumpJavaDocFile option allowed.");
-                    return false;
-                }
-                foundTagOption = true;
-            }
-        }
-        if (!foundTagOption) {
-            reporter.printError("Usage: -dumpJavaDocFile theFileToDumpJavaDocForLaterUse...");
-        }
-        return foundTagOption;
+    
+    @Override
+    public Set<Option> getSupportedOptions() {
+        return Collections.singleton(new DumpJavaDocFileOption());
     }
 }
diff --git a/maven-plugins/java2wadl-plugin/src/main/java13/org/apache/cxf/maven_plugin/javatowadl/DumpJavaDoc.java b/maven-plugins/java2wadl-plugin/src/main/java13/org/apache/cxf/maven_plugin/javatowadl/DumpJavaDoc.java
deleted file mode 100644
index 5ca20af500..0000000000
--- a/maven-plugins/java2wadl-plugin/src/main/java13/org/apache/cxf/maven_plugin/javatowadl/DumpJavaDoc.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/**
- * 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.cxf.maven_plugin.javatowadl;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
-import java.util.Properties;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.util.Elements;
-import javax.tools.Diagnostic;
-
-import com.sun.source.doctree.DocCommentTree;
-import com.sun.source.doctree.DocTree;
-import com.sun.source.doctree.ParamTree;
-import com.sun.source.doctree.ReturnTree;
-import com.sun.source.util.DocTrees;
-
-import java.util.Set;
-import java.util.stream.Collectors;
-
-import javax.lang.model.SourceVersion;
-
-import jdk.javadoc.doclet.Doclet;
-import jdk.javadoc.doclet.DocletEnvironment;
-import jdk.javadoc.doclet.Reporter;
-
-public final class DumpJavaDoc implements Doclet {
-    private String dumpFileName;
-    private Reporter reporter;
-    
-    private final class DumpJavaDocFileOption implements Option {
-        @Override
-        public int getArgumentCount() {
-            return 1;
-        }
-
-        @Override
-        public String getDescription() {
-            return "Specify the file to dump Javadoc for later use";
-        }
-
-        @Override
-        public Kind getKind() {
-            return Kind.STANDARD;
-        }
-
-        @Override
-        public List<String> getNames() {
-            return Collections.singletonList("-dumpJavaDocFile");
-        }
-
-        @Override
-        public String getParameters() {
-            return "theFileToDumpJavaDocForLaterUse";
-        }
-
-        @Override
-        public boolean process(String option, List<String> arguments) {
-            dumpFileName = arguments.get(0);
-            return true;
-        }
-    }
-
-    public DumpJavaDoc() {
-
-    }
-
-    @Override
-    public void init(Locale locale, Reporter reporter) {
-        this.reporter = reporter;
-    }
-
-    @Override
-    public String getName() {
-        return "DumpJavaDoc";
-    }
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.RELEASE_8;
-    }
-
-    @Override
-    public boolean run(DocletEnvironment docEnv) {
-        final Elements utils = docEnv.getElementUtils();
-        final DocTrees docTrees = docEnv.getDocTrees();
-        
-        try (OutputStream os = Files.newOutputStream(Paths.get(dumpFileName))) {
-            final Properties javaDocMap = new Properties();
-            for (Element element : docEnv.getIncludedElements()) {
-                if (element.getKind() == ElementKind.CLASS) {
-                    final TypeElement classDoc = (TypeElement) element;
-                    final DocCommentTree classCommentTree = docTrees.getDocCommentTree(classDoc);
-                    
-                    if (classCommentTree != null) {
-                        javaDocMap.put(classDoc.toString(), getAllComments(classCommentTree.getFullBody()));
-                    }
-                    
-                    for (Element member: classDoc.getEnclosedElements()) {
-                        // Skip all non-public methods
-                        if (!member.getModifiers().contains(Modifier.PUBLIC)) {
-                            continue;
-                        }
-                        
-                        if (member.getKind() == ElementKind.METHOD) {
-                            final ExecutableElement method = (ExecutableElement) member;
-                            final DocCommentTree methodCommentTree = docTrees.getDocCommentTree(method);
-                            final String qualifiedName = utils.getBinaryName(classDoc) + "." + method.getSimpleName();
-                            
-                            if (methodCommentTree == null) {
-                                javaDocMap.put(qualifiedName, "");
-                            } else  {
-                                javaDocMap.put(qualifiedName, getAllComments(methodCommentTree.getFullBody()));
-                                for (DocTree tree: methodCommentTree.getBlockTags()) {
-                                    if (tree.getKind() == DocTree.Kind.RETURN) {
-                                        final ReturnTree returnTree = (ReturnTree) tree;
-                                        javaDocMap.put(qualifiedName + ".returnCommentTag", 
-                                            getAllComments(returnTree.getDescription()));
-                                    } else if (tree.getKind() == DocTree.Kind.PARAM) {
-                                        final ParamTree paramTree = (ParamTree) tree;
-                                        final int index = getParamIndex(method, paramTree);
-                                        if (index >= 0) {
-                                            javaDocMap.put(qualifiedName + ".paramCommentTag." + index, 
-                                                getAllComments(paramTree.getDescription()));
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-            
-            javaDocMap.store(os, "");
-            os.flush();
-        } catch (final IOException ex) {
-            reporter.print(Diagnostic.Kind.ERROR, ex.getMessage());
-        }
-        
-        return true;
-    }
-    
-    private int getParamIndex(final ExecutableElement method, final ParamTree paramTree) {
-        final List<? extends VariableElement> parameters = method.getParameters();
-        
-        for (int i = 0; i < parameters.size(); ++i) {
-            if (paramTree.getName().getName().contentEquals(parameters.get(i).getSimpleName())) {
-                return i;
-            }
-        } 
-        
-        return -1;
-    }
-
-    private String getAllComments(final Collection<? extends DocTree> comments) {
-        return comments
-            .stream()
-            .map(DocTree::toString)
-            .collect(Collectors.joining());
-    }
-    
-    @Override
-    public Set<Option> getSupportedOptions() {
-        return Collections.singleton(new DumpJavaDocFileOption());
-    }
-}