Skip to content

Commit

Permalink
[helidon-generator] Support avaje-jsonb version 3 (#532)
Browse files Browse the repository at this point in the history
With the change of package for JsonOutput which is now in avaje-json-core
  • Loading branch information
rbygrave authored Dec 12, 2024
1 parent c9ecc86 commit 5e2e491
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@
import java.util.Map;
import java.util.Objects;

import io.avaje.http.generator.core.BaseControllerWriter;
import io.avaje.http.generator.core.Constants;
import io.avaje.http.generator.core.ControllerReader;
import io.avaje.http.generator.core.CoreWebMethod;
import io.avaje.http.generator.core.JsonBUtil;
import io.avaje.http.generator.core.MethodReader;
import io.avaje.http.generator.core.PrimitiveUtil;
import io.avaje.http.generator.core.UType;
import io.avaje.http.generator.core.*;

/**
* Write Helidon specific web route adapter (a Helidon Service).
Expand All @@ -25,6 +18,9 @@ class ControllerWriter extends BaseControllerWriter {
private static final String AT_GENERATED = "@Generated(\"avaje-helidon-generator\")";
private static final String IMPORT_HTTP_STATUS = "import static io.helidon.http.Status.*;";

private static final String JSON_JsonOutput = "io.avaje.json.stream.JsonOutput";
private static final String JSONB_JsonOutput = "io.avaje.jsonb.stream.JsonOutput";

private final boolean useJsonB;
private final Map<String, UType> jsonTypes;

Expand All @@ -35,7 +31,7 @@ class ControllerWriter extends BaseControllerWriter {
reader.addImportType("io.avaje.jsonb.Jsonb");
reader.addImportType("io.avaje.jsonb.JsonType");
reader.addImportType("io.avaje.jsonb.Types");
reader.addImportType("io.avaje.jsonb.stream.JsonOutput");
reader.addImportType(jsonOutputType());
this.jsonTypes = JsonBUtil.jsonTypes(reader);
jsonTypes.values().stream()
.map(UType::importTypes)
Expand Down Expand Up @@ -76,6 +72,12 @@ class ControllerWriter extends BaseControllerWriter {
}
}

private static String jsonOutputType() {
return ProcessingContext.typeElement(JSON_JsonOutput) != null
? JSON_JsonOutput
: JSONB_JsonOutput;
}

void write() {
writePackage();
writeImports();
Expand Down
4 changes: 2 additions & 2 deletions tests/test-jex/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb</artifactId>
<version>2.4</version>
<version>3.0-RC2</version>
</dependency>

<!-- java annotation processors -->
Expand All @@ -96,7 +96,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb-generator</artifactId>
<version>2.4</version>
<version>3.0-RC2</version>
</dependency>

<dependency>
Expand Down
4 changes: 2 additions & 2 deletions tests/test-nima-jsonb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb</artifactId>
<version>2.4</version>
<version>3.0-RC2</version>
</dependency>
<dependency>
<groupId>io.helidon.webserver</groupId>
Expand Down Expand Up @@ -85,7 +85,7 @@
<path>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb-generator</artifactId>
<version>2.4</version>
<version>3.0-RC2</version>
</path>
<path>
<groupId>io.avaje</groupId>
Expand Down

0 comments on commit 5e2e491

Please sign in to comment.