Skip to content

Commit 27c56bc

Browse files
authored
Merge pull request #283 from SentryMan/helidon-M2
Helidon 4.0-M2
2 parents 42abe78 + 86f49ca commit 27c56bc

File tree

18 files changed

+79
-98
lines changed

18 files changed

+79
-98
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
java_version: [17, 20]
13+
java_version: [17, 21-ea]
1414
os: [ubuntu-latest]
1515

1616
steps:

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ public class WidgetController {
7676
## DI Usage
7777
The annotation processor will generate controller adapters to register routes to Javalin/Helidon. The natural way to use the generated adapters is to get a DI library to find and wire them. This is what the examples below do; they use [Avaje-Inject](https://avaje.io/inject/) to do this. The AP will automatically detect the presence of avaje-inject and generate the class to use avaje-inject's `@Component` as the DI annotation.
7878

79-
There isn't a hard requirement to use Avaje for dependency injection. In the absence of avaje-inject, the generated class will use `@jakarta.inject.Singleton` or `@javax.inject.Singleton` depending on what's on the classpath. Any DI library that can find and wire the generated @Singleton beans can be used. You can even use Dagger2 or Guice to wire the controllers if you so desire.
79+
There isn't a hard requirement to use Avaje for dependency injection. In the absence of avaje-inject, the generated class will use `@jakarta.inject.Singleton` or `@javax.inject.Singleton` depending on what's on the classpath. Any DI library that can find and wire the generated @Singleton beans can be used. You can even use Dagger2 or Guice to wire the controllers if you so desire.
8080

81-
To force the AP to generate with `@javax.inject.Singleton`(in the case where you have both jakarta and javax on the classpath), use the compiler arg `-AuseJavax=true`
81+
To force the AP to generate with `@javax.inject.Singleton`(in the case where you have both jakarta and javax on the classpath), use the compiler arg `-AuseJavax=true`
8282
```xml
8383
<plugin>
8484
<groupId>org.apache.maven.plugins</groupId>
@@ -111,7 +111,7 @@ get all the services and register them with the Helidon `HttpRouting`.
111111
List<HttpFeature> routes = BeanScope.builder().build().list(HttpFeature.class);
112112
final var builder = HttpRouting.builder();
113113

114-
routes.forEach(builder::register);
114+
routes.forEach(builder::addFeature);
115115

116116
WebServer.builder()
117117
.addRouting(builder.build())

http-generator-helidon/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
<artifactId>avaje-http-helidon-generator</artifactId>
1111

1212
<properties>
13-
<java.release>20</java.release>
14-
<maven.compiler.source>20</maven.compiler.source>
15-
<maven.compiler.target>20</maven.compiler.target>
13+
<java.release>21</java.release>
14+
<maven.compiler.source>21</maven.compiler.source>
15+
<maven.compiler.target>21</maven.compiler.target>
1616
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1717
</properties>
1818

http-generator-helidon/src/main/java/io/avaje/http/generator/helidon/nima/ControllerMethodWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ private void writeContextReturn() {
263263
}
264264

265265
final var produces = producesOp.map(MediaType::parse).orElse(MediaType.APPLICATION_JSON);
266-
final var contentTypeString = " res.headers().contentType(HttpMediaType.";
266+
final var contentTypeString = " res.headers().contentType(MediaTypes.";
267267
switch (produces) {
268268
case APPLICATION_JSON -> writer.append(contentTypeString).append("APPLICATION_JSON);").eol();
269269
case TEXT_HTML -> writer.append(contentTypeString).append("TEXT_HTML);").eol();

http-generator-helidon/src/main/java/io/avaje/http/generator/helidon/nima/ControllerWriter.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
class ControllerWriter extends BaseControllerWriter {
2323

2424
private static final String AT_GENERATED = "@Generated(\"avaje-helidon-generator\")";
25-
private static final String IMPORT_HTTP_STATUS = "import static io.helidon.common.http.Http.Status.*;";
25+
private static final String IMPORT_HTTP_STATUS = "import static io.helidon.http.Http.Status.*;";
2626

2727
private final boolean useJsonB;
2828
private final Map<String, UType> jsonTypes;
@@ -42,22 +42,22 @@ class ControllerWriter extends BaseControllerWriter {
4242
} else {
4343
this.jsonTypes = Map.of();
4444
}
45-
reader.addImportType("io.helidon.common.http.HttpMediaType");
45+
reader.addImportType("io.helidon.common.media.type.MediaTypes");
4646
reader.addImportType("io.helidon.common.parameters.Parameters");
47-
reader.addImportType("io.helidon.nima.webserver.http.HttpRouting");
48-
reader.addImportType("io.helidon.nima.webserver.http.ServerRequest");
49-
reader.addImportType("io.helidon.nima.webserver.http.ServerResponse");
50-
reader.addImportType("io.helidon.nima.webserver.http.HttpFeature");
51-
reader.addImportType("io.helidon.common.http.Http.Header");
47+
reader.addImportType("io.helidon.webserver.http.HttpRouting");
48+
reader.addImportType("io.helidon.webserver.http.ServerRequest");
49+
reader.addImportType("io.helidon.webserver.http.ServerResponse");
50+
reader.addImportType("io.helidon.webserver.http.HttpFeature");
51+
reader.addImportType("io.helidon.http.Http.HeaderNames");
5252
if (reader.isIncludeValidator()) {
53-
reader.addImportType("io.helidon.common.http.Http");
53+
reader.addImportType("io.helidon.http.Http");
5454
}
5555
if (reader.methods().stream()
5656
.map(MethodReader::webMethod)
5757
.anyMatch(w -> CoreWebMethod.FILTER == w)) {
58-
reader.addImportType("io.helidon.nima.webserver.http.FilterChain");
59-
reader.addImportType("io.helidon.nima.webserver.http.RoutingRequest");
60-
reader.addImportType("io.helidon.nima.webserver.http.RoutingResponse");
58+
reader.addImportType("io.helidon.webserver.http.FilterChain");
59+
reader.addImportType("io.helidon.webserver.http.RoutingRequest");
60+
reader.addImportType("io.helidon.webserver.http.RoutingResponse");
6161
}
6262
}
6363

@@ -118,7 +118,7 @@ private void writeClassStart() {
118118
}
119119

120120
if (reader.isIncludeValidator()) {
121-
writer.append(" private static final Http.HeaderName HEADER_ACCEPT_LANGUAGE = Header.create(\"Accept-Language\");").eol();
121+
writer.append(" private static final Http.HeaderName HEADER_ACCEPT_LANGUAGE = HeaderNames.create(\"Accept-Language\");").eol();
122122
}
123123

124124
writer.append(" private final %s %s;", controllerType, controllerName).eol();

http-generator-helidon/src/main/java/io/avaje/http/generator/helidon/nima/NimaProcessor.java renamed to http-generator-helidon/src/main/java/io/avaje/http/generator/helidon/nima/HelidonProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import io.avaje.prism.AnnotationProcessor;
1010

1111
@AnnotationProcessor
12-
public class NimaProcessor extends BaseProcessor {
12+
public class HelidonProcessor extends BaseProcessor {
1313

1414
@Override
1515
protected PlatformAdapter providePlatformAdapter() {

http-generator-helidon/src/main/java/io/avaje/http/generator/helidon/nima/NimaPlatformAdapter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
class NimaPlatformAdapter implements PlatformAdapter {
1212

13-
static final String NIMA_REQ = "io.helidon.nima.webserver.http.ServerRequest";
14-
static final String NIMA_RES = "io.helidon.nima.webserver.http.ServerResponse";
13+
static final String NIMA_REQ = "io.helidon.webserver.http.ServerRequest";
14+
static final String NIMA_RES = "io.helidon.webserver.http.ServerResponse";
1515
static final String HELIDON_FORMPARAMS = "io.helidon.common.parameters.Parameters";
1616

1717
@Override
@@ -74,7 +74,7 @@ public void writeReadParameter(Append writer, ParamType paramType, String paramN
7474
case FORMPARAM -> writer.append("formParams.first(\"%s\").orElse(null)", paramName);
7575

7676
case HEADER -> writer.append(
77-
"req.headers().value(Header.create(\"%s\")).orElse(null)", paramName);
77+
"req.headers().value(HeaderNames.create(\"%s\")).orElse(null)", paramName);
7878

7979
case COOKIE -> writer.append("req.headers().cookies().first(\"%s\").orElse(null)", paramName);
8080

http-generator-helidon/src/main/java/module-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
requires java.compiler;
44
requires java.sql;
55

6-
provides javax.annotation.processing.Processor with io.avaje.http.generator.helidon.nima.NimaProcessor;
6+
provides javax.annotation.processing.Processor with io.avaje.http.generator.helidon.nima.HelidonProcessor;
77

88
// SHADED: All content after this line will be removed at package time
99
requires transitive io.avaje.http.generator.core;

tests/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<assertj.version>3.24.1</assertj.version>
1717
<jackson.version>2.14.1</jackson.version>
1818
<jex.version>2.5</jex.version>
19-
<avaje-inject.version>9.0</avaje-inject.version>
20-
<nima.version>4.0.0-M1</nima.version>
19+
<avaje-inject.version>9.5</avaje-inject.version>
20+
<nima.version>4.0.0-M2</nima.version>
2121
</properties>
2222

2323
<modules>
@@ -30,9 +30,9 @@
3030

3131
<profiles>
3232
<profile>
33-
<id>jdk19plus</id>
33+
<id>jdk20plus</id>
3434
<activation>
35-
<jdk>[19,20,21]</jdk>
35+
<jdk>21</jdk>
3636
</activation>
3737
<modules>
3838
<module>test-nima</module>

tests/test-nima-jsonb/pom.xml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
<artifactId>test-nima-jsonb</artifactId>
1313

1414
<properties>
15-
<java.release>20</java.release>
16-
<maven.compiler.source>20</maven.compiler.source>
17-
<maven.compiler.target>20</maven.compiler.target>
15+
<java.release>21</java.release>
16+
<maven.compiler.source>21</maven.compiler.source>
17+
<maven.compiler.target>21</maven.compiler.target>
1818
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1919
<surefire.useModulePath>false</surefire.useModulePath>
2020
</properties>
@@ -34,21 +34,21 @@
3434
<dependency>
3535
<groupId>io.avaje</groupId>
3636
<artifactId>avaje-jsonb</artifactId>
37-
<version>1.7-RC1</version>
37+
<version>1.8-RC1</version>
3838
</dependency>
3939
<dependency>
4040
<groupId>io.avaje</groupId>
4141
<artifactId>avaje-http-hibernate-validator</artifactId>
4242
<version>3.3</version>
4343
</dependency>
4444
<dependency>
45-
<groupId>io.helidon.nima.webserver</groupId>
46-
<artifactId>helidon-nima-webserver</artifactId>
45+
<groupId>io.helidon.webserver</groupId>
46+
<artifactId>helidon-webserver</artifactId>
4747
<version>${nima.version}</version>
4848
</dependency>
4949
<dependency>
50-
<groupId>io.helidon.nima.http.media</groupId>
51-
<artifactId>helidon-nima-http-media-jsonb</artifactId>
50+
<groupId>io.helidon.http.media</groupId>
51+
<artifactId>helidon-http-media-jsonb</artifactId>
5252
<version>${nima.version}</version>
5353
</dependency>
5454
<dependency>
@@ -78,8 +78,7 @@
7878
<groupId>org.apache.maven.plugins</groupId>
7979
<artifactId>maven-compiler-plugin</artifactId>
8080
<configuration>
81-
<enablePreview>true</enablePreview>
82-
<release>20</release>
81+
<release>21</release>
8382
<annotationProcessorPaths>
8483
<path>
8584
<groupId>io.avaje</groupId>
@@ -103,9 +102,6 @@
103102
<groupId>org.apache.maven.plugins</groupId>
104103
<artifactId>maven-surefire-plugin</artifactId>
105104
<version>3.0.0</version>
106-
<configuration>
107-
<argLine>--enable-preview</argLine>
108-
</configuration>
109105
</plugin>
110106
<plugin>
111107
<groupId>io.repaint.maven</groupId>

tests/test-nima-jsonb/src/main/java/org/example/ErrorController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import io.avaje.http.api.Controller;
44
import io.avaje.http.api.ExceptionHandler;
5-
import io.helidon.nima.webserver.http.ServerRequest;
6-
import io.helidon.nima.webserver.http.ServerResponse;
5+
import io.helidon.webserver.http.ServerRequest;
6+
import io.helidon.webserver.http.ServerResponse;
77

88
import java.util.Map;
99

tests/test-nima-jsonb/src/main/java/org/example/HelloController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
import io.avaje.http.api.Put;
1515
import io.avaje.http.api.QueryParam;
1616
import io.avaje.http.api.Valid;
17-
import io.helidon.common.http.HttpMediaType;
18-
import io.helidon.nima.webserver.http.ServerRequest;
19-
import io.helidon.nima.webserver.http.ServerResponse;
17+
import io.helidon.common.media.type.MediaTypes;
18+
import io.helidon.webserver.http.ServerRequest;
19+
import io.helidon.webserver.http.ServerResponse;
2020

2121
@Controller
2222
public class HelloController {
@@ -41,7 +41,7 @@ byte[] testBytes() {
4141

4242
@Get("/helidon")
4343
void testHelidon(ServerRequest req, ServerResponse res) {
44-
res.headers().contentType(HttpMediaType.TEXT_PLAIN);
44+
res.headers().contentType(MediaTypes.TEXT_PLAIN);
4545
res.send("success path:" + req.path());
4646
}
4747

tests/test-nima-jsonb/src/main/java/org/example/Main.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55
import io.avaje.inject.BeanScope;
66
import io.avaje.jsonb.Jsonb;
7-
import io.helidon.nima.webserver.WebServer;
8-
import io.helidon.nima.webserver.http.HttpFeature;
9-
import io.helidon.nima.webserver.http.HttpRouting;
10-
import io.helidon.nima.webserver.http.HttpService;
7+
import io.helidon.webserver.WebServer;
8+
import io.helidon.webserver.http.HttpFeature;
9+
import io.helidon.webserver.http.HttpRouting;
1110

1211
public class Main {
1312

tests/test-nima-jsonb/src/main/java/org/example/TestController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package org.example;
22

33
import io.avaje.http.api.*;
4-
import io.helidon.nima.webserver.http.FilterChain;
5-
import io.helidon.nima.webserver.http.RoutingResponse;
6-
import io.helidon.nima.webserver.http.ServerRequest;
7-
import io.helidon.nima.webserver.http.ServerResponse;
4+
import io.helidon.webserver.http.FilterChain;
5+
import io.helidon.webserver.http.RoutingResponse;
6+
import io.helidon.webserver.http.ServerRequest;
7+
import io.helidon.webserver.http.ServerResponse;
88

99
import java.io.InputStream;
1010
import java.util.LinkedHashMap;

tests/test-nima-jsonb/src/test/java/io/avaje/http/generator/NimaProcessorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.junit.jupiter.api.AfterEach;
2222
import org.junit.jupiter.api.Test;
2323

24-
import io.avaje.http.generator.helidon.nima.NimaProcessor;
24+
import io.avaje.http.generator.helidon.nima.HelidonProcessor;
2525

2626
class NimaProcessorTest {
2727

@@ -46,7 +46,7 @@ void runAnnotationProcessor() throws Exception {
4646
final var task =
4747
compiler.getTask(
4848
new PrintWriter(System.out), null, null, List.of("--release=20", "-AdisableDirectWrites=true"), null, files);
49-
task.setProcessors(List.of(new NimaProcessor()));
49+
task.setProcessors(List.of(new HelidonProcessor()));
5050

5151
assertThat(task.call()).isTrue();
5252
}
@@ -62,7 +62,7 @@ void runAnnotationProcessorWithJsonB() throws Exception {
6262
final var task =
6363
compiler.getTask(
6464
new PrintWriter(System.out), null, null, List.of("--release=19"), null, files);
65-
task.setProcessors(List.of(new NimaProcessor()));
65+
task.setProcessors(List.of(new HelidonProcessor()));
6666

6767
assertThat(task.call()).isTrue();
6868
}

tests/test-nima-jsonb/src/test/java/org/example/TestPair.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import io.avaje.http.client.HttpClient;
55
import io.avaje.http.hibernate.validator.BeanValidator;
66
import io.avaje.jsonb.Jsonb;
7-
import io.helidon.nima.webserver.WebServer;
8-
import io.helidon.nima.webserver.http.HttpRouting;
7+
import io.helidon.webserver.WebServer;
8+
import io.helidon.webserver.http.HttpRouting;
99

1010
public class TestPair {
1111

tests/test-nima/pom.xml

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<artifactId>test-nima</artifactId>
1313

1414
<properties>
15-
<maven.compiler.source>20</maven.compiler.source>
16-
<maven.compiler.target>20</maven.compiler.target>
15+
<maven.compiler.source>21</maven.compiler.source>
16+
<maven.compiler.target>21</maven.compiler.target>
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1818
</properties>
1919

@@ -30,26 +30,21 @@
3030
<version>${project.version}</version>
3131
</dependency>
3232
<dependency>
33-
<groupId>io.helidon.nima.webserver</groupId>
34-
<artifactId>helidon-nima-webserver</artifactId>
33+
<groupId>io.helidon.webserver</groupId>
34+
<artifactId>helidon-webserver</artifactId>
3535
<version>${nima.version}</version>
3636
</dependency>
3737
<dependency>
38-
<groupId>io.helidon.nima.http.media</groupId>
39-
<artifactId>helidon-nima-http-media-jsonb</artifactId>
38+
<groupId>io.helidon.http.media</groupId>
39+
<artifactId>helidon-http-media-jsonb</artifactId>
4040
<version>${nima.version}</version>
4141
</dependency>
42-
43-
<!-- <dependency>-->
44-
<!-- <groupId>io.helidon.nima.http2</groupId>-->
45-
<!-- <artifactId>helidon-nima-http2-webserver</artifactId>-->
46-
<!-- <version>4.0.0-SNAPSHOT</version>-->
47-
<!-- </dependency>-->
48-
<!-- <dependency>-->
49-
<!-- <groupId>io.helidon.nima.websocket</groupId>-->
50-
<!-- <artifactId>helidon-nima-websocket-webserver</artifactId>-->
51-
<!-- <version>4.0.0-SNAPSHOT</version>-->
52-
<!-- </dependency>-->
42+
<dependency>
43+
<groupId>io.avaje</groupId>
44+
<artifactId>avaje-http-helidon-generator</artifactId>
45+
<version>${project.version}</version>
46+
<scope>test</scope>
47+
</dependency>
5348
</dependencies>
5449

5550
<build>
@@ -59,7 +54,7 @@
5954
<artifactId>maven-compiler-plugin</artifactId>
6055
<version>3.10.1</version>
6156
<configuration>
62-
<release>20</release>
57+
<release>21</release>
6358
<annotationProcessorPaths>
6459
<path>
6560
<groupId>io.avaje</groupId>
@@ -72,8 +67,8 @@
7267
<version>${avaje-inject.version}</version>
7368
</path>
7469
</annotationProcessorPaths>
75-
<source>19</source>
76-
<target>19</target>
70+
<source>21</source>
71+
<target>21</target>
7772
</configuration>
7873
</plugin>
7974
<plugin>

0 commit comments

Comments
 (0)