Skip to content

Commit dfc8f52

Browse files
Copilotsimbo1905
andauthored
Issue #0 add jdt2jar CLI and container
Agent-Logs-Url: https://github.com/simbo1905/java.util.json.Java21/sessions/46541410-0395-47ca-bf41-41ba6d0a8dc6 Co-authored-by: simbo1905 <322608+simbo1905@users.noreply.github.com>
1 parent d431813 commit dfc8f52

11 files changed

Lines changed: 931 additions & 27 deletions

File tree

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM eclipse-temurin:24-jdk AS build
4+
WORKDIR /build
5+
COPY . .
6+
RUN ["./mvnw", "-pl", "jdt2jar", "-am", "package", "-DskipTests", "-Dsurefire.failIfNoSpecifiedTests=false"]
7+
RUN ["java", "-cp", "/build/jdt2jar/target/jdt2jar.jar", "json.java21.jdt2jar.build.DockerImageBuilder", "/build/jdt2jar/target/jdt2jar.jar", "/opt/jre"]
8+
RUN ["mkdir", "-p", "/work/tmp"]
9+
RUN ["chmod", "1777", "/work/tmp"]
10+
11+
FROM gcr.io/distroless/base-debian13:nonroot
12+
WORKDIR /work
13+
ENV JAVA_TOOL_OPTIONS="-XX:+UseContainerSupport -XX:MaxRAMPercentage=75.0 -Djava.io.tmpdir=/work/tmp -XX:+ExitOnOutOfMemoryError"
14+
COPY --from=build /opt/jre /jre
15+
COPY --from=build /build/jdt2jar/target/jdt2jar.jar /app/jdt2jar.jar
16+
COPY --from=build /work /work
17+
ENTRYPOINT ["/jre/bin/java","-jar","/app/jdt2jar.jar"]

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This repo is organized into the following modules:
1616
| `json-java21` | Core `java.util.json` backport (parser, immutable types, `Json` API) | 21+ |
1717
| `json-java21-jtd` | JSON Type Definition (JTD) validator implementing RFC 8927, with stack-machine interpreter and optional bytecode codegen interface (`JtdValidator`) | 21+ |
1818
| `json-java21-jtd-codegen` | Bytecode code generator for JTD schemas using JDK 24+ ClassFile API (JEP 484); generates Java 21-compatible `.class` files for ~9x faster validation | 24+ (auto-skipped on JDK 21) |
19+
| `jdt2jar` | Offline JTD-to-JAR compiler CLI and distroless container wrapper for build-time validator packaging | 24+ (auto-skipped on JDK 21) |
1920
| `json-java21-jsonpath` | JsonPath query engine over `jdk.sandbox.java.util.json` values (Goessner-style: filters, slices, recursive descent, unions) | 21+ |
2021
| `json-compatibility-suite` | JSON Test Suite conformance reporter (tests against [nst/JSONTestSuite](https://github.com/nst/JSONTestSuite)) | 21+ |
2122
| `json-java21-api-tracker` | Daily upstream API drift detector — fetches OpenJDK sandbox sources, compares public API signatures, reports differences | 25+ |

jdt2jar/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# jdt2jar
2+
3+
`jdt2jar` compiles a JTD schema into a standalone validator JAR at build time.
4+
5+
## CLI
6+
7+
```bash
8+
jdt2jar <schema.json> [options]
9+
```
10+
11+
Options:
12+
13+
- `--output <path>`: output JAR path
14+
- `--package <name>`: generated package name
15+
- `--class <name>`: validator class name
16+
- `--main`: include a standalone `java -jar` entry point
17+
- `--runtime <version>`: target bytecode version
18+
- `--include-sources`: write a companion `.java` file next to the JAR
19+
- `--help`: show usage
20+
21+
## Container
22+
23+
Build with the root `Dockerfile` and run it as a non-root distroless image.
24+
25+
```bash
26+
docker build -t jdt2jar .
27+
docker run --rm jdt2jar --help
28+
syft packages image:jdt2jar
29+
grype jdt2jar
30+
```

jdt2jar/pom.xml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
5+
http://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
8+
<parent>
9+
<groupId>io.github.simbo1905.json</groupId>
10+
<artifactId>parent</artifactId>
11+
<version>0.1.9</version>
12+
</parent>
13+
14+
<artifactId>jdt2jar</artifactId>
15+
<packaging>jar</packaging>
16+
<name>jdt2jar CLI</name>
17+
<description>Offline JTD-to-JAR compiler that packages generated validators into standalone JAR files.</description>
18+
19+
<properties>
20+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21+
<maven.compiler.release>24</maven.compiler.release>
22+
<project.build.finalName>jdt2jar</project.build.finalName>
23+
</properties>
24+
25+
<dependencies>
26+
<dependency>
27+
<groupId>io.github.simbo1905.json</groupId>
28+
<artifactId>java.util.json</artifactId>
29+
<version>${project.version}</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>io.github.simbo1905.json</groupId>
33+
<artifactId>java.util.json.jtd</artifactId>
34+
<version>${project.version}</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>io.github.simbo1905.json</groupId>
38+
<artifactId>java.util.json.jtd.codegen</artifactId>
39+
<version>${project.version}</version>
40+
</dependency>
41+
42+
<dependency>
43+
<groupId>org.junit.jupiter</groupId>
44+
<artifactId>junit-jupiter-api</artifactId>
45+
<scope>test</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.junit.jupiter</groupId>
49+
<artifactId>junit-jupiter-engine</artifactId>
50+
<scope>test</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.assertj</groupId>
54+
<artifactId>assertj-core</artifactId>
55+
<scope>test</scope>
56+
</dependency>
57+
</dependencies>
58+
59+
<build>
60+
<plugins>
61+
<plugin>
62+
<groupId>org.apache.maven.plugins</groupId>
63+
<artifactId>maven-compiler-plugin</artifactId>
64+
<version>3.13.0</version>
65+
<configuration>
66+
<release>24</release>
67+
<compilerArgs>
68+
<arg>-Xlint:all</arg>
69+
<arg>-Xdiags:verbose</arg>
70+
</compilerArgs>
71+
</configuration>
72+
</plugin>
73+
<plugin>
74+
<groupId>org.apache.maven.plugins</groupId>
75+
<artifactId>maven-shade-plugin</artifactId>
76+
<version>3.6.0</version>
77+
<executions>
78+
<execution>
79+
<phase>package</phase>
80+
<goals>
81+
<goal>shade</goal>
82+
</goals>
83+
<configuration>
84+
<createDependencyReducedPom>false</createDependencyReducedPom>
85+
<shadedArtifactAttached>false</shadedArtifactAttached>
86+
<finalName>jdt2jar</finalName>
87+
<transformers>
88+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
89+
<mainClass>json.java21.jdt2jar.Jdt2Jar</mainClass>
90+
</transformer>
91+
</transformers>
92+
</configuration>
93+
</execution>
94+
</executions>
95+
</plugin>
96+
<plugin>
97+
<groupId>org.apache.maven.plugins</groupId>
98+
<artifactId>maven-javadoc-plugin</artifactId>
99+
<configuration>
100+
<release>24</release>
101+
<doclint>none</doclint>
102+
</configuration>
103+
</plugin>
104+
</plugins>
105+
</build>
106+
</project>

0 commit comments

Comments
 (0)