Skip to content

Commit

Permalink
add jakarta implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyro-Ing committed Dec 26, 2022
1 parent 052511a commit 0bc7a1e
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 17 deletions.
7 changes: 7 additions & 0 deletions src/main/resources/handlebars/JavaMicronaut/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

{{#useBeanValidation}}
{{#jakarta}}
import jakarta.annotation.Nullable;
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
{{/jakarta}}
{{^jakarta}}
import javax.annotation.Nullable;
import javax.validation.Valid;
import javax.validation.constraints.*;
{{/jakarta}}
{{/useBeanValidation}}
import java.io.IOException;
import java.util.List;
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/handlebars/JavaMicronaut/api_test.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import io.micronaut.http.HttpStatus;
import io.micronaut.test.annotation.MicronautTest;
import org.junit.jupiter.api.Test;

{{#jakarta}}
import jakarta.inject.Inject;
{{/jakarta}}
{{^jakarta}}
import javax.inject.Inject;
{{/jakarta}}

import java.util.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{{^hideGenerationTimestamp}}
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
{{/hideGenerationTimestamp}}
{{^hideGenerationTimestamp}}@{{#jakarta}}jakarta{{/jakarta}}{{^jakarta}}javax{{/jakarta}}.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}}
11 changes: 11 additions & 0 deletions src/main/resources/handlebars/JavaMicronaut/model.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ import java.io.Serializable;
{{/serializableModel}}
{{#useBeanValidation}}
import io.micronaut.validation.Validated;
{{#jakarta}}
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
{{/jakarta}}
{{^jakarta}}
import javax.validation.Valid;
import javax.validation.constraints.*;
{{/jakarta}}
{{/useBeanValidation}}
{{#jackson}}
{{#withXml}}
Expand All @@ -18,7 +24,12 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
{{/withXml}}
{{/jackson}}
{{#withXml}}
{{#jakarta}}
import jakarta.xml.bind.annotation.*;
{{/jakarta}}
{{^jakarta}}
import javax.xml.bind.annotation.*;
{{/jakarta}}
{{/withXml}}

{{#models}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import io.micronaut.http.HttpStatus;
import io.micronaut.http.annotation.Produces;
import io.micronaut.http.server.exceptions.ExceptionHandler;

{{#jakarta}}
import jakarta.inject.Singleton;
{{/jakarta}}
{{^jakarta}}
import javax.inject.Singleton;
{{/jakarta}}

@Produces
@Singleton
Expand All @@ -19,4 +24,4 @@ public class UnsupportedOperationExceptionHandler implements ExceptionHandler<Un
public HttpResponse handle(HttpRequest request, UnsupportedOperationException exception) {
return HttpResponse.status(HttpStatus.NOT_IMPLEMENTED);
}
}
}
6 changes: 6 additions & 0 deletions src/main/resources/handlebars/JavaSpring/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ import org.springframework.web.bind.annotation.CookieValue;
import javax.servlet.http.HttpServletRequest;
{{/jdk8-no-delegate}}
{{#useBeanValidation}}
{{#jakarta}}
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
{{/jakarta}}
{{^jakarta}}
import javax.validation.Valid;
import javax.validation.constraints.*;
{{/jakarta}}
{{/useBeanValidation}}
{{#jdk8-no-delegate}}
import java.io.IOException;
Expand Down
10 changes: 8 additions & 2 deletions src/main/resources/handlebars/JavaSpring/apiController.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

{{#useBeanValidation}}
import javax.validation.constraints.*;
import javax.validation.Valid;
{{#jakarta}}
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
{{/jakarta}}
{{^jakarta}}
import javax.validation.Valid;
import javax.validation.constraints.*;
{{/jakarta}}
{{/useBeanValidation}}
{{/fullController}}
{{^isDelegate}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ package {{apiPackage}};

import java.io.IOException;

{{#jakarta}}
import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletResponse;
{{/jakarta}}
{{^jakarta}}
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
{{/jakarta}}

{{>generatedAnnotation}}
public class ApiOriginFilter implements javax.servlet.Filter {
public class ApiOriginFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
package {{apiPackage}};

{{#jakarta}}
import jakarta.xml.bind.annotation.XmlTransient;
{{/jakarta}}
{{^jakarta}}
import javax.xml.bind.annotation.XmlTransient;
{{/jakarta}}

{{>generatedAnnotation}}
{{#jakarta}}
@jakarta.xml.bind.annotation.XmlRootElement
{{/jakarta}}
{{^jakarta}}
@javax.xml.bind.annotation.XmlRootElement
{{/jakarta}}
public class ApiResponseMessage {
public static final int ERROR = 1;
public static final int WARNING = 2;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
{{^hideGenerationTimestamp}}
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
{{/hideGenerationTimestamp}}
{{^hideGenerationTimestamp}}@{{#jakarta}}jakarta{{/jakarta}}{{^jakarta}}javax{{/jakarta}}.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}}
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@

<!-- Bean Validation API support -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>
{{/useBeanValidation}}
{{#notNullJacksonAnnotation}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@
{{#useBeanValidation}}
<!-- Bean Validation API support -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>{{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}}</version>
<scope>provided</scope>
</dependency>
{{/useBeanValidation}}
Expand All @@ -132,12 +132,21 @@
<version>2.10.1</version>
</dependency>
{{/notNullJacksonAnnotation}}


{{#jakarta}}
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta-api</artifactId>
<scope>provided</scope>
</dependency>
{{/jakarta}}
{{^jakarta}}
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
{{/jakarta}}
{{#wiremock}}
<dependency>
<groupId>com.github.tomakehurst</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,20 @@
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
{{#jakarta}}
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta-api</artifactId>
<version>${servlet-api-version}</version>
</dependency>
{{/jakarta}}
{{^jakarta}}
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api-version}</version>
</dependency>
{{/jakarta}}
{{#useBeanValidation}}
<!-- Bean Validation API support -->
<dependency>
Expand Down Expand Up @@ -230,7 +239,7 @@
<jetty-version>9.3.28.v20191105</jetty-version>
<slf4j-version>1.7.21</slf4j-version>
<junit-version>4.13.1</junit-version>
<servlet-api-version>2.5</servlet-api-version>
<servlet-api-version>{{#jakarta}}6.0.0{{/jakarta}}{{^jakarta}}3.1.0{{/jakarta}}</servlet-api-version>
{{#useOas2}}
<springfox-version>2.9.2</springfox-version>
{{/useOas2}}
Expand Down
11 changes: 11 additions & 0 deletions src/main/resources/handlebars/JavaSpring/model.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ import java.io.Serializable;
{{/serializableModel}}
{{#useBeanValidation}}
import org.springframework.validation.annotation.Validated;
{{#jakarta}}
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
{{/jakarta}}
{{^jakarta}}
import javax.validation.Valid;
import javax.validation.constraints.*;
{{/jakarta}}
{{/useBeanValidation}}
{{#jackson}}
{{#withXml}}
Expand All @@ -19,7 +25,12 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
{{/withXml}}
{{/jackson}}
{{#withXml}}
{{#jakarta}}
import jakarta.xml.bind.annotation.*;
{{/jakarta}}
{{^jakarta}}
import javax.xml.bind.annotation.*;
{{/jakarta}}
{{/withXml}}
{{/x-is-composed-model}}

Expand Down

0 comments on commit 0bc7a1e

Please sign in to comment.