Skip to content

Commit 57e3855

Browse files
aepfliclaudeCopilot
authored
Feat/java library (#59)
## Description <!-- Provide a brief description of your changes --> ## Related Issue <!-- Link to the related issue(s) --> Closes # ## Type of Change <!-- Mark the relevant option with an "x" --> - [ ] `feat`: New feature (minor version bump) - [ ] `fix`: Bug fix (patch version bump) - [ ] `docs`: Documentation only changes - [ ] `chore`: Maintenance tasks, dependency updates - [ ] `refactor`: Code refactoring without functional changes - [ ] `test`: Adding or updating tests - [ ] `ci`: CI/CD changes - [ ] `perf`: Performance improvements - [ ] `build`: Build system changes - [ ] `style`: Code style/formatting changes ## PR Title Format **IMPORTANT**: Since we use squash and merge, your PR title will become the commit message. Please ensure your PR title follows the [Conventional Commits](https://www.conventionalcommits.org/) format: ``` <type>(<optional-scope>): <description> ``` ### Examples: - `feat(operators): add new string comparison operator` - `fix(wasm): correct memory allocation bug` - `docs: update API examples in README` - `chore(deps): update rust dependencies` For breaking changes, use `!` after the type/scope or include `BREAKING CHANGE:` in the PR description: - `feat(api)!: redesign evaluation API` ## Testing <!-- Describe the testing you've performed --> - [ ] Unit tests added/updated - [ ] Integration tests added/updated - [ ] Manual testing performed - [ ] All tests pass (`cargo test`) - [ ] Code is formatted (`cargo fmt`) - [ ] Clippy checks pass (`cargo clippy -- -D warnings`) - [ ] WASM builds successfully (if applicable) ## Breaking Changes <!-- If this introduces breaking changes, describe them here --> - [ ] This PR includes breaking changes - [ ] Documentation has been updated to reflect breaking changes - [ ] Migration guide included (if needed) ## Additional Notes <!-- Any additional information, context, or screenshots --> --------- Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
1 parent 748f05d commit 57e3855

10 files changed

Lines changed: 1005 additions & 464 deletions

File tree

java/pom.xml

Lines changed: 78 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
56
<modelVersion>4.0.0</modelVersion>
67

78
<groupId>dev.openfeature</groupId>
@@ -25,21 +26,26 @@
2526
<maven.compiler.target>11</maven.compiler.target>
2627
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2728

28-
<!-- Dependency versions -->
2929
<chicory.version>1.6.1</chicory.version>
3030
<jackson.version>2.18.2</jackson.version>
3131
<junit.version>5.11.4</junit.version>
3232
<assertj.version>3.27.3</assertj.version>
3333
<jmh.version>1.37</jmh.version>
3434
</properties>
3535

36+
<!-- ===================== -->
37+
<!-- Dependencies -->
38+
<!-- ===================== -->
39+
3640
<dependencies>
41+
42+
<!-- Production code -->
3743
<dependency>
3844
<groupId>dev.openfeature</groupId>
3945
<artifactId>sdk</artifactId>
4046
<version>1.19.2</version>
4147
</dependency>
42-
<!-- Chicory WASM Runtime -->
48+
4349
<dependency>
4450
<groupId>com.dylibso.chicory</groupId>
4551
<artifactId>runtime</artifactId>
@@ -56,94 +62,81 @@
5662
<version>${chicory.version}</version>
5763
</dependency>
5864

59-
<!-- Jackson for JSON -->
6065
<dependency>
6166
<groupId>com.fasterxml.jackson.core</groupId>
6267
<artifactId>jackson-databind</artifactId>
6368
<version>${jackson.version}</version>
6469
</dependency>
6570

66-
<!-- Test dependencies -->
71+
<!-- JMH -->
72+
<dependency>
73+
<groupId>org.openjdk.jmh</groupId>
74+
<artifactId>jmh-core</artifactId>
75+
<version>${jmh.version}</version>
76+
</dependency>
77+
<dependency>
78+
<groupId>org.openjdk.jmh</groupId>
79+
<artifactId>jmh-generator-annprocess</artifactId>
80+
<version>${jmh.version}</version>
81+
<scope>provided</scope>
82+
</dependency>
83+
84+
<!-- Tests (still allowed, but not benchmarks) -->
6785
<dependency>
6886
<groupId>org.junit.jupiter</groupId>
6987
<artifactId>junit-jupiter</artifactId>
7088
<version>${junit.version}</version>
7189
<scope>test</scope>
7290
</dependency>
91+
7392
<dependency>
7493
<groupId>org.assertj</groupId>
7594
<artifactId>assertj-core</artifactId>
7695
<version>${assertj.version}</version>
7796
<scope>test</scope>
7897
</dependency>
7998

80-
<!-- JMH Benchmarking -->
81-
<dependency>
82-
<groupId>org.openjdk.jmh</groupId>
83-
<artifactId>jmh-core</artifactId>
84-
<version>${jmh.version}</version>
85-
<scope>test</scope>
86-
</dependency>
87-
<dependency>
88-
<groupId>org.openjdk.jmh</groupId>
89-
<artifactId>jmh-generator-annprocess</artifactId>
90-
<version>${jmh.version}</version>
91-
<scope>test</scope>
92-
</dependency>
9399
<dependency>
94100
<groupId>io.github.jamsesso</groupId>
95101
<artifactId>json-logic-java</artifactId>
96102
<version>1.1.0</version>
97-
<scope>test</scope>
98103
</dependency>
104+
99105
</dependencies>
100106

107+
<!-- ===================== -->
108+
<!-- Build -->
109+
<!-- ===================== -->
110+
101111
<build>
102112
<plugins>
113+
114+
<!-- Compiler + JMH annotation processing -->
103115
<plugin>
104116
<groupId>org.apache.maven.plugins</groupId>
105117
<artifactId>maven-compiler-plugin</artifactId>
106118
<version>3.13.0</version>
107119
<configuration>
108120
<source>11</source>
109121
<target>11</target>
122+
<annotationProcessorPaths>
123+
<path>
124+
<groupId>org.openjdk.jmh</groupId>
125+
<artifactId>jmh-generator-annprocess</artifactId>
126+
<version>${jmh.version}</version>
127+
</path>
128+
</annotationProcessorPaths>
110129
</configuration>
111130
</plugin>
112131

132+
<!-- Surefire (unit tests only) -->
113133
<plugin>
114134
<groupId>org.apache.maven.plugins</groupId>
115135
<artifactId>maven-surefire-plugin</artifactId>
116136
<version>3.5.2</version>
117137
</plugin>
118138

119-
<!-- Copy WASM file from Rust build to resources -->
120-
<plugin>
121-
<groupId>org.apache.maven.plugins</groupId>
122-
<artifactId>maven-resources-plugin</artifactId>
123-
<version>3.3.1</version>
124-
<executions>
125-
<execution>
126-
<id>copy-wasm-module</id>
127-
<phase>generate-sources</phase>
128-
<goals>
129-
<goal>copy-resources</goal>
130-
</goals>
131-
<configuration>
132-
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
133-
<resources>
134-
<resource>
135-
<directory>${project.basedir}/../target/wasm32-unknown-unknown/release</directory>
136-
<includes>
137-
<include>flagd_evaluator.wasm</include>
138-
</includes>
139-
</resource>
140-
</resources>
141-
</configuration>
142-
</execution>
143-
</executions>
144-
</plugin>
145-
146-
<!-- Build WASM module before copying -->
139+
<!-- Build WASM -->
147140
<plugin>
148141
<groupId>org.codehaus.mojo</groupId>
149142
<artifactId>exec-maven-plugin</artifactId>
@@ -168,26 +161,37 @@
168161
</arguments>
169162
</configuration>
170163
</execution>
164+
</executions>
165+
</plugin>
166+
167+
<!-- Copy WASM -->
168+
<plugin>
169+
<groupId>org.apache.maven.plugins</groupId>
170+
<artifactId>maven-resources-plugin</artifactId>
171+
<version>3.3.1</version>
172+
<executions>
171173
<execution>
172-
<id>run-jmh-benchmark</id>
174+
<id>copy-wasm-module</id>
175+
<phase>generate-sources</phase>
173176
<goals>
174-
<goal>java</goal>
177+
<goal>copy-resources</goal>
175178
</goals>
176179
<configuration>
177-
<includePluginDependencies>false</includePluginDependencies>
178-
<classpathScope>test</classpathScope>
179-
<mainClass>org.openjdk.jmh.Main</mainClass>
180-
<arguments>
181-
<argument>FlagEvaluatorJmhBenchmark</argument>
182-
<argument>-f</argument>
183-
<argument>0</argument>
184-
</arguments>
180+
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
181+
<resources>
182+
<resource>
183+
<directory>${project.basedir}/../target/wasm32-unknown-unknown/release</directory>
184+
<includes>
185+
<include>flagd_evaluator.wasm</include>
186+
</includes>
187+
</resource>
188+
</resources>
185189
</configuration>
186190
</execution>
187191
</executions>
188192
</plugin>
189193

190-
<!-- AOT compile WASM to Java bytecode -->
194+
<!-- Chicory AOT -->
191195
<plugin>
192196
<groupId>com.dylibso.chicory</groupId>
193197
<artifactId>chicory-compiler-maven-plugin</artifactId>
@@ -201,12 +205,13 @@
201205
<configuration>
202206
<wasmFile>${project.build.outputDirectory}/flagd_evaluator.wasm</wasmFile>
203207
<name>dev.openfeature.flagd.evaluator.CompiledEvaluator</name>
204-
<!-- Allow interpreter fallback for functions that exceed JVM method size limits -->
205208
<interpreterFallback>WARN</interpreterFallback>
206209
</configuration>
207210
</execution>
208211
</executions>
209212
</plugin>
213+
214+
<!-- Add generated sources -->
210215
<plugin>
211216
<groupId>org.codehaus.mojo</groupId>
212217
<artifactId>build-helper-maven-plugin</artifactId>
@@ -226,35 +231,31 @@
226231
</execution>
227232
</executions>
228233
</plugin>
229-
<!-- Source JAR -->
230-
<plugin>
231-
<groupId>org.apache.maven.plugins</groupId>
232-
<artifactId>maven-source-plugin</artifactId>
233-
<version>3.3.1</version>
234-
<executions>
235-
<execution>
236-
<id>attach-sources</id>
237-
<goals>
238-
<goal>jar-no-fork</goal>
239-
</goals>
240-
</execution>
241-
</executions>
242-
</plugin>
243234

244-
<!-- Javadoc JAR -->
235+
<!-- JMH fat JAR -->
245236
<plugin>
246237
<groupId>org.apache.maven.plugins</groupId>
247-
<artifactId>maven-javadoc-plugin</artifactId>
248-
<version>3.11.2</version>
238+
<artifactId>maven-shade-plugin</artifactId>
239+
<version>3.5.1</version>
249240
<executions>
250241
<execution>
251-
<id>attach-javadocs</id>
242+
<phase>package</phase>
252243
<goals>
253-
<goal>jar</goal>
244+
<goal>shade</goal>
254245
</goals>
246+
<configuration>
247+
<finalName>benchmarks</finalName>
248+
<transformers>
249+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
250+
<mainClass>org.openjdk.jmh.Main</mainClass>
251+
</transformer>
252+
</transformers>
253+
</configuration>
255254
</execution>
256255
</executions>
257256
</plugin>
257+
258258
</plugins>
259259
</build>
260+
260261
</project>

0 commit comments

Comments
 (0)