TomEE 9 docs
diff --git a/pom.xml b/pom.xml
index 99ec9c8..cd5bc77 100755
--- a/pom.xml
+++ b/pom.xml
@@ -112,6 +112,11 @@
<artifactId>tomitribe-tio</artifactId>
<version>0.5</version>
</dependency>
+ <dependency>
+ <groupId>org.tomitribe</groupId>
+ <artifactId>swizzle</artifactId>
+ <version>1.1</version>
+ </dependency>
</dependencies>
<build>
diff --git a/src/main/java/org/apache/tomee/website/Jakartize.java b/src/main/java/org/apache/tomee/website/Jakartize.java
new file mode 100644
index 0000000..cd7264c
--- /dev/null
+++ b/src/main/java/org/apache/tomee/website/Jakartize.java
@@ -0,0 +1,104 @@
+/*
+ * 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.tomee.website;
+
+import org.apache.tomee.website.Source;
+import org.tomitribe.swizzle.stream.StreamBuilder;
+import org.tomitribe.tio.Dir;
+import org.tomitribe.util.IO;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UncheckedIOException;
+
+/**
+ * The TomEE 9.0.0 releases are generated from TomEE 8.0.0 releases
+ * via bytecode manipulation. The purpose of this class is to do the
+ * same transformation for the docs.
+ *
+ * The "tomee-9.0" source is effectively a clone of master (tomee-8.0).
+ * To prepare this clone we will search for all docs/ and examples/
+ * files and update any contents they may have to account for the
+ * javax to jakarta rename.
+ *
+ * For the purposes of our documentation, it will be as if we have done
+ * the rename in source.
+ */
+public class Jakartize {
+
+ public void prepare(final Source source) {
+ if (!source.getName().equals("tomee-9.0")) return;
+
+ final Dir dir = Dir.from(source.getDir());
+ dir.searchFiles()
+ .filter(File::isFile)
+ .filter(this::isDocsOrExamples)
+ .forEach(this::jakartize);
+ }
+
+ private boolean isDocsOrExamples(final File file) {
+ final String path = file.getAbsolutePath();
+ return path.contains("/docs/") || path.contains("/examples/");
+ }
+
+ private void jakartize(final File file) {
+ try {
+ final InputStream inputStream = StreamBuilder.create(IO.read(file))
+ .replace("javax.activation", "jakarta.activation")
+ .replace("javax.annotation", "jakarta.annotation")
+ .replace("javax.batch", "jakarta.batch")
+ .replace("javax.decorator", "jakarta.decorator")
+ .replace("javax.ejb", "jakarta.ejb")
+ .replace("javax.el", "jakarta.el")
+ .replace("javax.enterprise", "jakarta.enterprise")
+ .replace("javax.faces", "jakarta.faces")
+ .replace("javax.inject", "jakarta.inject")
+ .replace("javax.interceptor", "jakarta.interceptor")
+ .replace("javax.jms", "jakarta.jms")
+ .replace("javax.json", "jakarta.json")
+ .replace("javax.json.bind", "jakarta.json.bind")
+ .replace("javax.jws", "jakarta.jws")
+ .replace("javax.mail", "jakarta.mail")
+ .replace("javax.persistence", "jakarta.persistence")
+ .replace("javax.resource", "jakarta.resource")
+ .replace("javax.security.auth.message", "jakarta.security.auth.message")
+ .replace("javax.security.enterprise", "jakarta.security.enterprise")
+ .replace("javax.security.jacc", "jakarta.security.jacc")
+ .replace("javax.servlet", "jakarta.servlet")
+ .replace("javax.transaction", "jakarta.transaction")
+ .replace("javax.validation", "jakarta.validation")
+ .replace("javax.websocket", "jakarta.websocket")
+ .replace("javax.ws.rs", "jakarta.ws.rs")
+ .replace("javax.xml.bind", "jakarta.xml.bind")
+ .replace("javax.xml.soap", "jakarta.xml.soap")
+ .replace("javax.xml.ws", "jakarta.xml.ws")
+ // There will be some false hits we need to fix. Some of the
+ // sub-packages are excluded from the rename. Put them back.
+ .replace("jakarta.enterprise.deploy", "javax.enterprise.deploy")
+ .replace("jakarta.annotation.process", "javax.annotation.process")
+ .replace("jakarta.transaction.xa", "javax.transaction.xa")
+ .get();
+
+ final String content = IO.slurp(inputStream);
+ IO.copy(IO.read(content), file);
+ } catch (IOException e) {
+ throw new UncheckedIOException("Failed to process file: " + file.getAbsolutePath(), e);
+ }
+
+ }
+}
diff --git a/src/main/java/org/apache/tomee/website/Sources.java b/src/main/java/org/apache/tomee/website/Sources.java
index 71066ae..579790d 100644
--- a/src/main/java/org/apache/tomee/website/Sources.java
+++ b/src/main/java/org/apache/tomee/website/Sources.java
@@ -125,6 +125,7 @@
final Examples examples = new Examples(this);
final VersionIndex versionIndex = new VersionIndex(this);
final LearningLinks learningLinks = new LearningLinks(examples);
+ final Jakartize jakartize = new Jakartize();
try {
IO.copyDirectory(mainSource, jbake);
@@ -142,6 +143,7 @@
// Run any initial steps to process each
// source root (excluding the related repos)
sources.stream()
+ .peek(jakartize::prepare)
.peek(docs::prepare)
.peek(javadocs::prepare)
.peek(examples::prepare)