Skip to content

Commit

Permalink
Merge branch 'master' into renovate/org.bouncycastle
Browse files Browse the repository at this point in the history
  • Loading branch information
yschimke authored Dec 28, 2024
2 parents dd95fda + d212391 commit 61bd2e3
Show file tree
Hide file tree
Showing 322 changed files with 1,846 additions and 321 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
5 changes: 3 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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.79"
org-conscrypt = "2.5.2"
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 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
4 changes: 2 additions & 2 deletions okcurl/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.KotlinJvm
import org.graalvm.buildtools.gradle.dsl.GraalVMExtension
import ru.vyarus.gradle.plugin.animalsniffer.AnimalSnifferExtension

plugins {
kotlin("jvm")
Expand Down Expand Up @@ -39,7 +40,7 @@ dependencies {
testImplementation(kotlin("test"))
}

animalsniffer {
configure<AnimalSnifferExtension> {
isIgnoreFailures = true
}

Expand All @@ -54,7 +55,6 @@ tasks.shadowJar {
mergeServiceFiles()
}


if (testJavaVersion >= 11) {
apply(plugin = "org.graalvm.buildtools.native")

Expand Down
13 changes: 9 additions & 4 deletions okhttp-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,19 @@ dependencies {
testImplementation(libs.robolectric)
testImplementation(libs.androidx.espresso.core)
testImplementation(libs.squareup.okio.fakefilesystem)
testImplementation(projects.okhttpTestingSupport)
testImplementation(rootProject.libs.conscrypt.openjdk)

androidTestImplementation(projects.okhttpTls)
androidTestImplementation(libs.assertk)
androidTestImplementation(projects.mockwebserver3Junit4)
androidTestImplementation(libs.androidx.test.runner)
}

mavenPublishing {
// AGP 7.2 embeds Dokka 4, which breaks publishing. Android modules are hardcoded to generate Javadoc instead of Gfm.
configure(com.vanniktech.maven.publish.AndroidSingleVariantLibrary(publishJavadocJar=false))
}
// TODO remove this whole module after merging with okhttp
// Conflicts with KMP :okhttp outputs

//mavenPublishing {
// // AGP 7.2 embeds Dokka 4, which breaks publishing. Android modules are hardcoded to generate Javadoc instead of Gfm.
// configure(com.vanniktech.maven.publish.AndroidSingleVariantLibrary(publishJavadocJar=false))
//}
Loading

0 comments on commit 61bd2e3

Please sign in to comment.