From 6e7f175faaeb3bcc047372cd489eb65154d180ad Mon Sep 17 00:00:00 2001 From: Hugo Mercado Date: Sun, 15 Aug 2021 14:23:38 -0500 Subject: [PATCH] added java 11 support to java generators --- .../generators/java/AbstractJavaCodegen.java | 17 +++++++---- .../v3/generators/java/SpringCodegen.java | 18 +++++++++-- .../Java/libraries/feign/auth/OAuth.mustache | 6 ++-- .../Java/libraries/feign/pom.mustache | 22 ++++++++++++-- .../Java/libraries/okhttp-gson/pom.mustache | 18 ++++++++++- .../Java/libraries/resttemplate/pom.mustache | 16 ++++++++++ .../Java/libraries/retrofit/pom.mustache | 16 ++++++++++ .../Java/libraries/retrofit2/pom.mustache | 18 ++++++++++- .../resources/handlebars/Java/pom.mustache | 16 ++++++++++ .../handlebars/JavaInflector/pom.mustache | 4 +++ .../handlebars/JavaJaxRS/cxf-cdi/pom.mustache | 7 +++++ .../handlebars/JavaJaxRS/cxf/pom.mustache | 2 +- .../JavaJaxRS/cxf/server/pom.mustache | 2 +- .../JavaJaxRS/libraries/jersey1/pom.mustache | 2 +- .../handlebars/JavaJaxRS/pom.mustache | 2 +- .../JavaJaxRS/resteasy/eap/pom.mustache | 4 +-- .../JavaJaxRS/resteasy/pom.mustache | 4 +-- .../handlebars/JavaJaxRS/spec/pom.mustache | 22 ++++++++++++++ .../handlebars/JavaSpring/api.mustache | 6 ++-- .../JavaSpring/apiController.mustache | 12 ++++---- .../JavaSpring/apiDelegate.mustache | 30 +++++++++---------- .../libraries/spring-boot/pom.mustache | 20 ++++++++++++- .../libraries/spring-cloud/pom.mustache | 2 +- .../libraries/spring-mvc/pom.mustache | 20 ++++++++++++- 24 files changed, 234 insertions(+), 52 deletions(-) diff --git a/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java index 6b02a27fbd..e5452c30ec 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java @@ -54,6 +54,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegenConfig { public static final String DEFAULT_LIBRARY = ""; public static final String DATE_LIBRARY = "dateLibrary"; public static final String JAVA8_MODE = "java8"; + public static final String JAVA11_MODE = "java11"; public static final String WITH_XML = "withXml"; public static final String SUPPORT_JAVA6 = "supportJava6"; public static final String ERROR_ON_UNKNOWN_ENUM = "errorOnUnknownEnum"; @@ -61,6 +62,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegenConfig { protected String dateLibrary = "threetenbp"; protected boolean java8Mode = false; + protected boolean java11Mode = false; protected boolean withXml = false; protected String invokerPackage = "io.swagger"; protected String groupId = "io.swagger"; @@ -165,6 +167,7 @@ public AbstractJavaCodegen() { CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use"); Map dateOptions = new HashMap(); dateOptions.put("java8", "Java 8 native JSR310 (preferred for jdk 1.8+) - note: this also sets \"" + JAVA8_MODE + "\" to true"); + dateOptions.put("java11", "Java 11 native JSR384 (preferred for jdk 11+) - note: this also sets \"" + JAVA11_MODE + "\" to true"); dateOptions.put("threetenbp", "Backport of JSR310 (preferred for jdk < 1.8)"); dateOptions.put("java8-localdatetime", "Java 8 using LocalDateTime (for legacy app only)"); dateOptions.put("joda", "Joda (for legacy app only)"); @@ -424,12 +427,10 @@ public void processOpts() { // used later in recursive import in postProcessingModels importMapping.put("com.fasterxml.jackson.annotation.JsonProperty", "com.fasterxml.jackson.annotation.JsonCreator"); - if(additionalProperties.containsKey(JAVA8_MODE)) { - setJava8Mode(Boolean.parseBoolean(additionalProperties.get(JAVA8_MODE).toString())); - if ( java8Mode ) { - additionalProperties.put("java8", true); - } - } + setJava8Mode(Boolean.parseBoolean(String.valueOf(additionalProperties.get(JAVA8_MODE)))); + additionalProperties.put(JAVA8_MODE, java8Mode); + setJava11Mode(Boolean.parseBoolean(String.valueOf(additionalProperties.get(JAVA11_MODE)))); + additionalProperties.put(JAVA11_MODE, java11Mode); if(additionalProperties.containsKey(WITH_XML)) { setWithXml(Boolean.parseBoolean(additionalProperties.get(WITH_XML).toString())); @@ -1538,6 +1539,10 @@ public void setJava8Mode(boolean enabled) { this.java8Mode = enabled; } + public void setJava11Mode(boolean java11Mode) { + this.java11Mode = java11Mode; + } + @Override public String escapeQuotationMark(String input) { // remove " to avoid code injection diff --git a/src/main/java/io/swagger/codegen/v3/generators/java/SpringCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/java/SpringCodegen.java index c77711db1a..46e1b0327b 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/java/SpringCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/java/SpringCodegen.java @@ -68,6 +68,7 @@ public class SpringCodegen extends AbstractJavaCodegen implements BeanValidation protected boolean delegateMethod = false; protected boolean singleContentTypes = false; protected boolean java8 = false; + protected boolean java11 = false; protected boolean async = false; protected String responseWrapper = ""; protected boolean useTags = false; @@ -181,10 +182,19 @@ public void processOpts() { if (!additionalProperties.containsKey(DATE_LIBRARY)) { setDateLibrary("java8"); } - } else { - this.defaultInterfaces = false; } + if (additionalProperties.containsKey(JAVA11_MODE)) { + this.setJava11(Boolean.valueOf(additionalProperties.get(JAVA11_MODE).toString())); + } + if (this.java11) { + additionalProperties.put("javaVersion", "11"); + additionalProperties.put("jdk11", "true"); + } + + additionalProperties.put("isJava8or11", this.java8 || this.java11); + this.defaultInterfaces = !(this.java8 || this.java11); + // set invokerPackage as basePackage if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { this.setBasePackage((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); @@ -383,7 +393,7 @@ public void processOpts() { } } - if ((!this.delegatePattern && this.java8) || this.delegateMethod) { + if ((!this.delegatePattern && (this.java8 || this.java11)) || this.delegateMethod) { additionalProperties.put("jdk8-no-delegate", true); } @@ -800,6 +810,8 @@ public void setSingleContentTypes(boolean singleContentTypes) { public void setJava8(boolean java8) { this.java8 = java8; } + public void setJava11(boolean java11) { this.java11 = java11; } + public void setAsync(boolean async) { this.async = async; } public void setResponseWrapper(String responseWrapper) { this.responseWrapper = responseWrapper; } diff --git a/src/main/resources/handlebars/Java/libraries/feign/auth/OAuth.mustache b/src/main/resources/handlebars/Java/libraries/feign/auth/OAuth.mustache index 6be36b5b91..ede95edce7 100644 --- a/src/main/resources/handlebars/Java/libraries/feign/auth/OAuth.mustache +++ b/src/main/resources/handlebars/Java/libraries/feign/auth/OAuth.mustache @@ -87,19 +87,19 @@ public class OAuth implements RequestInterceptor { } // If first time, get the token if (expirationTimeMillis == null || System.currentTimeMillis() >= expirationTimeMillis) { - updateAccessToken(); + updateAccessToken(template); } if (getAccessToken() != null) { template.header("Authorization", "Bearer " + getAccessToken()); } } - public synchronized void updateAccessToken() { + public synchronized void updateAccessToken(RequestTemplate template) { OAuthJSONAccessTokenResponse accessTokenResponse; try { accessTokenResponse = oauthClient.accessToken(tokenRequestBuilder.buildBodyMessage()); } catch (Exception e) { - throw new RetryableException(e.getMessage(), e,null); + throw new RetryableException(400, e.getMessage(), template.request().httpMethod(), e, null, template.request()); } if (accessTokenResponse != null && accessTokenResponse.getAccessToken() != null) { setAccessToken(accessTokenResponse.getAccessToken(), accessTokenResponse.getExpiresIn()); diff --git a/src/main/resources/handlebars/Java/libraries/feign/pom.mustache b/src/main/resources/handlebars/Java/libraries/feign/pom.mustache index b6d531a652..ce23b76f21 100644 --- a/src/main/resources/handlebars/Java/libraries/feign/pom.mustache +++ b/src/main/resources/handlebars/Java/libraries/feign/pom.mustache @@ -165,6 +165,22 @@ + {{#java11}} + + jdk11 + + [11,) + + + + com.sun.xml.ws + jaxws-rt + 2.3.3 + pom + + + + {{/java11}} @@ -279,7 +295,7 @@ - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} + {{#java11}}11{{/java11}}{{^java11}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/java11}} ${java.version} ${java.version} {{#useOas2}} @@ -288,8 +304,8 @@ {{^useOas2}} 2.0.0 {{/useOas2}} - 9.4.0 - 2.1.0 + 11.6 + 3.8.0 2.10.1 {{#threetenbp}} 2.6.4 diff --git a/src/main/resources/handlebars/Java/libraries/okhttp-gson/pom.mustache b/src/main/resources/handlebars/Java/libraries/okhttp-gson/pom.mustache index d9a8887cdf..356b0d76c2 100644 --- a/src/main/resources/handlebars/Java/libraries/okhttp-gson/pom.mustache +++ b/src/main/resources/handlebars/Java/libraries/okhttp-gson/pom.mustache @@ -166,6 +166,22 @@ + {{#java11}} + + jdk11 + + [11,) + + + + com.sun.xml.ws + jaxws-rt + 2.3.3 + pom + + + + {{/java11}} @@ -276,7 +292,7 @@ - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} + {{#java11}}11{{/java11}}{{^java11}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/java11}} ${java.version} ${java.version} {{#useOas2}} diff --git a/src/main/resources/handlebars/Java/libraries/resttemplate/pom.mustache b/src/main/resources/handlebars/Java/libraries/resttemplate/pom.mustache index e032df8d00..df731f2dbd 100644 --- a/src/main/resources/handlebars/Java/libraries/resttemplate/pom.mustache +++ b/src/main/resources/handlebars/Java/libraries/resttemplate/pom.mustache @@ -181,6 +181,22 @@ + {{#java11}} + + jdk11 + + [11,) + + + + com.sun.xml.ws + jaxws-rt + 2.3.3 + pom + + + + {{/java11}} diff --git a/src/main/resources/handlebars/Java/libraries/retrofit/pom.mustache b/src/main/resources/handlebars/Java/libraries/retrofit/pom.mustache index cbeada35bd..dadf9a22c5 100644 --- a/src/main/resources/handlebars/Java/libraries/retrofit/pom.mustache +++ b/src/main/resources/handlebars/Java/libraries/retrofit/pom.mustache @@ -174,6 +174,22 @@ + {{#java11}} + + jdk11 + + [11,) + + + + com.sun.xml.ws + jaxws-rt + 2.3.3 + pom + + + + {{/java11}} diff --git a/src/main/resources/handlebars/Java/libraries/retrofit2/pom.mustache b/src/main/resources/handlebars/Java/libraries/retrofit2/pom.mustache index a9da7810fe..fc60a4f0f0 100644 --- a/src/main/resources/handlebars/Java/libraries/retrofit2/pom.mustache +++ b/src/main/resources/handlebars/Java/libraries/retrofit2/pom.mustache @@ -166,6 +166,22 @@ + {{#java11}} + + jdk11 + + [11,) + + + + com.sun.xml.ws + jaxws-rt + 2.3.3 + pom + + + + {{/java11}} @@ -323,7 +339,7 @@ UTF-8 - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} + {{#java11}}11{{/java11}}{{^java11}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/java11}} ${java.version} ${java.version} 1.8.0 diff --git a/src/main/resources/handlebars/Java/pom.mustache b/src/main/resources/handlebars/Java/pom.mustache index 805fe40a9e..abc6c554d2 100644 --- a/src/main/resources/handlebars/Java/pom.mustache +++ b/src/main/resources/handlebars/Java/pom.mustache @@ -181,6 +181,22 @@ + {{#java11}} + + jdk11 + + [11,) + + + + com.sun.xml.ws + jaxws-rt + 2.3.3 + pom + + + + {{/java11}} diff --git a/src/main/resources/handlebars/JavaInflector/pom.mustache b/src/main/resources/handlebars/JavaInflector/pom.mustache index a79dd4344c..dabf47f8cf 100644 --- a/src/main/resources/handlebars/JavaInflector/pom.mustache +++ b/src/main/resources/handlebars/JavaInflector/pom.mustache @@ -117,6 +117,10 @@ + {{#java11}} + 11 + 11 + {{/java11}} UTF-8 1.0.0 9.4.9.v20180320 diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pom.mustache index 070c9f7c2b..9851b195cb 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pom.mustache @@ -98,4 +98,11 @@ + {{#java11}} + + 11 + 11 + + {{/java11}} + diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/pom.mustache index 0a91a003b2..78c26d56ac 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/pom.mustache @@ -215,7 +215,7 @@ - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} + {{#java11}}11{{/java11}}{{^java11}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/java11}} ${java.version} ${java.version} {{#useOas2}} diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/server/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/server/pom.mustache index 467e58218d..88b8cf8ab0 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/server/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/server/pom.mustache @@ -276,7 +276,7 @@ - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} + {{#java11}}11{{/java11}}{{^java11}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/java11}} ${java.version} ${java.version} {{#useOas2}} diff --git a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/pom.mustache index 6936dc4a31..4c03cfddc7 100644 --- a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/pom.mustache @@ -197,7 +197,7 @@ - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} + {{#java11}}11{{/java11}}{{^java11}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/java11}} ${java.version} ${java.version} 1.5.18 diff --git a/src/main/resources/handlebars/JavaJaxRS/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/pom.mustache index a20ab5d228..6888f74e55 100644 --- a/src/main/resources/handlebars/JavaJaxRS/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/pom.mustache @@ -223,7 +223,7 @@ - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} + {{#java11}}11{{/java11}}{{^java11}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/java11}} ${java.version} ${java.version} {{#useOas2}} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pom.mustache index 3d7a8bff75..2b3e981440 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pom.mustache @@ -14,8 +14,8 @@ maven-compiler-plugin 3.6.1 - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} + {{#java11}}11{{/java11}}{{^java11}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/java11}} + {{#java11}}11{{/java11}}{{^java11}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/java11}} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/pom.mustache index 46373c555c..70a6016cfe 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/pom.mustache @@ -14,8 +14,8 @@ maven-compiler-plugin 3.6.1 - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} + {{#java11}}11{{/java11}}{{^java11}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/java11}} + {{#java11}}11{{/java11}}{{^java11}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/java11}} diff --git a/src/main/resources/handlebars/JavaJaxRS/spec/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/spec/pom.mustache index 049ba9dc6e..4a8e89beb4 100644 --- a/src/main/resources/handlebars/JavaJaxRS/spec/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/spec/pom.mustache @@ -35,6 +35,24 @@ {{/interfaceOnly}} + {{#java11}} + + + jdk11 + + [11,) + + + + com.sun.xml.ws + jaxws-rt + 2.3.3 + pom + + + + + {{/java11}} javax.ws.rs @@ -95,6 +113,10 @@ {{/useBeanValidation}} + {{#java11}} + 11 + 11 + {{/java11}} 4.13.1 diff --git a/src/main/resources/handlebars/JavaSpring/api.mustache b/src/main/resources/handlebars/JavaSpring/api.mustache index a14b7666bc..9df639dbd9 100644 --- a/src/main/resources/handlebars/JavaSpring/api.mustache +++ b/src/main/resources/handlebars/JavaSpring/api.mustache @@ -64,7 +64,7 @@ import java.util.Optional; {{/useOptional}} {{/jdk8-no-delegate}} {{#async}} -import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}}; +import java.util.concurrent.{{^isJava8or11}}Callable{{/isJava8or11}}{{#isJava8or11}}CompletableFuture{{/isJava8or11}}; {{/async}} {{>generatedAnnotation}} @@ -76,7 +76,7 @@ import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture {{/useOas2}} {{#operations}} public interface {{classname}} { -{{#jdk8}} +{{#isJava8or11}} {{^isDelegate}} Logger log = LoggerFactory.getLogger({{classname}}.class); @@ -96,7 +96,7 @@ public interface {{classname}} { {{#isDelegate}} {{classname}}Delegate getDelegate(); {{/isDelegate}} -{{/jdk8}} +{{/isJava8or11}} {{#operation}} {{#contents}} {{#@first}} diff --git a/src/main/resources/handlebars/JavaSpring/apiController.mustache b/src/main/resources/handlebars/JavaSpring/apiController.mustache index 812bf53fd9..4d07255f72 100644 --- a/src/main/resources/handlebars/JavaSpring/apiController.mustache +++ b/src/main/resources/handlebars/JavaSpring/apiController.mustache @@ -47,9 +47,9 @@ import javax.validation.Valid; {{/fullController}} {{^isDelegate}} import javax.servlet.http.HttpServletRequest; - {{#jdk8}} + {{#isJava8or11}} import java.util.Optional; - {{/jdk8}} + {{/isJava8or11}} {{/isDelegate}} {{^jdk8-no-delegate}} {{#useOptional}} @@ -84,13 +84,13 @@ public class {{classname}}Controller implements {{classname}} { public {{classname}}Controller({{classname}}Delegate delegate) { this.delegate = delegate; } - {{#jdk8}} + {{#isJava8or11}} @Override public {{classname}}Delegate getDelegate() { return delegate; } - {{/jdk8}} + {{/isJava8or11}} {{/isDelegate}} {{^isDelegate}} {{#fullController}} @@ -106,7 +106,7 @@ public class {{classname}}Controller implements {{classname}} { this.objectMapper = objectMapper; this.request = request; } - {{#jdk8}} + {{#isJava8or11}} @Override public Optional getObjectMapper() { @@ -117,7 +117,7 @@ public class {{classname}}Controller implements {{classname}} { public Optional getRequest() { return Optional.ofNullable(request); } - {{/jdk8}} + {{/isJava8or11}} {{/isDelegate}} {{#fullController}} diff --git a/src/main/resources/handlebars/JavaSpring/apiDelegate.mustache b/src/main/resources/handlebars/JavaSpring/apiDelegate.mustache index 884352a081..6c752ac7d1 100644 --- a/src/main/resources/handlebars/JavaSpring/apiDelegate.mustache +++ b/src/main/resources/handlebars/JavaSpring/apiDelegate.mustache @@ -2,9 +2,9 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} -{{#jdk8}} +{{#isJava8or11}} import com.fasterxml.jackson.databind.ObjectMapper; -{{/jdk8}} +{{/isJava8or11}} {{#useOas2}} import io.swagger.annotations.*; {{/useOas2}} @@ -18,32 +18,32 @@ import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.security.SecurityRequirement; {{/useOas2}} -{{#jdk8}} +{{#isJava8or11}} import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; -{{/jdk8}} +{{/isJava8or11}} import org.springframework.http.ResponseEntity; import org.springframework.web.multipart.MultipartFile; -{{#jdk8}} +{{#isJava8or11}} import java.io.IOException; -{{/jdk8}} +{{/isJava8or11}} -{{#jdk8}} +{{#isJava8or11}} import javax.servlet.http.HttpServletRequest; -{{/jdk8}} +{{/isJava8or11}} import java.util.List; import java.util.Map; -{{#jdk8}} +{{#isJava8or11}} import java.util.Optional; -{{/jdk8}} -{{^jdk8}} +{{/isJava8or11}} +{{^isJava8or11}} {{#useOptional}} import java.util.Optional; {{/useOptional}} -{{/jdk8}} +{{/isJava8or11}} {{#async}} -import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture{{/jdk8}}; +import java.util.concurrent.{{^isJava8or11}}Callable{{/isJava8or11}}{{#isJava8or11}}CompletableFuture{{/isJava8or11}}; {{/async}} {{#operations}} @@ -53,7 +53,7 @@ import java.util.concurrent.{{^jdk8}}Callable{{/jdk8}}{{#jdk8}}CompletableFuture */ {{>generatedAnnotation}} public interface {{classname}}Delegate { -{{#jdk8}} +{{#isJava8or11}} Logger log = LoggerFactory.getLogger({{classname}}.class); @@ -68,7 +68,7 @@ public interface {{classname}}Delegate { {{#defaultInterfaces}}default Optional getAcceptHeader() { return getRequest().map(r -> r.getHeader("Accept")); }{{/defaultInterfaces}} -{{/jdk8}} +{{/isJava8or11}} {{#operation}} {{#contents}} diff --git a/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/pom.mustache b/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/pom.mustache index 9e6a9e515e..12dd3f92dd 100644 --- a/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/pom.mustache +++ b/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/pom.mustache @@ -6,7 +6,7 @@ {{artifactId}} {{artifactVersion}} - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} + {{#java11}}11{{/java11}}{{^java11}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/java11}} ${java.version} ${java.version} {{#useOas2}} @@ -44,6 +44,24 @@ {{/interfaceOnly}} + {{#java11}} + + + jdk11 + + [11,) + + + + com.sun.xml.ws + jaxws-rt + 2.3.3 + pom + + + + + {{/java11}} org.springframework.boot diff --git a/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/pom.mustache b/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/pom.mustache index ec0c8eeab3..3290451339 100644 --- a/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/pom.mustache +++ b/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/pom.mustache @@ -6,7 +6,7 @@ {{artifactId}} {{artifactVersion}} - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} + {{#java11}}11{{/java11}}{{^java11}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/java11}} ${java.version} ${java.version} {{#useOas2}} diff --git a/src/main/resources/handlebars/JavaSpring/libraries/spring-mvc/pom.mustache b/src/main/resources/handlebars/JavaSpring/libraries/spring-mvc/pom.mustache index 46ab3155bc..4d85d3a3b9 100644 --- a/src/main/resources/handlebars/JavaSpring/libraries/spring-mvc/pom.mustache +++ b/src/main/resources/handlebars/JavaSpring/libraries/spring-mvc/pom.mustache @@ -65,6 +65,24 @@ + {{#java11}} + + + jdk11 + + [11,) + + + + com.sun.xml.ws + jaxws-rt + 2.3.3 + pom + + + + + {{/java11}} org.slf4j @@ -206,7 +224,7 @@ - {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} + {{#java11}}11{{/java11}}{{^java11}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/java11}} ${java.version} ${java.version} 9.3.28.v20191105