Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gradle to 7.4.2.+ deps #52

Merged
merged 9 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions api/EitherNet.api → api/eithernet.api
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
public final class com/slack/eithernet/AnnotationsKt {
public static final fun errorType ([Ljava/lang/annotation/Annotation;)Lkotlin/Pair;
public static final fun statusCode ([Ljava/lang/annotation/Annotation;)Lkotlin/Pair;
public static final fun toType (Lcom/slack/eithernet/ResultType;)Ljava/lang/reflect/Type;
}

public final class com/slack/eithernet/ApiException : java/lang/Exception {
public fun <init> (Ljava/lang/Object;)V
public final fun getError ()Ljava/lang/Object;
Expand Down
67 changes: 24 additions & 43 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
* limitations under the License.
*/
import io.gitlab.arturbosch.detekt.Detekt
import java.net.URL
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URL

plugins {
kotlin("jvm") version "1.6.10"
kotlin("jvm") version "1.6.21"
`java-test-fixtures`
id("org.jetbrains.dokka") version "1.6.10"
id("com.google.devtools.ksp") version "1.6.10-1.0.2"
id("com.diffplug.spotless") version "6.2.0"
id("com.vanniktech.maven.publish") version "0.18.0"
id("io.gitlab.arturbosch.detekt") version "1.18.1"
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.8.0"
id("org.jetbrains.dokka") version "1.6.21"
id("com.google.devtools.ksp") version "1.6.21-1.0.6"
id("com.diffplug.spotless") version "6.7.1"
id("com.vanniktech.maven.publish") version "0.20.0"
id("io.gitlab.arturbosch.detekt") version "1.20.0"
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.10.0"
}

repositories {
Expand All @@ -35,28 +35,19 @@ repositories {
}

pluginManager.withPlugin("java") {
configure<JavaPluginExtension> {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
configure<JavaPluginExtension> { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) } }

project.tasks.withType<JavaCompile>().configureEach {
options.release.set(8)
}
project.tasks.withType<JavaCompile>().configureEach { options.release.set(8) }
}

tasks.withType<KotlinCompile>().configureEach {
val taskName = name
kotlinOptions {
jvmTarget = "1.8"
val argsList = mutableListOf(
"-progressive",
"-Xopt-in=kotlin.RequiresOptIn"
)
val argsList = mutableListOf("-progressive", "-opt-in=kotlin.RequiresOptIn")
if (taskName == "compileTestKotlin") {
argsList += "-Xopt-in=kotlin.ExperimentalStdlibApi"
argsList += "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
argsList += "-opt-in=kotlin.ExperimentalStdlibApi"
argsList += "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
// Enable new jvmdefault behavior
// https://blog.jetbrains.com/kotlin/2020/07/kotlin-1-4-m3-generating-default-methods-in-interfaces/
argsList += "-Xjvm-default=all"
Expand All @@ -66,21 +57,15 @@ tasks.withType<KotlinCompile>().configureEach {
}
}

tasks.withType<Detekt>().configureEach {
jvmTarget = "1.8"
}
tasks.withType<Detekt>().configureEach { jvmTarget = "1.8" }

kotlin {
explicitApi()
}
kotlin { explicitApi() }

tasks.named<DokkaTask>("dokkaHtml") {
outputDirectory.set(rootDir.resolve("docs/0.x"))
dokkaSourceSets.configureEach {
skipDeprecated.set(true)
externalDocumentationLink {
url.set(URL("https://square.github.io/retrofit/2.x/retrofit/"))
}
externalDocumentationLink { url.set(URL("https://square.github.io/retrofit/2.x/retrofit/")) }
}
}

Expand All @@ -90,35 +75,31 @@ spotless {
trimTrailingWhitespace()
endWithNewline()
}
val ktlintVersion = "0.41.0"
val ktlintUserData = mapOf("indent_size" to "2", "continuation_indent_size" to "2")
val ktfmtVersion = "0.38"
kotlin {
target("**/*.kt")
ktlint(ktlintVersion).userData(ktlintUserData)
ktfmt(ktfmtVersion).googleStyle()
trimTrailingWhitespace()
endWithNewline()
licenseHeaderFile("spotless/spotless.kt")
targetExclude("**/spotless.kt")
}
kotlinGradle {
ktlint(ktlintVersion).userData(ktlintUserData)
ktfmt(ktfmtVersion).googleStyle()
trimTrailingWhitespace()
endWithNewline()
licenseHeaderFile("spotless/spotless.kt", "(import|plugins|buildscript|dependencies|pluginManagement|rootProject)")
licenseHeaderFile(
"spotless/spotless.kt",
"(import|plugins|buildscript|dependencies|pluginManagement|rootProject)"
)
}
}

apiValidation {
// Exclude directly instantiated annotations
// https://github.com/Kotlin/binary-compatibility-validator/issues/71
ignoredClasses.add("com/slack/eithernet/AnnotationsKt\$annotationImpl\$com_slack_eithernet_ResultType\$0")
ignoredClasses.add("com/slack/eithernet/AnnotationsKt\$annotationImpl\$com_slack_eithernet_StatusCode\$0")
}

val moshiVersion = "1.12.0"
val retrofitVersion = "2.9.0"
val okhttpVersion = "4.9.0"
val coroutinesVersion = "1.6.0"

dependencies {
implementation("com.squareup.retrofit2:retrofit:$retrofitVersion")

Expand Down
11 changes: 4 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ kapt.include.compile.classpath=false
# https://youtrack.jetbrains.com/issue/KT-45545#focus=Comments-27-4862682.0-0
# Adds exports for GJF in spotless
# https://github.com/diffplug/spotless/issues/834
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 \
--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8

POM_NAME=EitherNet
POM_ARTIFACT_ID=eithernet
Expand All @@ -36,4 +31,6 @@ POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=slackhq
POM_DEVELOPER_NAME=Slack Technologies, LLC
POM_DEVELOPER_URL=https://github.com/slackhq
SONATYPE_STAGING_PROFILE=com.slack
SONATYPE_STAGING_PROFILE=com.slack
SONATYPE_HOST=DEFAULT
RELEASE_SIGNING_ENABLED=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 3 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
rootProject.name = "eithernet" // This is important because Gradle module metadata uses this in the pom artifact id of test fixtures!
rootProject.name =
"eithernet" // This is important because Gradle module metadata uses this in the pom artifact id
// of test fixtures!
32 changes: 17 additions & 15 deletions src/main/java/com/slack/eithernet/Annotations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import java.lang.reflect.WildcardType

/**
* Returns a [Pair] of a [StatusCode] and subset of these annotations without that [StatusCode]
* instance. This should be used in a custom Retrofit [retrofit2.Converter.Factory] to know what
* the given status code of a non-2xx response was when decoding the error body. This can be useful
* for contextually decoding error bodies based on the status code.
* instance. This should be used in a custom Retrofit [retrofit2.Converter.Factory] to know what the
* given status code of a non-2xx response was when decoding the error body. This can be useful for
* contextually decoding error bodies based on the status code.
*
* ```
* override fun responseBodyConverter(
Expand All @@ -50,8 +50,8 @@ public fun Array<out Annotation>.statusCode(): Pair<StatusCode, Array<Annotation

/**
* Returns a [Pair] of a [ResultType] and subset of these annotations without that [ResultType]
* instance. This should be used in a custom Retrofit [retrofit2.Converter.Factory] to determine
* the error type of an [ApiResult] for the given endpoint.
* instance. This should be used in a custom Retrofit [retrofit2.Converter.Factory] to determine the
* error type of an [ApiResult] for the given endpoint.
*
* ```
* override fun responseBodyConverter(
Expand All @@ -70,7 +70,9 @@ public fun Array<out Annotation>.errorType(): Pair<ResultType, Array<Annotation>
return nextAnnotations(ResultType::class.java)
}

private fun <A : Any> Array<out Annotation>.nextAnnotations(type: Class<A>): Pair<A, Array<Annotation>>? {
private fun <A : Any> Array<out Annotation>.nextAnnotations(
type: Class<A>
): Pair<A, Array<Annotation>>? {
var nextIndex = 0
val theseAnnotations = this
var resultType: A? = null
Expand Down Expand Up @@ -147,9 +149,8 @@ internal fun createResultType(type: Type): ResultType {
is ParameterizedType -> {
ownerType = type.ownerType ?: Nothing::class.java
rawType = Types.getRawType(type)
typeArgs = Array(type.actualTypeArguments.size) { i ->
createResultType(type.actualTypeArguments[i])
}
typeArgs =
Array(type.actualTypeArguments.size) { i -> createResultType(type.actualTypeArguments[i]) }
}
is WildcardType -> return createResultType(Util.removeSubtypeWildcard(type))
else -> error("Unrecognized type: $type")
Expand All @@ -168,9 +169,10 @@ private fun createResultType(
rawType: Class<*>,
typeArgs: Array<ResultType>,
isArray: Boolean
): ResultType = ResultType(
rawType = rawType.kotlin,
typeArgs = typeArgs,
ownerType = ownerType.kotlin,
isArray = isArray
)
): ResultType =
ResultType(
rawType = rawType.kotlin,
typeArgs = typeArgs,
ownerType = ownerType.kotlin,
isArray = isArray
)
3 changes: 2 additions & 1 deletion src/main/java/com/slack/eithernet/ApiException.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.slack.eithernet
/**
* Represents a generic API error from a given endpoint.
*
* @see [ApiResult.Failure.ApiFailure] for full documentation for how this [error] property is used and its caveats.
* @see [ApiResult.Failure.ApiFailure] for full documentation for how this [error] property is used
* and its caveats.
*/
public class ApiException(public val error: Any?) : Exception()