Skip to content

Commit 23369d0

Browse files
committed
Working
1 parent 0bc554d commit 23369d0

File tree

29 files changed

+505
-194
lines changed

29 files changed

+505
-194
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
run: |
3636
if (( JAVA_VERSION < 19 ));
3737
then
38-
mvn clean test -pl "!:avaje-http-nima-generator"
38+
mvn clean package -pl "!:avaje-http-nima-generator"
3939
else
40-
mvn clean test
40+
mvn clean package
4141
fi

.github/workflows/jdk-ea.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ jobs:
3737
- name: Maven version
3838
run: mvn --version
3939
- name: Build with Maven
40-
run: mvn clean verify
40+
run: mvn clean verify package
4141

http-api/pom.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,4 @@
1515
<tag>avaje-http-parent-1.19</tag>
1616
</scm>
1717

18-
<dependencies>
19-
20-
<dependency>
21-
<groupId>io.avaje</groupId>
22-
<artifactId>junit</artifactId>
23-
<version>1.1</version>
24-
<scope>test</scope>
25-
</dependency>
26-
27-
</dependencies>
28-
2918
</project>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<parent>
4+
<artifactId>avaje-http-parent</artifactId>
5+
<groupId>io.avaje</groupId>
6+
<version>1.26-SNAPSHOT</version>
7+
</parent>
8+
<modelVersion>4.0.0</modelVersion>
9+
<artifactId>avaje-http-client-generator</artifactId>
10+
<build>
11+
<plugins>
12+
<plugin>
13+
<artifactId>maven-compiler-plugin</artifactId>
14+
<version>3.10.1</version>
15+
<configuration>
16+
<source>11</source>
17+
<target>11</target>
18+
<compilerArgument>-proc:none</compilerArgument>
19+
</configuration>
20+
</plugin>
21+
</plugins>
22+
</build>
23+
<dependencies>
24+
<dependency>
25+
<groupId>io.avaje</groupId>
26+
<artifactId>junit</artifactId>
27+
<version>1.1</version>
28+
<scope>test</scope>
29+
<exclusions>
30+
<exclusion>
31+
<artifactId>junit-jupiter-api</artifactId>
32+
<groupId>org.junit.jupiter</groupId>
33+
</exclusion>
34+
<exclusion>
35+
<artifactId>junit-jupiter-engine</artifactId>
36+
<groupId>org.junit.jupiter</groupId>
37+
</exclusion>
38+
<exclusion>
39+
<artifactId>assertj-core</artifactId>
40+
<groupId>org.assertj</groupId>
41+
</exclusion>
42+
<exclusion>
43+
<artifactId>mockito-core</artifactId>
44+
<groupId>org.mockito</groupId>
45+
</exclusion>
46+
</exclusions>
47+
</dependency>
48+
</dependencies>
49+
<properties>
50+
<java.version>11</java.version>
51+
</properties>
52+
</project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove from module-info all content after: // SHADED:

http-generator-client/src/main/java/io/avaje/http/generator/client/ClientProcessor.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@
88
import javax.annotation.processing.AbstractProcessor;
99
import javax.annotation.processing.ProcessingEnvironment;
1010
import javax.annotation.processing.RoundEnvironment;
11+
import javax.annotation.processing.SupportedAnnotationTypes;
1112
import javax.lang.model.SourceVersion;
1213
import javax.lang.model.element.AnnotationMirror;
1314
import javax.lang.model.element.AnnotationValue;
1415
import javax.lang.model.element.Element;
1516
import javax.lang.model.element.TypeElement;
1617

17-
import io.avaje.http.api.Client;
18+
import io.avaje.http.generator.core.ClientPrism;
1819
import io.avaje.http.generator.core.ControllerReader;
20+
import io.avaje.http.generator.core.ImportPrism;
1921
import io.avaje.http.generator.core.JsonBUtil;
2022
import io.avaje.http.generator.core.ProcessingContext;
21-
import io.avaje.prism.GeneratePrism;
2223

23-
@GeneratePrism(Client.class)
24+
@SupportedAnnotationTypes({ClientPrism.PRISM_TYPE, ImportPrism.PRISM_TYPE})
2425
public class ClientProcessor extends AbstractProcessor {
2526

26-
private static final String METAINF_SERVICES_PROVIDER = "META-INF/services/io.avaje.http.client.HttpApiProvider";
27+
private static final String METAINF_SERVICES_PROVIDER =
28+
"META-INF/services/io.avaje.http.client.HttpApiProvider";
2729

2830
private final Set<String> generatedClients = new LinkedHashSet<>();
2931

@@ -44,14 +46,6 @@ public SourceVersion getSupportedSourceVersion() {
4446
return SourceVersion.latest();
4547
}
4648

47-
@Override
48-
public Set<String> getSupportedAnnotationTypes() {
49-
final Set<String> annotations = new LinkedHashSet<>();
50-
annotations.add(Client.class.getCanonicalName());
51-
annotations.add(Client.Import.class.getCanonicalName());
52-
return annotations;
53-
}
54-
5549
@Override
5650
public synchronized void init(ProcessingEnvironment processingEnv) {
5751
super.init(processingEnv);
@@ -61,10 +55,12 @@ public synchronized void init(ProcessingEnvironment processingEnv) {
6155

6256
@Override
6357
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment round) {
64-
for (final Element controller : round.getElementsAnnotatedWith(Client.class)) {
58+
for (final Element controller :
59+
round.getElementsAnnotatedWith(ctx.typeElement(ClientPrism.PRISM_TYPE))) {
6560
writeClient(controller);
6661
}
67-
for (final Element importedElement : round.getElementsAnnotatedWith(Client.Import.class)) {
62+
for (final Element importedElement :
63+
round.getElementsAnnotatedWith(ctx.typeElement(ImportPrism.PRISM_TYPE))) {
6864
writeForImported(importedElement);
6965
}
7066
if (round.processingOver()) {
@@ -118,8 +114,8 @@ private void writeClient(Element controller) {
118114
}
119115
}
120116

121-
protected String writeClientAdapter(ProcessingContext ctx, ControllerReader reader) throws IOException {
117+
protected String writeClientAdapter(ProcessingContext ctx, ControllerReader reader)
118+
throws IOException {
122119
return new ClientWriter(reader, ctx, useJsonB).write();
123120
}
124-
125121
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
provides javax.annotation.processing.Processor with io.avaje.http.generator.client.ClientProcessor;
44

5+
requires java.compiler;
6+
7+
// SHADED: All content after this line will be removed at package time
58
requires transitive io.avaje.http.generator.core;
69

7-
requires java.compiler;
810
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<parent>
4+
<artifactId>avaje-http-parent</artifactId>
5+
<groupId>io.avaje</groupId>
6+
<version>1.26-SNAPSHOT</version>
7+
</parent>
8+
<modelVersion>4.0.0</modelVersion>
9+
<artifactId>avaje-http-generator-core</artifactId>
10+
<build>
11+
<plugins>
12+
<plugin>
13+
<artifactId>maven-compiler-plugin</artifactId>
14+
<configuration>
15+
<annotationProcessorPaths>
16+
<path>
17+
<groupId>io.avaje</groupId>
18+
<artifactId>avaje-prisms</artifactId>
19+
<version>1.3-SNAPSHOT</version>
20+
</path>
21+
</annotationProcessorPaths>
22+
</configuration>
23+
</plugin>
24+
</plugins>
25+
</build>
26+
<dependencies>
27+
<dependency>
28+
<groupId>io.avaje</groupId>
29+
<artifactId>avaje-prisms</artifactId>
30+
<version>1.3-SNAPSHOT</version>
31+
<scope>provided</scope>
32+
<optional>true</optional>
33+
</dependency>
34+
<dependency>
35+
<groupId>io.avaje</groupId>
36+
<artifactId>avaje-http-api</artifactId>
37+
<version>1.26-SNAPSHOT</version>
38+
<scope>provided</scope>
39+
<optional>true</optional>
40+
</dependency>
41+
<dependency>
42+
<groupId>jakarta.validation</groupId>
43+
<artifactId>jakarta.validation-api</artifactId>
44+
<version>3.0.2</version>
45+
<scope>provided</scope>
46+
<optional>true</optional>
47+
</dependency>
48+
<dependency>
49+
<groupId>javax.validation</groupId>
50+
<artifactId>validation-api</artifactId>
51+
<version>2.0.1.Final</version>
52+
<scope>provided</scope>
53+
<optional>true</optional>
54+
</dependency>
55+
<dependency>
56+
<groupId>jakarta.inject</groupId>
57+
<artifactId>jakarta.inject-api</artifactId>
58+
<version>2.0.1</version>
59+
<scope>provided</scope>
60+
<optional>true</optional>
61+
</dependency>
62+
<dependency>
63+
<groupId>io.swagger.core.v3</groupId>
64+
<artifactId>swagger-annotations</artifactId>
65+
<version>2.0.8</version>
66+
<scope>provided</scope>
67+
<optional>true</optional>
68+
</dependency>
69+
<dependency>
70+
<groupId>io.avaje</groupId>
71+
<artifactId>junit</artifactId>
72+
<version>1.1</version>
73+
<scope>test</scope>
74+
<exclusions>
75+
<exclusion>
76+
<artifactId>junit-jupiter-api</artifactId>
77+
<groupId>org.junit.jupiter</groupId>
78+
</exclusion>
79+
<exclusion>
80+
<artifactId>junit-jupiter-engine</artifactId>
81+
<groupId>org.junit.jupiter</groupId>
82+
</exclusion>
83+
<exclusion>
84+
<artifactId>assertj-core</artifactId>
85+
<groupId>org.assertj</groupId>
86+
</exclusion>
87+
<exclusion>
88+
<artifactId>mockito-core</artifactId>
89+
<groupId>org.mockito</groupId>
90+
</exclusion>
91+
</exclusions>
92+
</dependency>
93+
</dependencies>
94+
<properties>
95+
<swagger.version>2.0.8</swagger.version>
96+
</properties>
97+
</project>

http-generator-core/pom.xml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,34 @@
1818
<dependencies>
1919

2020

21-
<dependency>
21+
<dependency>
2222
<groupId>io.avaje</groupId>
2323
<artifactId>avaje-prisms</artifactId>
2424
<version>1.3-SNAPSHOT</version>
25+
<optional>true</optional>
2526
<scope>provided</scope>
2627
</dependency>
28+
29+
<dependency>
30+
<groupId>io.avaje</groupId>
31+
<artifactId>avaje-http-api</artifactId>
32+
<version>1.26-SNAPSHOT</version>
33+
<optional>true</optional>
34+
<scope>provided</scope>
35+
</dependency>
36+
37+
<dependency>
38+
<groupId>io.swagger.core.v3</groupId>
39+
<artifactId>swagger-models</artifactId>
40+
<version>${swagger.version}</version>
41+
<exclusions>
42+
<exclusion>
43+
<groupId>com.fasterxml.jackson.core</groupId>
44+
<artifactId>jackson-annotations</artifactId>
45+
</exclusion>
46+
</exclusions>
47+
</dependency>
48+
2749
<dependency>
2850
<groupId>jakarta.validation</groupId>
2951
<artifactId>jakarta.validation-api</artifactId>
@@ -48,20 +70,6 @@
4870
<scope>provided</scope>
4971
</dependency>
5072

51-
<dependency>
52-
<groupId>io.avaje</groupId>
53-
<artifactId>avaje-http-api</artifactId>
54-
<version>1.26-SNAPSHOT</version>
55-
<scope>provided</scope>
56-
</dependency>
57-
58-
<dependency>
59-
<groupId>io.swagger.core.v3</groupId>
60-
<artifactId>swagger-models</artifactId>
61-
<version>${swagger.version}</version>
62-
<optional>true</optional>
63-
<scope>provided</scope>
64-
</dependency>
6573

6674
<dependency>
6775
<groupId>io.swagger.core.v3</groupId>
@@ -75,6 +83,7 @@
7583

7684
<build>
7785
<plugins>
86+
7887
<plugin>
7988
<groupId>org.apache.maven.plugins</groupId>
8089
<artifactId>maven-compiler-plugin</artifactId>
@@ -91,5 +100,4 @@
91100
</plugins>
92101
</build>
93102

94-
95103
</project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove from module-info all content after: // SHADED:

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public SourceVersion getSupportedSourceVersion() {
2323
return SourceVersion.latest();
2424
}
2525

26+
@Override
27+
public Set<String> getSupportedAnnotationTypes() {
28+
return Set.of(ControllerPrism.PRISM_TYPE, OpenAPIDefinitionPrism.PRISM_TYPE);
29+
}
30+
2631
@Override
2732
public synchronized void init(ProcessingEnvironment processingEnv) {
2833
super.init(processingEnv);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ private List<OpenAPIResponsePrism> buildApiResponses() {
6767
}
6868

6969
private void buildApiResponsesFor(Element element, ArrayList<OpenAPIResponsePrism> responses) {
70-
Optional.ofNullable(OpenAPIResponsesPrism.getInstanceOn(element)).stream()
70+
71+
OpenAPIResponsesPrism.getOptionalOn(element).stream()
7172
.map(OpenAPIResponsesPrism::value)
7273
.flatMap(List::stream)
7374
.forEach(responses::add);

http-generator-core/src/main/java/io/avaje/http/generator/core/openapi/MethodDocBuilder.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package io.avaje.http.generator.core.openapi;
22

3-
import javax.lang.model.type.MirroredTypeException;
4-
import javax.lang.model.type.TypeMirror;
5-
63
import io.avaje.http.generator.core.HiddenPrism;
74
import io.avaje.http.generator.core.MethodParam;
85
import io.avaje.http.generator.core.MethodReader;
@@ -100,13 +97,7 @@ public void build() {
10097
newResponse.setContent(response.getContent());
10198
override2xx = !hasProducesStatus;
10299
}
103-
TypeMirror returnType = null;
104-
try {
105-
// this will always throw
106-
responseAnnotation.type();
107-
} catch (final MirroredTypeException mte) {
108-
returnType = mte.getTypeMirror();
109-
}
100+
final var returnType = responseAnnotation.type();
110101

111102
if (!"java.lang.Void".equals(returnType.toString())) {
112103
newResponse.setContent(ctx.createContent(returnType, contentMediaType));

0 commit comments

Comments
 (0)