Skip to content

Commit 843665f

Browse files
committed
#48 - Update to generate using "jakarta.inject" with avaje-inject version 4.1
1 parent cd682c7 commit 843665f

File tree

25 files changed

+104
-78
lines changed

25 files changed

+104
-78
lines changed

http-generator-core/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
<dependencies>
2020

2121
<dependency>
22-
<groupId>javax.inject</groupId>
23-
<artifactId>javax.inject</artifactId>
24-
<version>1</version>
22+
<groupId>jakarta.inject</groupId>
23+
<artifactId>jakarta.inject-api</artifactId>
24+
<version>2.0.0</version>
2525
</dependency>
2626

2727
<dependency>
@@ -33,7 +33,7 @@
3333
<dependency>
3434
<groupId>io.avaje</groupId>
3535
<artifactId>avaje-http-api</artifactId>
36-
<version>0.1</version>
36+
<version>1.1</version>
3737
</dependency>
3838

3939
<dependency>

http-generator-core/src/main/java/io/avaje/http/generator/core/Constants.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ class Constants {
44

55
static final String OPENAPIDEFINITION = "io.swagger.v3.oas.annotations.OpenAPIDefinition";
66

7-
static final String SINGLETON = "javax.inject.Singleton";
8-
static final String GENERATED_9 = "javax.annotation.processing.Generated";
9-
//static final String GENERATED_8 = "javax.annotation.Generated";
7+
static final String SINGLETON = "jakarta.inject.Singleton";
8+
static final String GENERATED = "io.avaje.http.api.Generated";
109

1110
static final String IMPORT_PATH_TYPE_CONVERT = "import static io.avaje.http.api.PathTypeConversion.*;";
1211

http-generator-core/src/main/java/io/avaje/http/generator/core/ControllerReader.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ public class ControllerReader {
6161
this.interfaces = initInterfaces();
6262
this.interfaceMethods = initInterfaceMethods();
6363
this.roles = Util.findRoles(beanType);
64-
final String generated = ctx.getGeneratedAnnotation();
65-
if (generated != null) {
66-
importTypes.add(generated);
67-
}
64+
importTypes.add(Constants.GENERATED);
6865
if (ctx.isOpenApiAvailable()) {
6966
docHidden = initDocHidden();
7067
}

http-generator-core/src/main/java/io/avaje/http/generator/core/ProcessingContext.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public class ProcessingContext {
2323
private final Filer filer;
2424
private final Elements elements;
2525
private final Types types;
26-
private final String generatedAnnotation;
2726
private final boolean openApiAvailable;
2827
private final DocContext docContext;
2928

@@ -35,12 +34,6 @@ public class ProcessingContext {
3534
this.types = env.getTypeUtils();
3635
this.openApiAvailable = isTypeAvailable(Constants.OPENAPIDEFINITION);
3736
this.docContext = new DocContext(env, openApiAvailable);
38-
boolean jdk8 = env.getSourceVersion().compareTo(SourceVersion.RELEASE_8) <= 0;
39-
this.generatedAnnotation = generatedAnnotation(jdk8);
40-
}
41-
42-
private String generatedAnnotation(boolean jdk8) {
43-
return jdk8 ? null : isTypeAvailable(Constants.GENERATED_9) ? Constants.GENERATED_9 : null;
4437
}
4538

4639
private boolean isTypeAvailable(String canonicalName) {
@@ -51,14 +44,6 @@ public TypeElement getTypeElement(String canonicalName) {
5144
return elements.getTypeElement(canonicalName);
5245
}
5346

54-
public boolean isGeneratedAvailable() {
55-
return generatedAnnotation != null;
56-
}
57-
58-
public String getGeneratedAnnotation() {
59-
return generatedAnnotation;
60-
}
61-
6247
public boolean isOpenApiAvailable() {
6348
return openApiAvailable;
6449
}
@@ -67,10 +52,6 @@ public void logError(Element e, String msg, Object... args) {
6752
messager.printMessage(Diagnostic.Kind.ERROR, String.format(msg, args), e);
6853
}
6954

70-
// void logDebug(String msg, Object... args) {
71-
// messager.printMessage(Diagnostic.Kind.NOTE, String.format(msg, args));
72-
// }
73-
7455
/**
7556
* Create a file writer for the given class name.
7657
*/

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ private void writeRoutes(List<ControllerMethodWriter> methods) {
6262
}
6363

6464
private void writeClassStart() {
65-
if (ctx.isGeneratedAvailable()) {
66-
writer.append(AT_GENERATED).eol();
67-
}
65+
writer.append(AT_GENERATED).eol();
6866
writer.append("@Singleton").eol();
6967
writer.append("public class ").append(shortName).append("$route implements Service {").eol().eol();
7068

http-generator-javalin/src/main/java/io/avaje/http/generator/javalin/ControllerWriter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ private void writeForMethod(MethodReader method) {
4747
}
4848

4949
private void writeClassStart() {
50-
if (ctx.isGeneratedAvailable()) {
51-
writer.append(AT_GENERATED).eol();
52-
}
50+
writer.append(AT_GENERATED).eol();
5351
writer.append("@Singleton").eol();
5452
writer.append("public class ").append(shortName).append("$route implements WebRoutes {").eol().eol();
5553

http-generator-jex/src/main/java/io/avaje/http/generator/jex/ControllerWriter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ private void writeForMethod(MethodReader method) {
4949
}
5050

5151
private void writeClassStart() {
52-
if (ctx.isGeneratedAvailable()) {
53-
writer.append(AT_GENERATED).eol();
54-
}
52+
writer.append(AT_GENERATED).eol();
5553
writer.append("@Singleton").eol();
5654
writer.append("public class ").append(shortName).append("$route implements Routing.Service {").eol().eol();
5755

http-generator-spark/src/main/java/io/avaje/http/generator/spark/ControllerWriter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ private void writeForMethod(MethodReader method) {
4747
}
4848

4949
private void writeClassStart() {
50-
if (ctx.isGeneratedAvailable()) {
51-
writer.append(AT_GENERATED).eol();
52-
}
50+
writer.append(AT_GENERATED).eol();
5351
writer.append("@Singleton").eol();
5452
writer.append("public class ").append(shortName).append("$route implements WebRoutes {").eol().eol();
5553

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<parent>
1111
<groupId>org.avaje</groupId>
1212
<artifactId>java8-oss</artifactId>
13-
<version>2.2</version>
13+
<version>2.3</version>
1414
</parent>
1515

1616
<scm>
@@ -34,7 +34,7 @@
3434
<module>http-generator-javalin</module>
3535
<module>http-generator-jex</module>
3636
<module>http-generator-helidon</module>
37-
<module>http-generator-spark</module>
37+
<!-- <module>http-generator-spark</module>-->
3838
<!-- <module>http-generator-client</module>-->
3939
<module>tests</module>
4040
</modules>

tests/test-client/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<dependency>
2626
<groupId>io.avaje</groupId>
2727
<artifactId>avaje-http-client</artifactId>
28-
<version>0.1</version>
28+
<version>0.10</version>
2929
</dependency>
3030

3131
<dependency>
@@ -37,7 +37,7 @@
3737
<dependency>
3838
<groupId>io.avaje</groupId>
3939
<artifactId>avaje-http-api</artifactId>
40-
<version>0.1</version>
40+
<version>1.1</version>
4141
</dependency>
4242

4343
<dependency>

0 commit comments

Comments
 (0)