diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d829b820..d6b5c291 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - java_version: [1.8, 11, 17] + java_version: [11, 17, 21] os: [windows-latest, macOS-latest, ubuntu-latest] steps: diff --git a/.gitignore b/.gitignore index bcc0e4eb..379aafd4 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ buildNumber.properties ### IntelliJ ### *.iml .idea/ + +target diff --git a/GETTING_STARTED.md b/GETTING_STARTED.md new file mode 100644 index 00000000..eb096aa8 --- /dev/null +++ b/GETTING_STARTED.md @@ -0,0 +1,21 @@ +# Getting started + +### Build all projects: +- `mvn clean install` + +### Core project +- The core project is situated in the `j2html` directory. When building, source code is generated using the maven plugin from project `j2html-codegen` + +### Extra projects +- `j2html-website` - the project website (using j2html code) that runs via Javalin (https://javalin.io/) +- `j2html-codegen` - maven plugin for generating Java sources from a configured collection of tags (in a .model file). +- `j2html-mathml` - a mathml extension + +### Hints when using Intellij: +- Mark directory `j2html/target/generated-sources/j2html-codegen` as Generated Sources Root +- Mark directory `j2html-ext-mathml/target/generated-sources/j2html-codegen` as Generated Sources Root + +### Security check on dependencies +- Type `mvn org.owasp:dependency-check-maven:6.5.3:aggregate` and wait for the generated security report + + diff --git a/j2html-codegen/pom.xml b/j2html-codegen/pom.xml index e9ca1495..56553a1f 100644 --- a/j2html-codegen/pom.xml +++ b/j2html-codegen/pom.xml @@ -18,14 +18,14 @@ org.apache.maven maven-plugin-api - 3.8.4 + 3.8.8 provided org.apache.maven.plugin-tools maven-plugin-annotations - 3.6.0 + 3.6.4 provided diff --git a/j2html-website/pom.xml b/j2html-website/pom.xml index c0598da9..64a432f3 100644 --- a/j2html-website/pom.xml +++ b/j2html-website/pom.xml @@ -15,13 +15,11 @@ io.javalin javalin - 4.0.0.ALPHA2 org.slf4j slf4j-simple - 1.7.26 diff --git a/j2html-website/src/main/java/app/Main.java b/j2html-website/src/main/java/app/Main.java index 60164f06..66134666 100644 --- a/j2html-website/src/main/java/app/Main.java +++ b/j2html-website/src/main/java/app/Main.java @@ -3,12 +3,27 @@ import app.controllers.PageController; import io.javalin.Javalin; import io.javalin.http.staticfiles.Location; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.IOException; public class Main { + private static final Logger LOG = LoggerFactory.getLogger(Main.class); + + public static void main(String[] args) { + String path = "./src/main/resources/public"; + File file = new File(path); + + try { + LOG.info("static files served from location: {}, ready {} ", file.getCanonicalFile(), file.exists()); + } catch (IOException ex) { + throw new IllegalStateException(ex); + } - public static void main(String[] args) { - Javalin app = Javalin.create(config -> - config.addStaticFiles("website/src/main/resources/public", Location.EXTERNAL) + Javalin app = Javalin.create( + config -> config.staticFiles.add(path, Location.EXTERNAL) ).start(8888); app.get("/", PageController::serveIndex); diff --git a/j2html/pom.xml b/j2html/pom.xml index 14434bb0..2016c202 100644 --- a/j2html/pom.xml +++ b/j2html/pom.xml @@ -39,9 +39,15 @@ org.apache.velocity - velocity + velocity-engine-core test + + org.hsqldb + hsqldb + test + + jar diff --git a/j2html/src/test/java/j2html/PerformanceTest.java b/j2html/src/test/java/j2html/PerformanceTest.java index de33ee7e..06767a1a 100644 --- a/j2html/src/test/java/j2html/PerformanceTest.java +++ b/j2html/src/test/java/j2html/PerformanceTest.java @@ -18,13 +18,13 @@ public class PerformanceTest { @Rule public TestRule benchmarkRun = new BenchmarkRule(); - private String shortTestString = "\n" + private final String shortTestString = "\n" + "

Heading!

\n" + " \n" + ""; // syntax-highlighted getting started example from j2html.com: - private String longTestString = + private final String longTestString = "
import static j2html.TagCreator.*;\n"
             + "\n"
             + "public class Main {\n"
diff --git a/j2html/src/test/java/j2html/RenderPerformanceTest.java b/j2html/src/test/java/j2html/RenderPerformanceTest.java
index f4869c96..fda74fd3 100644
--- a/j2html/src/test/java/j2html/RenderPerformanceTest.java
+++ b/j2html/src/test/java/j2html/RenderPerformanceTest.java
@@ -29,7 +29,7 @@ public class RenderPerformanceTest {
     @Rule
     public TestRule benchmarkRun = new BenchmarkRule();
     String expected = "Browsertitle

Hello World!

Hello World!

Hello World!

Hello World!

Hello World!

Hello World!

Hello World!

Action!

Hello World!

Hello World!

Hello World!

Hello World!

Hello World!

Hello World!

Hello World!

Hello World!

Hello World!

Hello World!

Hello World!

Hello World!

Hello World!

"; - private DomContent template; + private final DomContent template; public RenderPerformanceTest() { this.template = diff --git a/j2html/src/test/java/j2html/comparison/RenderPerformanceComparisonTest.java b/j2html/src/test/java/j2html/comparison/RenderPerformanceComparisonTest.java index e821c50c..98399b24 100644 --- a/j2html/src/test/java/j2html/comparison/RenderPerformanceComparisonTest.java +++ b/j2html/src/test/java/j2html/comparison/RenderPerformanceComparisonTest.java @@ -17,18 +17,18 @@ public class RenderPerformanceComparisonTest { @Test public void j2htmlPerformance() throws Exception { - TestJ2html.helloWorld(); - TestJ2html.fiveHundredEmployees(); - TestJ2html.macros(); - TestJ2html.multiplicationTable(); + TestOptionsForJ2html.helloWorld(); + TestOptionsForJ2html.fiveHundredEmployees(); + TestOptionsForJ2html.macros(); + TestOptionsForJ2html.multiplicationTable(); } @Test public void velocityPerformance() throws Exception { - TestVelocity.helloWorld(); - TestVelocity.fiveHundredEmployees(); - TestVelocity.macros(); - TestVelocity.multiplicationTable(); + TestOptionsForVelocity.helloWorld(); + TestOptionsForVelocity.fiveHundredEmployees(); + TestOptionsForVelocity.macros(); + TestOptionsForVelocity.multiplicationTable(); } } diff --git a/j2html/src/test/java/j2html/comparison/TestJ2html.java b/j2html/src/test/java/j2html/comparison/TestOptionsForJ2html.java similarity index 87% rename from j2html/src/test/java/j2html/comparison/TestJ2html.java rename to j2html/src/test/java/j2html/comparison/TestOptionsForJ2html.java index ec66dab1..9c0df25c 100644 --- a/j2html/src/test/java/j2html/comparison/TestJ2html.java +++ b/j2html/src/test/java/j2html/comparison/TestOptionsForJ2html.java @@ -5,7 +5,10 @@ import j2html.comparison.j2html.Macros; import j2html.comparison.j2html.MultiplicationTable; -public class TestJ2html { +/** + * Options are used in {@link RenderPerformanceComparisonTest} + */ +class TestOptionsForJ2html { public static String helloWorld() { return HelloWorld.tag.render(); diff --git a/j2html/src/test/java/j2html/comparison/TestVelocity.java b/j2html/src/test/java/j2html/comparison/TestOptionsForVelocity.java similarity index 91% rename from j2html/src/test/java/j2html/comparison/TestVelocity.java rename to j2html/src/test/java/j2html/comparison/TestOptionsForVelocity.java index 3048014d..f92613f5 100644 --- a/j2html/src/test/java/j2html/comparison/TestVelocity.java +++ b/j2html/src/test/java/j2html/comparison/TestOptionsForVelocity.java @@ -7,9 +7,12 @@ import org.apache.velocity.VelocityContext; import org.apache.velocity.app.VelocityEngine; -public class TestVelocity { +/** + * Options are used in {@link RenderPerformanceComparisonTest} + */ +class TestOptionsForVelocity { - private static VelocityEngine velocityEngine; + private static final VelocityEngine velocityEngine; static { velocityEngine = new VelocityEngine(); @@ -45,6 +48,8 @@ public static String multiplicationTable() { return render("/comparison/velocity/multiplicationTable.vm", model); } + + public static void main(String[] args) { System.out.println(multiplicationTable()); } diff --git a/pom.xml b/pom.xml index 919ca8b7..8d4eef82 100644 --- a/pom.xml +++ b/pom.xml @@ -66,16 +66,17 @@ ${jdk.version} ${jdk.version} - 4.13.1 + 4.13.2 4.8.1 1.3 3.0 0.7.2 - 1.7 - 1.14.3 + 2.3 + 2.7.2 + 1.17.2 1.9.0 - 4.0.0.ALPHA2 - 1.7.26 + 6.1.3 + 2.0.13 @@ -109,12 +110,19 @@ + org.apache.velocity - velocity + velocity-engine-core ${apache-velocity.version} test + + org.hsqldb + hsqldb + ${hsqldb.version} + test + org.apache.commons