Skip to content

Commit

Permalink
Merge branch 'master' into renovate/org.apache.httpcomponents.client5…
Browse files Browse the repository at this point in the history
…-httpclient5-5.x
  • Loading branch information
yschimke authored Dec 28, 2024
2 parents da6c7ee + 8cc665f commit 70a6a66
Show file tree
Hide file tree
Showing 328 changed files with 1,890 additions and 341 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import okhttp3.internal.platform.AndroidPlatform
import okio.IOException

class MainActivity : ComponentActivity() {
Expand All @@ -31,6 +32,9 @@ class MainActivity : ComponentActivity() {

val client = OkHttpClient()

// Ensure we are compiling against the right variant
println(AndroidPlatform.isSupported)

val url = "https://github.com/square/okhttp".toHttpUrl()
println(url.topPrivateDomain())

Expand Down
126 changes: 85 additions & 41 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.dokka.gradle.DokkaTaskPartial
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import ru.vyarus.gradle.plugin.animalsniffer.AnimalSnifferExtension
import java.net.URI
Expand Down Expand Up @@ -57,7 +58,7 @@ allprojects {
google()
}

tasks.create("downloadDependencies") {
tasks.register("downloadDependencies") {
description = "Download all dependencies to the Gradle cache"
doLast {
for (configuration in configurations) {
Expand Down Expand Up @@ -93,16 +94,32 @@ subprojects {

apply(plugin = "checkstyle")
apply(plugin = "ru.vyarus.animalsniffer")
apply(plugin = "biz.aQute.bnd.builder")
apply(plugin = "io.github.usefulness.maven-sympathy")

// The 'java' plugin has been applied, but it is not compatible with the Android plugins.
// These are applied inside the okhttp module for that case specifically
if (project.name != "okhttp") {
apply(plugin = "biz.aQute.bnd.builder")
apply(plugin = "io.github.usefulness.maven-sympathy")
}

// Skip samples parent
if (project.buildFile.exists() && project.name != "okhttp") {
apply(plugin = "com.android.lint")

dependencies {
"lintChecks"(rootProject.libs.androidx.lint.gradle)
}
}

tasks.withType<JavaCompile> {
options.encoding = Charsets.UTF_8.toString()
}

configure<JavaPluginExtension> {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
if (plugins.hasPlugin(JavaBasePlugin::class.java)) {
extensions.configure<JavaPluginExtension> {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
}

Expand All @@ -117,33 +134,38 @@ subprojects {
}
}

configure<CheckstyleExtension> {
config = resources.text.fromArchiveEntry(checkstyleConfig, "google_checks.xml")
toolVersion = rootProject.libs.versions.checkStyle.get()
sourceSets = listOf(project.sourceSets["main"])
}
// Handled in :okhttp directly
if (project.name != "okhttp") {
configure<CheckstyleExtension> {
config = resources.text.fromArchiveEntry(checkstyleConfig, "google_checks.xml")
toolVersion = rootProject.libs.versions.checkStyle.get()
sourceSets = listOf(project.sourceSets["main"])
}

// Animal Sniffer confirms we generally don't use APIs not on Java 8.
configure<AnimalSnifferExtension> {
annotation = "okhttp3.internal.SuppressSignatureCheck"
sourceSets = listOf(project.sourceSets["main"])
// Animal Sniffer confirms we generally don't use APIs not on Java 8.
configure<AnimalSnifferExtension> {
annotation = "okhttp3.internal.SuppressSignatureCheck"
sourceSets = listOf(project.sourceSets["main"])
}
}

val signature: Configuration by configurations.getting
dependencies {
// No dependency requirements for testing-support.
if (project.name == "okhttp-testing-support") return@dependencies

// okhttp configured specifically.
if (project.name == "okhttp") return@dependencies

if (project.name == "mockwebserver3-junit5") {
// JUnit 5's APIs need java.util.function.Function and java.util.Optional from API 24.
signature(rootProject.libs.signature.android.apilevel24) { artifact { type = "signature" } }
"signature"(rootProject.libs.signature.android.apilevel24) { artifact { type = "signature" } }
} else {
// Everything else requires Android API 21+.
signature(rootProject.libs.signature.android.apilevel21) { artifact { type = "signature" } }
"signature"(rootProject.libs.signature.android.apilevel21) { artifact { type = "signature" } }
}

// OkHttp requires Java 8+.
signature(rootProject.libs.codehaus.signature.java18) { artifact { type = "signature" } }
"signature"(rootProject.libs.codehaus.signature.java18) { artifact { type = "signature" } }
}

val javaVersionSetting =
Expand All @@ -166,10 +188,15 @@ subprojects {
}
}

val testRuntimeOnly: Configuration by configurations.getting
dependencies {
testRuntimeOnly(rootProject.libs.junit.jupiter.engine)
testRuntimeOnly(rootProject.libs.junit.vintage.engine)
val platform = System.getProperty("okhttp.platform", "jdk9")
val testJavaVersion = System.getProperty("test.java.version", "21").toInt()

if (project.name != "okhttp") {
val testRuntimeOnly: Configuration by configurations.getting
dependencies {
testRuntimeOnly(rootProject.libs.junit.jupiter.engine)
testRuntimeOnly(rootProject.libs.junit.vintage.engine)
}
}

tasks.withType<Test> {
Expand Down Expand Up @@ -202,25 +229,30 @@ subprojects {
tasks.withType<Test>().configureEach {
environment("OKHTTP_ROOT", rootDir)
}
tasks.withType<KotlinJvmTest>().configureEach {
environment("OKHTTP_ROOT", rootDir)
}

if (platform == "jdk8alpn") {
// Add alpn-boot on Java 8 so we can use HTTP/2 without a stable API.
val alpnBootVersion = alpnBootVersion()
if (alpnBootVersion != null) {
val alpnBootJar = configurations.detachedConfiguration(
dependencies.create("org.mortbay.jetty.alpn:alpn-boot:$alpnBootVersion")
).singleFile
tasks.withType<Test> {
jvmArgs("-Xbootclasspath/p:${alpnBootJar}")
if (project.name != "okhttp") {
if (platform == "jdk8alpn") {
// Add alpn-boot on Java 8 so we can use HTTP/2 without a stable API.
val alpnBootVersion = alpnBootVersion()
if (alpnBootVersion != null) {
val alpnBootJar = configurations.detachedConfiguration(
dependencies.create("org.mortbay.jetty.alpn:alpn-boot:$alpnBootVersion")
).singleFile
tasks.withType<Test> {
jvmArgs("-Xbootclasspath/p:${alpnBootJar}")
}
}
} else if (platform == "conscrypt") {
dependencies {
// testRuntimeOnly(rootProject.libs.conscrypt.openjdk)
}
} else if (platform == "openjsse") {
dependencies {
// testRuntimeOnly(rootProject.libs.openjsse)
}
}
} else if (platform == "conscrypt") {
dependencies {
testRuntimeOnly(rootProject.libs.conscrypt.openjdk)
}
} else if (platform == "openjsse") {
dependencies {
testRuntimeOnly(rootProject.libs.openjsse)
}
}

Expand All @@ -237,6 +269,11 @@ subprojects {
languageSettings.optIn("okhttp3.ExperimentalOkHttpApi")
}
}
plugins.withId("org.jetbrains.kotlin.multiplatform") {
kotlinExtension.sourceSets.configureEach {
languageSettings.optIn("okhttp3.ExperimentalOkHttpApi")
}
}
plugins.withId("org.jetbrains.kotlin.android") {
kotlinExtension.sourceSets.configureEach {
languageSettings.optIn("okhttp3.ExperimentalOkHttpApi")
Expand Down Expand Up @@ -266,7 +303,6 @@ subprojects {
}

plugins.withId("com.vanniktech.maven.publish.base") {
val publishingExtension = extensions.getByType(PublishingExtension::class.java)
configure<MavenPublishBaseExtension> {
publishToMavenCentral(SonatypeHost.S01, automaticRelease = true)
signAllPublications()
Expand Down Expand Up @@ -308,6 +344,14 @@ subprojects {
}
}

plugins.withId("org.jetbrains.kotlin.jvm") {
val test = tasks.named("test")
tasks.register("jvmTest") {
description = "Get 'gradlew jvmTest' to run the tests of JVM-only modules"
dependsOn(test)
}
}

tasks.wrapper {
distributionType = Wrapper.DistributionType.ALL
}
1 change: 1 addition & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "okhttp-buildSrc"
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ org.gradle.caching=true
org.gradle.parallel=true

android.useAndroidX=true
kotlin.mpp.applyDefaultHierarchyTemplate=false

androidBuild=false
graalBuild=false
Expand Down
9 changes: 5 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ de-mannodermaus-junit5 = "1.6.0"
graalvm = "24.1.1"
kotlinx-serialization = "1.7.3"
ksp = "2.1.0-1.0.29"
lintGradle = "1.0.0-alpha03"
mockserverClient = "5.15.0"
org-bouncycastle = "1.76"
org-bouncycastle = "1.79"
org-conscrypt = "2.5.2"
org-jetbrains-coroutines = "1.9.0"
org-jetbrains-kotlin = "2.1.0"
Expand All @@ -23,6 +24,7 @@ androidx-activity = "androidx.activity:activity-ktx:1.9.3"
androidx-annotation = "androidx.annotation:annotation:1.9.1"
androidx-espresso-core = "androidx.test.espresso:espresso-core:3.6.1"
androidx-junit = "androidx.test.ext:junit:1.2.1"
androidx-lint-gradle = { module = "androidx.lint:lint-gradle", version.ref = "lintGradle" }
androidx-test-runner = "androidx.test:runner:1.6.2"
animalsniffer-annotations = "org.codehaus.mojo:animal-sniffer-annotations:1.24"
aqute-resolve = { module = "biz.aQute.bnd:biz.aQute.resolve", version.ref = "biz-aQute-bnd" }
Expand All @@ -45,7 +47,7 @@ gradlePlugin-androidJunit5 = "de.mannodermaus.gradle.plugins:android-junit5:1.11
gradlePlugin-animalsniffer = "ru.vyarus:gradle-animalsniffer-plugin:1.7.2"
gradlePlugin-binaryCompatibilityValidator = "org.jetbrains.kotlinx.binary-compatibility-validator:org.jetbrains.kotlinx.binary-compatibility-validator.gradle.plugin:0.17.0"
gradlePlugin-bnd = { module = "biz.aQute.bnd:biz.aQute.bnd.gradle", version.ref = "biz-aQute-bnd" }
gradlePlugin-dokka = "org.jetbrains.dokka:dokka-gradle-plugin:1.9.20"
gradlePlugin-dokka = "org.jetbrains.dokka:dokka-gradle-plugin:2.0.0"
gradlePlugin-errorprone = "net.ltgt.gradle:gradle-errorprone-plugin:4.1.0"
gradlePlugin-graalvmBuildTools = "org.graalvm.buildtools.native:org.graalvm.buildtools.native.gradle.plugin:0.10.4"
gradlePlugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "org-jetbrains-kotlin" }
Expand Down Expand Up @@ -76,7 +78,6 @@ kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "
kotlin-stdlib-osgi = { module = "org.jetbrains.kotlin:kotlin-osgi-bundle", version.ref = "org-jetbrains-kotlin" }
kotlin-test-annotations = { module = "org.jetbrains.kotlin:kotlin-test-annotations-common", version.ref = "org-jetbrains-kotlin" }
kotlin-test-common = { module = "org.jetbrains.kotlin:kotlin-test-common", version.ref = "org-jetbrains-kotlin" }
kotlin-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref = "org-jetbrains-kotlin" }
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "org-jetbrains-kotlin" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "org-jetbrains-coroutines" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "org-jetbrains-coroutines" }
Expand All @@ -96,7 +97,7 @@ squareup-moshi = { module = "com.squareup.moshi:moshi", version.ref = "com-squar
squareup-moshi-compiler = { module = "com.squareup.moshi:moshi-kotlin-codegen", version.ref = "com-squareup-moshi" }
squareup-moshi-kotlin = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "com-squareup-moshi" }
squareup-okhttp-icu = "com.squareup.okhttpicu:okhttp-icu:0.2.0"
squareup-kotlinPoet = "com.squareup:kotlinpoet:1.18.1"
squareup-kotlinPoet = "com.squareup:kotlinpoet:2.0.0"
squareup-okio = { module = "com.squareup.okio:okio", version.ref = "com-squareup-okio" }
squareup-okio-fakefilesystem = { module = "com.squareup.okio:okio-fakefilesystem", version.ref = "com-squareup-okio" }
squareup-okio-nodefilesystem = { module = "com.squareup.okio:okio-nodefilesystem", version.ref = "com-squareup-okio" }
Expand Down
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,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
6 changes: 4 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
1 change: 1 addition & 0 deletions mockwebserver-junit4/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies {
api(libs.junit)

testImplementation(libs.assertk)
testImplementation(libs.junit.vintage.engine)
}

mavenPublishing {
Expand Down
Loading

0 comments on commit 70a6a66

Please sign in to comment.