diff --git a/CHANGELOG.md b/CHANGELOG.md index d7b9d72..c44a3e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ Changelog ========= +## Version 3.0.0 + +_2021-03-11_ + +- use [Thrifty 2.1.2](https://github.com/microsoft/thrifty/blob/master/CHANGELOG.md) +- use Okio 2.10.0, OkHttp 4.9.1, Kotlin 1.4.30 +- migrate deployment to Maven Central +- change group id `co.infinum` -> `com.infinum` +- change package name `co.infinum` -> `com.infinum` + ## Version 2.0.0 _2020-06-01_ diff --git a/README.md b/README.md index 4c2f937..7837f57 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Thrifty Retrofit converter [![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) -[![Download](https://api.bintray.com/packages/infinum/android/retrofit-converter-thrifty/images/download.svg) ](https://bintray.com/infinum/android/retrofit-converter-thrifty/_latestVersion) A `Retrofit converter` implementation using [Thrifty](https://github.com/Microsoft/thrifty) for (de)serialization of Apache Thrift requests and responses. @@ -11,10 +10,10 @@ It supports Thrifty models generated in both `Java` and `Kotlin`. ## Usage -Add the library as a dependency to your `build.gradle` to automatically download it from jcenter. +Add the library as a dependency to your `build.gradle` to automatically download it from Maven Central. ```groovy -compile 'co.infinum:retrofit-converter-thrifty:2.0.0' +implementation "com.infinum:retrofit-converter-thrifty:3.0.0" ``` ... and add the converter factory when you create the `Retrofit` object. @@ -28,25 +27,40 @@ Retrofit retrofit = new Retrofit.Builder() We also maintain a [changelog](CHANGELOG.md). -## Generating new files with thrifty compiler +## Contributing + +Feedback and code contributions are very much welcome. Just make a pull request with a short description of your changes. By making contributions to this project you give permission for your code to be used under the same [license](LICENSE). + +### Generating new files with the thrifty compiler In case source files need to be generated from .thrift files using a different version of the thrifty compiler, use these commands: ```shell -java -jar thrifty-compiler-2.0.1-all.jar --out=retrofit-converter-thrifty/src/test/java/ --lang=java retrofit-converter-thrifty/src/test/resources/phone.thrift -java -jar thrifty-compiler-2.0.1-all.jar --out=retrofit-converter-thrifty/src/test/java/ --lang=kotlin --kt-file-per-type retrofit-converter-thrifty/src/test/resources/phone.thrift - +wget https://repo1.maven.org/maven2/com/microsoft/thrifty/thrifty-compiler/2.1.2/thrifty-compiler-2.1.2-all.jar +java -jar thrifty-compiler-2.1.2-all.jar --out=retrofit-converter-thrifty/src/test/java/ --lang=java retrofit-converter-thrifty/src/test/resources/phone.thrift +java -jar thrifty-compiler-2.1.2-all.jar --out=retrofit-converter-thrifty/src/test/kotlin/ --lang=kotlin --kt-file-per-type retrofit-converter-thrifty/src/test/resources/phone.thrift ``` -## Deploying a new version +### Deploying a new version -To deploy a new version to bintray, use `deploy.sh`: +To publish to Maven Central you first need to set the following [Gradle properties](https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties): +``` +signing.keyId= +signing.password= +signing.secretKeyRingFile= + +sonatypeUrl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ +sonatypeUsername= +sonatypePassword= +``` + +To deploy a new version to Maven Central, use `deploy.sh`: ```shell -./deploy.sh [optional tag message] +./publish.sh [optional tag message] ``` -## Contributing +The `publish.sh` script will automatically push a tag with the version name and change the version in the README. -Feedback and code contributions are very much welcome. Just make a pull request with a short description of your changes. By making contributions to this project you give permission for your code to be used under the same [license](LICENSE). +All you need to do after the script runs is to press release in [Sonatype OSS](https://oss.sonatype.org/#stagingRepositories). diff --git a/build.gradle.kts b/build.gradle.kts index 45fbd95..5c6a945 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,15 +1,35 @@ +plugins { + id("io.github.gradle-nexus.publish-plugin") version "1.0.0" +} + buildscript { repositories { maven { url = uri("https://plugins.gradle.org/m2/") } - jcenter() + mavenCentral() } dependencies { - classpath("com.novoda:bintray-release:0.9.1") } } allprojects { repositories { - jcenter() + mavenCentral() } } + +group = "com.infinum" +version = "3.0.0" + +nexusPublishing { + repositories { + sonatype() + } +} + +//do not generate extra load on Nexus with new staging repository if signing fails +val initializeSonatypeStagingRepository by tasks.existing +subprojects { + initializeSonatypeStagingRepository { + shouldRunAfter(tasks.withType()) + } +} \ No newline at end of file diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index ca257b5..0000000 --- a/deploy.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -if [ $# -lt 3 ]; then - echo "Usage: [optional tag message]" - exit 1 -fi - -username="$1" -api_key="$2" -version="$3" - -# default tag message -tag_message="$version release" - -if [ ! -z "$4" ]; then - tag_message="$4" -fi - -./gradlew clean build bintrayUpload -PbintrayUser=${username} -PbintrayKey=${api_key} -PdryRun=false && \ -git tag -a "${version}" -m "${tag_message}" && \ -git push --tags - -# fix version in README.md if needed -sed -E "s/'co.infinum:retrofit-converter-thrifty:[\.0-9]+'/'co.infinum:retrofit-converter-thrifty:$version'/g" README.md > tmp_readme && mv tmp_readme README.md - -# show changes so we know to commit if needed -git status \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf..e708b1c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ee69dd6..8cf6eb5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index b0d6d0a..4f906e0 100755 --- a/gradlew +++ b/gradlew @@ -7,7 +7,7 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -82,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -125,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -154,19 +156,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -175,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 15e1ee3..ac1b06f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -5,7 +5,7 @@ @rem you may not use this file except in compliance with the License. @rem You may obtain a copy of the License at @rem -@rem http://www.apache.org/licenses/LICENSE-2.0 +@rem https://www.apache.org/licenses/LICENSE-2.0 @rem @rem Unless required by applicable law or agreed to in writing, software @rem distributed under the License is distributed on an "AS IS" BASIS, @@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/publish.sh b/publish.sh new file mode 100755 index 0000000..eda2d84 --- /dev/null +++ b/publish.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +###################################################################################################### +# +# This deploy script requires have all the necessary gradle properties already set up: +# - signing.keyId +# - signing.password +# - signing.secretKeyRingFile +# - sonatype.url +# - sonatype.username +# - sonatype.password +# +###################################################################################################### + +# Stop script on errors or undefined vars +set -euo pipefail; + +readonly SCRIPT_NAME="$(basename "$0")" +readonly green="\e[0;32m" +readonly red="\e[0;31m" +readonly reset="\e[0m" + +if [ $# -lt 1 ]; then + echo + echo "Usage:" + echo -e "${green}$SCRIPT_NAME [optional tag message]${reset}" + exit 1 +fi + +readonly version="$1" + +# default tag message +tag_message="$version release" + +if [ -n "${2-}" ]; then + tag_message="$2" +fi + +echo -e "${green}Building and uploading release ...${reset}" +./gradlew clean build publishToSonatype + +echo -e "${green}Closing sonatype staging repository ...${reset}" +./gradlew closeSonatypeStagingRepository + +echo -e "${green}Pushing version tag ...${reset}" +git tag -a "${version}" -m "${tag_message}" && \ +git push --tags + +# fix version in README.md if needed +echo -e "${green}Setting version in README.md to $version ...${reset}" +sed -E "s/\"com.infinum:retrofit-converter-thrifty:[\.0-9]+\"/\"com.infinum:retrofit-converter-thrifty:$version\"/g" README.md > tmp_readme && mv tmp_readme README.md + +# show changes so we know to commit if needed +echo -e "${green}\nHere's the output of git status:\n${reset}" +git status + +echo -e "${red}\n\nDON'T FORGET to release the artifact on https://oss.sonatype.org/#stagingRepositories !\n${reset}" \ No newline at end of file diff --git a/retrofit-converter-thrifty/build.gradle.kts b/retrofit-converter-thrifty/build.gradle.kts index 4806c2d..50b49a5 100644 --- a/retrofit-converter-thrifty/build.gradle.kts +++ b/retrofit-converter-thrifty/build.gradle.kts @@ -1,35 +1,37 @@ -import com.novoda.gradle.release.PublishExtension +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import java.net.URI plugins { id("java") - kotlin("jvm") version "1.3.71" + kotlin("jvm") version "1.4.30" id("jacoco") - id("com.novoda.bintray-release") + id("maven-publish") + id("signing") } java { + withJavadocJar() + withSourcesJar() sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } -group = "co.infinum" -version = "2.0.0" - object Versions { - const val thrifty_version = "2.0.1" + const val thrifty_version = "2.1.2" const val retrofit_version = "2.9.0" - const val okhttp_version = "4.7.2" - const val okio_version = "2.6.0" + const val okhttp_version = "4.9.1" + const val okio_version = "2.10.0" } dependencies { - compile("com.microsoft.thrifty:thrifty-runtime:${Versions.thrifty_version}") - compile("com.microsoft.thrifty:thrifty-runtime-ktx:${Versions.thrifty_version}") - compile("com.squareup.okio:okio:${Versions.okio_version}") - compile("com.squareup.retrofit2:retrofit:${Versions.retrofit_version}") - testCompile("com.squareup.okhttp3:mockwebserver:${Versions.okhttp_version}") - testCompile("org.assertj:assertj-core:3.16.1") - testCompile("junit:junit:4.13") + api("com.microsoft.thrifty:thrifty-runtime:${Versions.thrifty_version}") + api("com.microsoft.thrifty:thrifty-runtime-ktx:${Versions.thrifty_version}") + api("com.squareup.retrofit2:retrofit:${Versions.retrofit_version}") + implementation("com.squareup.okio:okio:${Versions.okio_version}") + implementation("javax.annotation:javax.annotation-api:1.3.2") + testImplementation("com.squareup.okhttp3:mockwebserver:${Versions.okhttp_version}") + testImplementation("org.assertj:assertj-core:3.19.0") + testImplementation("junit:junit:4.13.2") compileOnly("com.google.code.findbugs:jsr305:3.0.2") } @@ -46,13 +48,66 @@ tasks { } } -configure { - userOrg = "infinum" - groupId = project.group.toString() - artifactId = "retrofit-converter-thrifty" - publishVersion = project.version.toString() - desc = "Retrofit converter for Thrifty implementation of Apache Thrift" - website = "https://github.com/infinum/thrifty-retrofit-converter" - repoName = "android" - setLicences("Apache-2.0") +// use new JVM IR https://blog.jetbrains.com/kotlin/2021/02/the-jvm-backend-is-in-beta-let-s-make-it-stable-together/ +// TODO remove after it becomes the default in Kotlin 1.5 +tasks.withType().configureEach { + kotlinOptions { + useIR = true + } +} + +publishing { + repositories { + maven { + name = "MavenCentral" + url = URI.create(project.property("sonatypeUrl") as String) + credentials { + username = project.property("sonatypeUsername") as String + password = project.property("sonatypePassword") as String + } + } + } + publications { + create("library") { + groupId = rootProject.group as String? + artifactId = project.name + version = rootProject.version as String? + + from(components["java"]) + + pom { + name.set("Thrifty Retrofit converter") + description.set("Retrofit converter for Thrifty implementation of Apache Thrift") + url.set("https://github.com/infinum/thrifty-retrofit-converter") + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + developers { + developer { + id.set("reisub") + name.set("Dino Kovač") + email.set("dino@infinum.com") + } + } + scm { + connection.set("scm:git:git://github.com/infinum/thrifty-retrofit-converter.git") + developerConnection.set("scm:git:ssh://github.com/infinum/thrifty-retrofit-converter.git") + url.set("https://github.com/infinum/thrifty-retrofit-converter") + } + } + } + } +} + +signing { + sign(publishing.publications["library"]) } + +tasks.javadoc { + if (JavaVersion.current().isJava9Compatible) { + (options as StandardJavadocDocletOptions).addBooleanOption("html5", true) + } +} \ No newline at end of file diff --git a/retrofit-converter-thrifty/src/main/java/co/infinum/thrifty/package-info.java b/retrofit-converter-thrifty/src/main/java/co/infinum/thrifty/package-info.java deleted file mode 100644 index 7e449a9..0000000 --- a/retrofit-converter-thrifty/src/main/java/co/infinum/thrifty/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -@ParametersAreNonnullByDefault -package co.infinum.thrifty; - -import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/retrofit-converter-thrifty/src/main/java/co/infinum/thrifty/ProtocolType.java b/retrofit-converter-thrifty/src/main/java/com/infinum/thrifty/ProtocolType.java similarity index 97% rename from retrofit-converter-thrifty/src/main/java/co/infinum/thrifty/ProtocolType.java rename to retrofit-converter-thrifty/src/main/java/com/infinum/thrifty/ProtocolType.java index 451eb5a..27e9498 100644 --- a/retrofit-converter-thrifty/src/main/java/co/infinum/thrifty/ProtocolType.java +++ b/retrofit-converter-thrifty/src/main/java/com/infinum/thrifty/ProtocolType.java @@ -1,4 +1,4 @@ -package co.infinum.thrifty; +package com.infinum.thrifty; import com.microsoft.thrifty.protocol.BinaryProtocol; import com.microsoft.thrifty.protocol.CompactProtocol; diff --git a/retrofit-converter-thrifty/src/main/java/co/infinum/thrifty/ThriftyConverterFactory.java b/retrofit-converter-thrifty/src/main/java/com/infinum/thrifty/ThriftyConverterFactory.java similarity index 98% rename from retrofit-converter-thrifty/src/main/java/co/infinum/thrifty/ThriftyConverterFactory.java rename to retrofit-converter-thrifty/src/main/java/com/infinum/thrifty/ThriftyConverterFactory.java index 6e03fed..209728b 100644 --- a/retrofit-converter-thrifty/src/main/java/co/infinum/thrifty/ThriftyConverterFactory.java +++ b/retrofit-converter-thrifty/src/main/java/com/infinum/thrifty/ThriftyConverterFactory.java @@ -1,4 +1,4 @@ -package co.infinum.thrifty; +package com.infinum.thrifty; import com.microsoft.thrifty.Adapter; import com.microsoft.thrifty.Struct; diff --git a/retrofit-converter-thrifty/src/main/java/co/infinum/thrifty/ThriftyRequestBodyConverter.java b/retrofit-converter-thrifty/src/main/java/com/infinum/thrifty/ThriftyRequestBodyConverter.java similarity index 97% rename from retrofit-converter-thrifty/src/main/java/co/infinum/thrifty/ThriftyRequestBodyConverter.java rename to retrofit-converter-thrifty/src/main/java/com/infinum/thrifty/ThriftyRequestBodyConverter.java index 09d1fd4..a011e3d 100644 --- a/retrofit-converter-thrifty/src/main/java/co/infinum/thrifty/ThriftyRequestBodyConverter.java +++ b/retrofit-converter-thrifty/src/main/java/com/infinum/thrifty/ThriftyRequestBodyConverter.java @@ -1,4 +1,4 @@ -package co.infinum.thrifty; +package com.infinum.thrifty; import com.microsoft.thrifty.Adapter; import com.microsoft.thrifty.StructBuilder; diff --git a/retrofit-converter-thrifty/src/main/java/co/infinum/thrifty/ThriftyResponseBodyConverter.java b/retrofit-converter-thrifty/src/main/java/com/infinum/thrifty/ThriftyResponseBodyConverter.java similarity index 97% rename from retrofit-converter-thrifty/src/main/java/co/infinum/thrifty/ThriftyResponseBodyConverter.java rename to retrofit-converter-thrifty/src/main/java/com/infinum/thrifty/ThriftyResponseBodyConverter.java index ac189b6..9430139 100644 --- a/retrofit-converter-thrifty/src/main/java/co/infinum/thrifty/ThriftyResponseBodyConverter.java +++ b/retrofit-converter-thrifty/src/main/java/com/infinum/thrifty/ThriftyResponseBodyConverter.java @@ -1,4 +1,4 @@ -package co.infinum.thrifty; +package com.infinum.thrifty; import com.microsoft.thrifty.Adapter; import com.microsoft.thrifty.StructBuilder; diff --git a/retrofit-converter-thrifty/src/main/java/com/infinum/thrifty/package-info.java b/retrofit-converter-thrifty/src/main/java/com/infinum/thrifty/package-info.java new file mode 100644 index 0000000..9364291 --- /dev/null +++ b/retrofit-converter-thrifty/src/main/java/com/infinum/thrifty/package-info.java @@ -0,0 +1,4 @@ +@ParametersAreNonnullByDefault +package com.infinum.thrifty; + +import javax.annotation.ParametersAreNonnullByDefault; \ No newline at end of file diff --git a/retrofit-converter-thrifty/src/test/java/co/infinum/thrifty/ThriftyConverterFactoryTest.java b/retrofit-converter-thrifty/src/test/java/com/infinum/thrifty/ThriftyConverterFactoryTest.java similarity index 82% rename from retrofit-converter-thrifty/src/test/java/co/infinum/thrifty/ThriftyConverterFactoryTest.java rename to retrofit-converter-thrifty/src/test/java/com/infinum/thrifty/ThriftyConverterFactoryTest.java index 84191a7..6ac3e6d 100644 --- a/retrofit-converter-thrifty/src/test/java/co/infinum/thrifty/ThriftyConverterFactoryTest.java +++ b/retrofit-converter-thrifty/src/test/java/com/infinum/thrifty/ThriftyConverterFactoryTest.java @@ -18,9 +18,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package co.infinum.thrifty; +package com.infinum.thrifty; -import co.infinum.thrifty.kotlin.BrokenPhone; +import com.infinum.thrifty.kotlin.BrokenPhone; +import com.infinum.thrifty.java.Phone; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; @@ -46,16 +47,16 @@ public final class ThriftyConverterFactoryTest { interface Service { @GET("/") - Call get(); + Call get(); @POST("/") - Call post(@Body co.infinum.thrifty.java.Phone impl); + Call post(@Body Phone impl); @GET("/") - Call getKt(); + Call getKt(); @POST("/") - Call postKt(@Body co.infinum.thrifty.kotlin.Phone impl); + Call postKt(@Body com.infinum.thrifty.kotlin.Phone impl); @GET("/") Call getWrongClass(); @@ -110,10 +111,10 @@ private void serializeAndDeserialize(ProtocolType type, String phoneNumber, Stri ByteString bodyByteString = isBodyBase64 ? ByteString.decodeBase64(body) : ByteString.encodeUtf8(body); server.enqueue(new MockResponse().setBody(new Buffer().write(bodyByteString))); - co.infinum.thrifty.java.Phone phone = new co.infinum.thrifty.java.Phone.Builder().number(phoneNumber).build(); - Call call = service.post(phone); - Response response = call.execute(); - co.infinum.thrifty.java.Phone bodyPhone = response.body(); + Phone phone = new Phone.Builder().number(phoneNumber).build(); + Call call = service.post(phone); + Response response = call.execute(); + Phone bodyPhone = response.body(); assertThat(bodyPhone.number).isEqualTo(phoneNumber); RecordedRequest request = server.takeRequest(); @@ -128,10 +129,10 @@ private void serializeAndDeserializeKt(ProtocolType type, String phoneNumber, St ByteString bodyByteString = isBodyBase64 ? ByteString.decodeBase64(body) : ByteString.encodeUtf8(body); server.enqueue(new MockResponse().setBody(new Buffer().write(bodyByteString))); - co.infinum.thrifty.kotlin.Phone phone = new co.infinum.thrifty.kotlin.Phone.Builder().number(phoneNumber).build(); - Call call = service.postKt(phone); - Response response = call.execute(); - co.infinum.thrifty.kotlin.Phone bodyPhone = response.body(); + com.infinum.thrifty.kotlin.Phone phone = new com.infinum.thrifty.kotlin.Phone.Builder().number(phoneNumber).build(); + Call call = service.postKt(phone); + Response response = call.execute(); + com.infinum.thrifty.kotlin.Phone bodyPhone = response.body(); assertThat(bodyPhone.number).isEqualTo(phoneNumber); RecordedRequest request = server.takeRequest(); @@ -165,11 +166,7 @@ private void serializeWrongClass(ProtocolType type) throws IOException { assertThat(e).hasMessage("" + "Unable to create @Body converter for class java.lang.String (parameter #1)\n" + " for method Service.postWrongClass"); - assertThat(e.getCause()).hasMessageStartingWith("" - + "Could not locate RequestBody converter for class java.lang.String.\n" - + " Tried:\n" - + " * retrofit2.BuiltInConverters\n" - + " * co.infinum.thrifty.ThriftyConverterFactory"); + assertThat(e.getCause()).hasMessageMatching("(?s).*Tried:.*ThriftyConverterFactory.*"); } } @@ -200,11 +197,7 @@ private void deserializeWrongClass(ProtocolType type, String body, boolean isBod assertThat(e).hasMessage("" + "Unable to create converter for class java.lang.String\n" + " for method Service.getWrongClass"); - assertThat(e.getCause()).hasMessageStartingWith("" - + "Could not locate ResponseBody converter for class java.lang.String.\n" - + " Tried:\n" - + " * retrofit2.BuiltInConverters\n" - + " * co.infinum.thrifty.ThriftyConverterFactory"); + assertThat(e.getCause()).hasMessageMatching("(?s).*Tried:.*ThriftyConverterFactory.*"); } } @@ -234,11 +227,7 @@ private void serializeWrongType(ProtocolType type) throws IOException { assertThat(e).hasMessage("" + "Unable to create @Body converter for java.util.List (parameter #1)\n" + " for method Service.postWrongType"); - assertThat(e.getCause()).hasMessageStartingWith("" - + "Could not locate RequestBody converter for java.util.List.\n" - + " Tried:\n" - + " * retrofit2.BuiltInConverters\n" - + " * co.infinum.thrifty.ThriftyConverterFactory"); + assertThat(e.getCause()).hasMessageMatching("(?s).*Tried:.*ThriftyConverterFactory.*"); } } @@ -269,11 +258,7 @@ private void deserializeWrongType(ProtocolType type, String body, boolean isBody assertThat(e).hasMessage("" + "Unable to create converter for java.util.List\n" + " for method Service.getWrongType"); - assertThat(e.getCause()).hasMessageStartingWith("" - + "Could not locate ResponseBody converter for java.util.List.\n" - + " Tried:\n" - + " * retrofit2.BuiltInConverters\n" - + " * co.infinum.thrifty.ThriftyConverterFactory"); + assertThat(e.getCause()).hasMessageMatching("(?s).*Tried:.*ThriftyConverterFactory.*"); } } diff --git a/retrofit-converter-thrifty/src/test/java/co/infinum/thrifty/java/Phone.java b/retrofit-converter-thrifty/src/test/java/com/infinum/thrifty/java/Phone.java similarity index 95% rename from retrofit-converter-thrifty/src/test/java/co/infinum/thrifty/java/Phone.java rename to retrofit-converter-thrifty/src/test/java/com/infinum/thrifty/java/Phone.java index b67f3c6..0f05fa4 100644 --- a/retrofit-converter-thrifty/src/test/java/co/infinum/thrifty/java/Phone.java +++ b/retrofit-converter-thrifty/src/test/java/com/infinum/thrifty/java/Phone.java @@ -1,7 +1,7 @@ // Automatically generated by the Thrifty compiler; do not edit! -// Generated on: 2020-06-01T12:48:15.816Z -// Source: /Users/dino/android/thrifty-converter/retrofit-converter-thrifty/src/test/resources/phone.thrift at 3:1 -package co.infinum.thrifty.java; +// Generated on: 2021-03-11T13:23:16.134262292Z +// Source: /home/dino/work/thrifty-retrofit-converter/retrofit-converter-thrifty/src/test/resources/phone.thrift: (3, 1) +package com.infinum.thrifty.java; import com.microsoft.thrifty.Adapter; import com.microsoft.thrifty.Struct; diff --git a/retrofit-converter-thrifty/src/test/java/co/infinum/thrifty/kotlin/BrokenPhone.kt b/retrofit-converter-thrifty/src/test/java/com/infinum/thrifty/kotlin/BrokenPhone.kt similarity index 95% rename from retrofit-converter-thrifty/src/test/java/co/infinum/thrifty/kotlin/BrokenPhone.kt rename to retrofit-converter-thrifty/src/test/java/com/infinum/thrifty/kotlin/BrokenPhone.kt index f599025..70b1573 100644 --- a/retrofit-converter-thrifty/src/test/java/co/infinum/thrifty/kotlin/BrokenPhone.kt +++ b/retrofit-converter-thrifty/src/test/java/com/infinum/thrifty/kotlin/BrokenPhone.kt @@ -1,4 +1,4 @@ -package co.infinum.thrifty.kotlin +package com.infinum.thrifty.kotlin import com.microsoft.thrifty.Adapter import com.microsoft.thrifty.Struct diff --git a/retrofit-converter-thrifty/src/test/java/co/infinum/thrifty/kotlin/Phone.kt b/retrofit-converter-thrifty/src/test/java/com/infinum/thrifty/kotlin/Phone.kt similarity index 99% rename from retrofit-converter-thrifty/src/test/java/co/infinum/thrifty/kotlin/Phone.kt rename to retrofit-converter-thrifty/src/test/java/com/infinum/thrifty/kotlin/Phone.kt index 0086a13..b437005 100644 --- a/retrofit-converter-thrifty/src/test/java/co/infinum/thrifty/kotlin/Phone.kt +++ b/retrofit-converter-thrifty/src/test/java/com/infinum/thrifty/kotlin/Phone.kt @@ -1,4 +1,4 @@ -package co.infinum.thrifty.kotlin +package com.infinum.thrifty.kotlin import com.microsoft.thrifty.Adapter import com.microsoft.thrifty.Struct diff --git a/retrofit-converter-thrifty/src/test/resources/phone.thrift b/retrofit-converter-thrifty/src/test/resources/phone.thrift index 69162a2..e85caaa 100644 --- a/retrofit-converter-thrifty/src/test/resources/phone.thrift +++ b/retrofit-converter-thrifty/src/test/resources/phone.thrift @@ -1,4 +1,4 @@ -namespace java co.infinum.thrifty.java +namespace java com.infinum.thrifty.java struct Phone { 1: optional string number