From a123dd7ef1866c3036ce18bdcc7fb8438dd2eed2 Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 7 Feb 2017 17:52:47 +0800 Subject: [PATCH] Revert "rx2 support" (#4737) --- .../codegen/languages/JavaClientCodegen.java | 27 ++----------------- .../libraries/retrofit2/ApiClient.mustache | 2 -- .../Java/libraries/retrofit2/api.mustache | 5 ++-- .../libraries/retrofit2/build.gradle.mustache | 7 ----- .../libraries/retrofit2/build.sbt.mustache | 4 --- .../Java/libraries/retrofit2/pom.mustache | 15 ----------- .../options/JavaClientOptionsProvider.java | 1 - 7 files changed, 4 insertions(+), 57 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 84426f0271c..ab4345f997a 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -20,8 +20,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen private static final Logger LOGGER = LoggerFactory.getLogger(JavaClientCodegen.class); public static final String USE_RX_JAVA = "useRxJava"; - public static final String USE_RX_JAVA2 = "useRxJava2"; - public static final String DO_NOT_USE_RX = "doNotUseRx"; public static final String USE_PLAY24_WS = "usePlay24WS"; public static final String PARCELABLE_MODEL = "parcelableModel"; @@ -30,8 +28,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen protected String gradleWrapperPackage = "gradle.wrapper"; protected boolean useRxJava = false; - protected boolean useRxJava2 = false; - protected boolean doNotUseRx = true; // backwards compatibility for swagger configs that specify neither rx1 nor rx2 (mustache does not allow for boolean operators so we need this extra field) protected boolean usePlay24WS = false; protected boolean parcelableModel = false; protected boolean useBeanValidation = false; @@ -47,7 +43,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen modelPackage = "io.swagger.client.model"; cliOptions.add(CliOption.newBoolean(USE_RX_JAVA, "Whether to use the RxJava adapter with the retrofit2 library.")); - cliOptions.add(CliOption.newBoolean(USE_RX_JAVA2, "Whether to use the RxJava2 adapter with the retrofit2 library.")); cliOptions.add(CliOption.newBoolean(PARCELABLE_MODEL, "Whether to generate models for Android that implement Parcelable with the okhttp-gson library.")); cliOptions.add(CliOption.newBoolean(USE_PLAY24_WS, "Use Play! 2.4 Async HTTP client (Play WS API)")); cliOptions.add(CliOption.newBoolean(SUPPORT_JAVA6, "Whether to support Java6 with the Jersey1 library.")); @@ -59,7 +54,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen supportedLibraries.put("jersey2", "HTTP client: Jersey client 2.22.2. JSON processing: Jackson 2.7.0"); supportedLibraries.put("okhttp-gson", "HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.6.2. Enable Parcelable modles on Android using '-DparcelableModel=true'"); supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.7.5. JSON processing: Gson 2.3.1 (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead."); - supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.2.0. JSON processing: Gson 2.6.1 (Retrofit 2.0.2). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)"); + supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.2.0. JSON processing: Gson 2.6.1 (Retrofit 2.0.2). Enable the RxJava adapter using '-DuseRxJava=true'. (RxJava 1.1.3)"); CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); libraryOption.setEnum(supportedLibraries); @@ -89,17 +84,9 @@ public class JavaClientCodegen extends AbstractJavaCodegen public void processOpts() { super.processOpts(); - if (additionalProperties.containsKey(USE_RX_JAVA) && additionalProperties.containsKey(USE_RX_JAVA2)) { - LOGGER.warn("You specified both RxJava versions 1 and 2 but they are mutually exclusive. Defaulting to v2."); - } else if (additionalProperties.containsKey(USE_RX_JAVA)) { + if (additionalProperties.containsKey(USE_RX_JAVA)) { this.setUseRxJava(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA).toString())); } - if (additionalProperties.containsKey(USE_RX_JAVA2)) { - this.setUseRxJava2(Boolean.valueOf(additionalProperties.get(USE_RX_JAVA2).toString())); - } - if (additionalProperties.containsKey(DO_NOT_USE_RX)) { - this.setDoNotUseRx(Boolean.valueOf(additionalProperties.get(DO_NOT_USE_RX).toString())); - } if (additionalProperties.containsKey(USE_PLAY24_WS)) { this.setUsePlay24WS(Boolean.valueOf(additionalProperties.get(USE_PLAY24_WS).toString())); } @@ -348,16 +335,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen public void setUseRxJava(boolean useRxJava) { this.useRxJava = useRxJava; - doNotUseRx = false; - } - - public void setUseRxJava2(boolean useRxJava2) { - this.useRxJava2 = useRxJava2; - doNotUseRx = false; - } - - public void setDoNotUseRx(boolean doNotUseRx) { - this.doNotUseRx = doNotUseRx; } public void setUsePlay24WS(boolean usePlay24WS) { diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/ApiClient.mustache index 368b4ba2dba..7d4f106a05a 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/ApiClient.mustache @@ -23,7 +23,6 @@ import java.time.format.DateTimeFormatter; import retrofit2.Converter; import retrofit2.Retrofit; {{#useRxJava}}import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;{{/useRxJava}} -{{#useRxJava2}}import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;{{/useRxJava2}} import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.scalars.ScalarsConverterFactory; @@ -141,7 +140,6 @@ public class ApiClient { .Builder() .baseUrl(baseUrl) {{#useRxJava}}.addCallAdapterFactory(RxJavaCallAdapterFactory.create()){{/useRxJava}} - {{#useRxJava2}}.addCallAdapterFactory(RxJava2CallAdapterFactory.create()){{/useRxJava2}} .addConverterFactory(ScalarsConverterFactory.create()) .addConverterFactory(GsonCustomConverterFactory.create(gson)); } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/api.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/api.mustache index 1ce3dc62502..b72af4f1703 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/api.mustache @@ -3,8 +3,7 @@ package {{package}}; import {{invokerPackage}}.CollectionFormats.*; {{#useRxJava}}import rx.Observable;{{/useRxJava}} -{{#useRxJava2}}import io.reactivex.Observable;{{/useRxJava2}} -{{#doNotUseRx}}import retrofit2.Call;{{/doNotUseRx}} +{{^useRxJava}}import retrofit2.Call;{{/useRxJava}} import retrofit2.http.*; import okhttp3.RequestBody; @@ -47,7 +46,7 @@ public interface {{classname}} { {{/prioritizedContentTypes}} {{/formParams}} @{{httpMethod}}("{{path}}") - {{^usePlay24WS}}{{^doNotUseRx}}Observable{{/doNotUseRx}}{{#doNotUseRx}}Call{{/doNotUseRx}}{{/usePlay24WS}}{{#usePlay24WS}}F.Promise{{#usePlay24WS}}>{{/usePlay24WS}} {{operationId}}({{^allParams}});{{/allParams}} + {{^usePlay24WS}}{{#useRxJava}}Observable{{/useRxJava}}{{^useRxJava}}Call{{/useRxJava}}{{/usePlay24WS}}{{#usePlay24WS}}F.Promise{{#usePlay24WS}}>{{/usePlay24WS}} {{operationId}}({{^allParams}});{{/allParams}} {{#allParams}}{{>libraries/retrofit2/queryParams}}{{>libraries/retrofit2/pathParams}}{{>libraries/retrofit2/headerParams}}{{>libraries/retrofit2/bodyParams}}{{>libraries/retrofit2/formParams}}{{#hasMore}}, {{/hasMore}}{{^hasMore}} );{{/hasMore}}{{/allParams}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache index 407c7ab6b02..353d70eafdc 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache @@ -101,9 +101,6 @@ ext { {{#useRxJava}} rx_java_version = "1.1.3" {{/useRxJava}} - {{#useRxJava2}} - rx_java_version = "2.0.5" - {{/useRxJava2}} {{^java8}} jodatime_version = "2.9.3" {{/java8}} @@ -117,10 +114,6 @@ dependencies { compile "com.squareup.retrofit2:adapter-rxjava:$retrofit_version" compile "io.reactivex:rxjava:$rx_java_version" {{/useRxJava}} - {{#useRxJava2}} - compile "com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0" - compile "io.reactivex.rxjava2:rxjava:$rx_java_version" - {{/useRxJava2}} compile "io.swagger:swagger-annotations:$swagger_annotations_version" compile "org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:$oltu_version" {{^java8}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.sbt.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.sbt.mustache index f7aa5996409..ac9f49c1417 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.sbt.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.sbt.mustache @@ -16,10 +16,6 @@ lazy val root = (project in file(".")). "com.squareup.retrofit2" % "adapter-rxjava" % "2.0.2" % "compile", "io.reactivex" % "rxjava" % "1.1.3" % "compile", {{/useRxJava}} - {{#useRxJava2}} - "com.jakewharton.retrofit" % "retrofit2-rxjava2-adapter" % "1.0.0" % "compile", - "io.reactivex.rxjava2" % "rxjava" % "2.0.5" % "compile", - {{/useRxJava2}} "io.swagger" % "swagger-annotations" % "1.5.8" % "compile", "org.apache.oltu.oauth2" % "org.apache.oltu.oauth2.client" % "1.0.1" % "compile", {{^java8}} diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache index 9899c9c1828..2434c0da20d 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/pom.mustache @@ -213,18 +213,6 @@ ${retrofit-version} {{/useRxJava}} - {{#useRxJava2}} - - io.reactivex.rxjava2 - rxjava - ${rxjava-version} - - - com.jakewharton.retrofit - com.jakewharton.retrofit - 1.0.0 - - {{/useRxJava2}} {{#usePlay24WS}} @@ -281,9 +269,6 @@ {{#useRxJava}} 1.1.6 {{/useRxJava}} - {{#useRxJava2}} - 2.0.5 - {{/useRxJava2}} {{^java8}} 2.9.4 {{/java8}} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaClientOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaClientOptionsProvider.java index cc0f3217403..1fb1b86604d 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaClientOptionsProvider.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaClientOptionsProvider.java @@ -17,7 +17,6 @@ public class JavaClientOptionsProvider extends JavaOptionsProvider { Map options = new HashMap(super.createOptions()); options.put(CodegenConstants.LIBRARY, DEFAULT_LIBRARY_VALUE); options.put(JavaClientCodegen.USE_RX_JAVA, "false"); - options.put(JavaClientCodegen.USE_RX_JAVA2, "false"); options.put(JavaClientCodegen.USE_PLAY24_WS, "false"); options.put(JavaClientCodegen.PARCELABLE_MODEL, "false"); options.put(JavaClientCodegen.SUPPORT_JAVA6, "false");