You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2019/01/05 05:29:47 UTC

[tomee-site-generator] branch master updated (17b7804 -> e195946)

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

dblevins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/tomee-site-generator.git.


    from 17b7804  TOMEE-2412 & TOMEE-2414 - pdf filename and tomee master link CI.
     new d817583  TOMEE-2342: Generate Javadoc for each version
     new e195946  Update repo locations after gitbox move.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/java/org/apache/tomee/website/JBake.java  |  8 +-
 .../java/org/apache/tomee/website/Javadocs.java    | 97 +++++++++++++++++++++-
 .../java/org/apache/tomee/website/Sources.java     | 25 ++++++
 .../org/apache/tomee/website/VersionIndex.java     |  1 +
 .../org/apache/tomee/website/VersionsIndex.java    |  2 +
 5 files changed, 128 insertions(+), 5 deletions(-)


[tomee-site-generator] 02/02: Update repo locations after gitbox move.

Posted by db...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dblevins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee-site-generator.git

commit e195946a120829698d43ada3c7e8fff239ddbb8f
Author: David Blevins <da...@gmail.com>
AuthorDate: Fri Jan 4 21:29:16 2019 -0800

    Update repo locations after gitbox move.
---
 src/main/java/org/apache/tomee/website/JBake.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/tomee/website/JBake.java b/src/main/java/org/apache/tomee/website/JBake.java
index 147fe8d..3a2b44d 100755
--- a/src/main/java/org/apache/tomee/website/JBake.java
+++ b/src/main/java/org/apache/tomee/website/JBake.java
@@ -41,10 +41,10 @@ public class JBake {
                 new File("repos"),
                 new File("src/main/jbake"),
                 destination,
-                new Source("https://git-wip-us.apache.org/repos/asf/tomee.git", "master", "tomee-8.0", true),
-                new Source("https://git-wip-us.apache.org/repos/asf/tomee.git", "tomee-7.1.0", "tomee-7.1"),
-                new Source("https://git-wip-us.apache.org/repos/asf/tomee.git", "tomee-7.0.5", "tomee-7.0"),
-                new Source("https://git-wip-us.apache.org/repos/asf/tomee.git", "master", "master")
+                new Source("https://gitbox.apache.org/repos/asf/tomee.git", "master", "tomee-8.0", true),
+                new Source("https://gitbox.apache.org/repos/asf/tomee.git", "tomee-7.1.0", "tomee-7.1"),
+                new Source("https://gitbox.apache.org/repos/asf/tomee.git", "tomee-7.0.5", "tomee-7.0"),
+                new Source("https://gitbox.apache.org/repos/asf/tomee.git", "master", "master")
         );
 
         sources.prepare();


[tomee-site-generator] 01/02: TOMEE-2342: Generate Javadoc for each version

Posted by db...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dblevins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee-site-generator.git

commit d8175832aa7792fe6415d89bb93951f4778edc28
Author: David Blevins <da...@gmail.com>
AuthorDate: Fri Jan 4 21:28:36 2019 -0800

    TOMEE-2342: Generate Javadoc for each version
---
 .../java/org/apache/tomee/website/Javadocs.java    | 97 +++++++++++++++++++++-
 .../java/org/apache/tomee/website/Sources.java     | 25 ++++++
 .../org/apache/tomee/website/VersionIndex.java     |  1 +
 .../org/apache/tomee/website/VersionsIndex.java    |  2 +
 4 files changed, 124 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/tomee/website/Javadocs.java b/src/main/java/org/apache/tomee/website/Javadocs.java
index 6320c42..da36eaf 100644
--- a/src/main/java/org/apache/tomee/website/Javadocs.java
+++ b/src/main/java/org/apache/tomee/website/Javadocs.java
@@ -16,6 +16,18 @@
  */
 package org.apache.tomee.website;
 
+import org.apache.openejb.loader.Files;
+import org.apache.openejb.loader.IO;
+import org.apache.openejb.util.Pipe;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.function.Supplier;
+import java.util.stream.Stream;
+
+import static org.apache.openejb.loader.Files.mkdirs;
+
 /**
  * For each git repo (source) it will collects the `src/main/java` contents
  * into one large source tree and use the Javadoc proccessor directly in code
@@ -63,6 +75,89 @@ public class Javadocs {
      */
     public void prepare(final Source source) {
 
-        // do the magic
+        final File javaSources = mkdirs(new File(String.format("target/javadocs/%s-src", source.getName())));
+
+        try {
+            java.nio.file.Files.walk(source.getDir().toPath())
+                    .map(Path::toFile)
+                    .filter(File::isFile)
+                    .filter(this::isJava)
+                    .filter(this::srcMainJava)
+                    .filter(file -> !file.getAbsolutePath().contains("/tck/"))
+                    .filter(file -> !file.getAbsolutePath().contains("/itests/"))
+                    .filter(file -> !file.getAbsolutePath().contains("/examples/"))
+                    .filter(file -> !file.getAbsolutePath().contains("-example/"))
+                    .filter(file -> !file.getAbsolutePath().contains("/archetype-resources/"))
+                    .forEach(file -> {
+                        try {
+                            final String relativePath = file.getAbsolutePath().replaceAll(".*/src/main/java/", "");
+                            final File dest = new File(javaSources, relativePath);
+                            Files.mkdirs(dest.getParentFile());
+                            IO.copy(file, dest);
+                        } catch (IOException e) {
+                            throw new IllegalStateException(e);
+                        }
+                    });
+        } catch (IOException e) {
+            throw new IllegalStateException("Failed to aggregate java sources");
+        }
+
+        final ProcessBuilder cmd = new ProcessBuilder(
+                getJavadocCommand().getAbsolutePath(),
+                "-sourcepath",
+                javaSources.getAbsolutePath(),
+                "-d",
+                sources.getGeneratedDestFor(source, "javadoc").getAbsolutePath()
+        );
+
+        Stream.of(javaSources.listFiles())
+                .filter(File::isDirectory)
+                .forEach(file -> {
+                    cmd.command().add("-subpackages");
+                    cmd.command().add(file.getName());
+                });
+
+        try {
+            Pipe.pipe(cmd.start());
+        } catch (IOException e) {
+            throw new IllegalStateException("Command failed");
+        }
+    }
+
+    public static File getJavadocCommand() {
+
+        final File java_home = System.getenv("JAVA_HOME") != null ? new File(System.getenv("JAVA_HOME")) : new File("");
+        final File javaHome = new File(System.getProperty("java.home"));
+
+        final Supplier<File>[] locations = new Supplier[]{
+                () -> new File(java_home, "bin/javadoc"),
+                () -> new File(java_home, "bin/javadoc.exe"),
+                () -> new File(java_home.getParentFile(), "bin/javadoc"),
+                () -> new File(java_home.getParentFile(), "bin/javadoc.exe"),
+                () -> new File(javaHome, "bin/javadoc"),
+                () -> new File(javaHome, "bin/javadoc.exe"),
+                () -> new File(javaHome.getParentFile(), "bin/javadoc"),
+                () -> new File(javaHome.getParentFile(), "bin/javadoc.exe"),
+        };
+
+        return Stream.of(locations)
+                .map(Supplier::get)
+                .filter(File::exists)
+                .filter(File::canExecute)
+                .findFirst().orElseThrow(() -> new IllegalStateException("Cannot find javadoc command"));
+    }
+
+    public static void main(String[] args) {
+    }
+
+    private static void copy(final File file, File javaSources) {
+    }
+
+    private boolean srcMainJava(final File file) {
+        return file.getAbsolutePath().contains("src/main/java/");
+    }
+
+    private boolean isJava(final File file) {
+        return file.getName().endsWith(".java");
     }
 }
diff --git a/src/main/java/org/apache/tomee/website/Sources.java b/src/main/java/org/apache/tomee/website/Sources.java
index 0b481bd..be892da 100644
--- a/src/main/java/org/apache/tomee/website/Sources.java
+++ b/src/main/java/org/apache/tomee/website/Sources.java
@@ -138,6 +138,18 @@ public class Sources {
 
         VersionsIndex.prepare(this);
     }
+    /**
+     * This is the heart of the code to merge several documentation
+     * sources into one tree.
+     */
+    public void post() {
+        final Javadocs javadocs = new Javadocs(this);
+
+        sources.stream()
+                .peek(javadocs::prepare)
+                .forEach(Sources::done);
+        ;
+    }
 
     public File getJbakeContentDestFor(final Source source, final String... parts) {
         final File content = new File(jbake, "content");
@@ -153,6 +165,19 @@ public class Sources {
         return dir;
     }
 
+    public File getGeneratedDestFor(final Source source, final String... parts) {
+        File dir = new File(generated, source.getName());
+
+        for (final String part : parts) {
+            dir = new File(dir, part);
+        }
+
+        if (!dir.exists()) {
+            if (!dir.mkdirs()) throw new RuntimeException("Could not make directory: " + dir.getAbsolutePath());
+        }
+        return dir;
+    }
+
     private static void done(final Source source) {
         System.out.println("Done " + source);
     }
diff --git a/src/main/java/org/apache/tomee/website/VersionIndex.java b/src/main/java/org/apache/tomee/website/VersionIndex.java
index a2d0116..0008428 100644
--- a/src/main/java/org/apache/tomee/website/VersionIndex.java
+++ b/src/main/java/org/apache/tomee/website/VersionIndex.java
@@ -50,6 +50,7 @@ public class VersionIndex {
             if (examples.exists() && examples.listFiles().length > 0) {
                 index.append(" - link:examples[Examples]\n");
             }
+            index.append(" - link:javadoc[Javadoc]\n");
 
             IO.copy(IO.read(index.toString()), new File(docs.getParentFile(), "index.adoc"));
 
diff --git a/src/main/java/org/apache/tomee/website/VersionsIndex.java b/src/main/java/org/apache/tomee/website/VersionsIndex.java
index eaf3b0a..a96e56e 100644
--- a/src/main/java/org/apache/tomee/website/VersionsIndex.java
+++ b/src/main/java/org/apache/tomee/website/VersionsIndex.java
@@ -56,6 +56,8 @@ public class VersionsIndex {
                 if (examples.exists() && examples.listFiles().length > 0) {
                     index.append(" - link:").append(source.getName()).append("/examples[Examples]\n");
                 }
+                index.append(" - link:").append(source.getName()).append("/javadoc[Javadoc]\n");
+
                 index.append("\n\n");
             }