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/06 21:05:24 UTC
[tomee-site-generator] 01/02: Add MicroProfile javadoc
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 db604d2a46dd6cdf767618e8f3e5ae61eaa1cf50
Author: David Blevins <da...@gmail.com>
AuthorDate: Sun Jan 6 12:14:58 2019 -0800
Add MicroProfile javadoc
---
src/main/java/org/apache/tomee/website/JBake.java | 13 +++++-
.../java/org/apache/tomee/website/Javadocs.java | 53 +++++++++++-----------
src/main/java/org/apache/tomee/website/Source.java | 53 ++++++++++++++++++++--
.../java/org/apache/tomee/website/Sources.java | 6 +++
4 files changed, 94 insertions(+), 31 deletions(-)
diff --git a/src/main/java/org/apache/tomee/website/JBake.java b/src/main/java/org/apache/tomee/website/JBake.java
index 3a2b44d..15ef459 100755
--- a/src/main/java/org/apache/tomee/website/JBake.java
+++ b/src/main/java/org/apache/tomee/website/JBake.java
@@ -36,12 +36,23 @@ public class JBake {
final File destination = args == null || args.length < 2 ? new File("target/site-tmp") : new File(args[1]);
final boolean startHttp = args == null || args.length < 2 || Boolean.parseBoolean(args[2]); // by default we dev
+ final Source[] microProfile2 = new Source[]{
+ new Source("https://github.com/eclipse/microprofile-jwt-auth.git", "1.1.1", "microprofile-jwt-1.1").filterJavadoc(".*/api/src/main/java/.*", ""),
+ new Source("https://github.com/eclipse/microprofile-config.git", "1.3", "microprofile-config-1.3").filterJavadoc(".*/api/src/main/java/.*", ""),
+ new Source("https://github.com/eclipse/microprofile-fault-tolerance", "1.1.4", "microprofile-fault-tolerance-1.1").filterJavadoc(".*/api/src/main/java/.*", ""),
+ new Source("https://github.com/eclipse/microprofile-health", "1.0", "microprofile-health-1.0").filterJavadoc(".*/api/src/main/java/.*", ""),
+ new Source("https://github.com/eclipse/microprofile-metrics", "1.1.1", "microprofile-metrics-1.1").filterJavadoc(".*/api/src/main/java/.*", ""),
+ new Source("https://github.com/eclipse/microprofile-open-api", "1.0.2", "microprofile-open-api-1.0").filterJavadoc(".*/api/src/main/java/.*", ""),
+ new Source("https://github.com/eclipse/microprofile-opentracing", "1.1", "microprofile-opentracing-1.1").filterJavadoc(".*/api/src/main/java/.*", ""),
+ new Source("https://github.com/eclipse/microprofile-rest-client", "1.1", "microprofile-rest-client-1.1").filterJavadoc(".*/api/src/main/java/.*", ""),
+ };
+
final Sources sources = new Sources(
new File("target/jbake"),
new File("repos"),
new File("src/main/jbake"),
destination,
- 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", "master", "tomee-8.0", true).related(microProfile2),
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")
diff --git a/src/main/java/org/apache/tomee/website/Javadocs.java b/src/main/java/org/apache/tomee/website/Javadocs.java
index 23f0324..4818378 100644
--- a/src/main/java/org/apache/tomee/website/Javadocs.java
+++ b/src/main/java/org/apache/tomee/website/Javadocs.java
@@ -76,29 +76,9 @@ public class Javadocs {
public void prepare(final Source source) {
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");
+ copySource(source, javaSources);
+ for (final Source related : source.getRelated()) {
+ copySource(related, javaSources);
}
final ProcessBuilder cmd = new ProcessBuilder(
@@ -123,6 +103,29 @@ public class Javadocs {
}
}
+ private void copySource(final Source source, final File javaSources) {
+ try {
+ java.nio.file.Files.walk(source.getDir().toPath())
+ .map(Path::toFile)
+ .filter(File::isFile)
+ .filter(this::isJava)
+ .filter(source.getJavadocFilter()::include)
+ .filter(source.getJavadocFilter()::exclude)
+ .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");
+ }
+ }
+
public static File getJavadocCommand() {
final File java_home = System.getenv("JAVA_HOME") != null ? new File(System.getenv("JAVA_HOME")) : new File("");
@@ -152,10 +155,6 @@ public class Javadocs {
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/Source.java b/src/main/java/org/apache/tomee/website/Source.java
index af0afd6..70e0adf 100644
--- a/src/main/java/org/apache/tomee/website/Source.java
+++ b/src/main/java/org/apache/tomee/website/Source.java
@@ -16,17 +16,20 @@
*/
package org.apache.tomee.website;
-import org.apache.openejb.loader.IO;
-
import java.io.File;
-import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Pattern;
public class Source {
private final String name;
private final String scmUrl;
private final String branch;
private final boolean latest;
+ private final List<Source> related = new ArrayList<>();
private File dir;
+ private Filter javadocFilter = new Filter(".*/src/main/java/.*", ".*/(tck|itests|examples|archetype-resources|.*-example)/.*");
public Source(final String scmUrl, final String branch, final String name) {
this(scmUrl, branch, name, false);
@@ -63,6 +66,25 @@ public class Source {
this.dir = dir;
}
+ public List<Source> getRelated() {
+ return related;
+ }
+
+ public Source related(final Source... related) {
+ Collections.addAll(this.related, related);
+ return this;
+ }
+
+ public Filter getJavadocFilter() {
+ return javadocFilter;
+ }
+
+ public Source filterJavadoc(final String include, final String exclude) {
+ this.javadocFilter = new Filter(include, exclude);
+ return this;
+ }
+
+
@Override
public String toString() {
return "Source{" +
@@ -72,4 +94,29 @@ public class Source {
'}';
}
+ public static class Filter {
+ private final Pattern include;
+ private final Pattern exclude;
+
+ public Filter(final String include, final String exclude) {
+ this.include = Pattern.compile(include);
+ this.exclude = Pattern.compile(exclude);
+ }
+
+ public Pattern getInclude() {
+ return include;
+ }
+
+ public Pattern getExclude() {
+ return exclude;
+ }
+
+ public boolean include(final File file) {
+ return include.matcher(file.getAbsolutePath()).matches();
+ }
+
+ public boolean exclude(final File file) {
+ return !exclude.matcher(file.getAbsolutePath()).matches();
+ }
+ }
}
diff --git a/src/main/java/org/apache/tomee/website/Sources.java b/src/main/java/org/apache/tomee/website/Sources.java
index be892da..599b9df 100644
--- a/src/main/java/org/apache/tomee/website/Sources.java
+++ b/src/main/java/org/apache/tomee/website/Sources.java
@@ -127,6 +127,11 @@ public class Sources {
}
sources.stream()
+ .flatMap(source -> source.getRelated().stream())
+ .peek(source -> source.setDir(new File(repos, source.getName())))
+ .forEach(Repos::download);
+
+ sources.stream()
.peek(source -> source.setDir(new File(repos, source.getName())))
.peek(Repos::download)
.peek(docs::prepare)
@@ -138,6 +143,7 @@ public class Sources {
VersionsIndex.prepare(this);
}
+
/**
* This is the heart of the code to merge several documentation
* sources into one tree.