1
0
mirror of https://github.com/square/okhttp.git synced 2025-12-25 00:01:02 +03:00

Convert native-image gradle to kts (#6798)

This commit is contained in:
Goooler
2021-07-31 14:35:08 +08:00
committed by GitHub
parent f037cf7d13
commit 619c3256e7
6 changed files with 144 additions and 133 deletions

View File

@@ -4,6 +4,7 @@ buildscript {
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.10.1"
classpath "com.android.tools.build:gradle:7.0.0"
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.7.1.1"
classpath "gradle.plugin.com.palantir.graal:gradle-graal:0.9.0"
classpath Dependencies.bnd
}

View File

@@ -1,66 +0,0 @@
import org.apache.tools.ant.taskdefs.condition.Os
plugins {
id "com.palantir.graal" version "0.9.0"
}
dependencies {
implementation Dependencies.assertj
implementation Dependencies.junit5Api
implementation Dependencies.junit5JupiterEngine
implementation Dependencies.junitPlatformConsole
implementation Dependencies.okioFakeFileSystem
implementation project(':okhttp')
implementation project(':okhttp-brotli')
implementation project(':okhttp-dnsoverhttps')
implementation project(':okhttp-logging-interceptor')
implementation project(':okhttp-sse')
implementation project(':okhttp-testing-support')
implementation project(':okhttp-tls')
implementation Dependencies.assertj
implementation project(':mockwebserver')
implementation project(':mockwebserver-deprecated')
implementation project(':okhttp-urlconnection')
implementation project(':mockwebserver-junit4')
implementation project(':mockwebserver-junit5')
implementation Dependencies.bndResolve
implementation Dependencies.junit5Api
implementation Dependencies.junit5JupiterParams
implementation("org.graalvm.nativeimage:svm:21.2.0")
compileOnly Dependencies.jsr305
}
animalsniffer {
ignoreFailures = true
}
sourceSets {
// Not included in IDE as this confuses Intellij for obvious reasons.
main.java.srcDirs += project.file("../okhttp/src/test/java")
main.java.srcDirs += project.file("../okhttp-brotli/src/test/java")
main.java.srcDirs += project.file("../okhttp-dnsoverhttps/src/test/java")
main.java.srcDirs += project.file("../okhttp-logging-interceptor/src/test/java")
main.java.srcDirs += project.file("../okhttp-sse/src/test/java")
}
graal {
mainClass "okhttp3.RunTestsKt"
outputName "ConsoleLauncher"
graalVersion "21.2.0"
javaVersion "11"
option "--no-fallback"
option "--allow-incomplete-classpath"
option "--report-unsupported-elements-at-runtime"
option "-H:+ReportExceptionStackTraces"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
// May be possible without, but autodetection is problematic on Windows 10
// see https://github.com/palantir/gradle-graal
// see https://www.graalvm.org/docs/reference-manual/native-image/#prerequisites
windowsVsVarsPath('C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat')
}
}

View File

@@ -0,0 +1,70 @@
import org.apache.tools.ant.taskdefs.condition.Os
plugins {
id("com.palantir.graal")
}
dependencies {
implementation(Dependencies.assertj)
implementation(Dependencies.junit5Api)
implementation(Dependencies.junit5JupiterEngine)
implementation(Dependencies.junitPlatformConsole)
implementation(Dependencies.okioFakeFileSystem)
implementation(project(":okhttp"))
implementation(project(":okhttp-brotli"))
implementation(project(":okhttp-dnsoverhttps"))
implementation(project(":okhttp-logging-interceptor"))
implementation(project(":okhttp-sse"))
implementation(project(":okhttp-testing-support"))
implementation(project(":okhttp-tls"))
implementation(Dependencies.assertj)
implementation(project(":mockwebserver"))
implementation(project(":mockwebserver-deprecated"))
implementation(project(":okhttp-urlconnection"))
implementation(project(":mockwebserver-junit4"))
implementation(project(":mockwebserver-junit5"))
implementation(Dependencies.bndResolve)
implementation(Dependencies.junit5Api)
implementation(Dependencies.junit5JupiterParams)
implementation("org.graalvm.nativeimage:svm:21.2.0")
compileOnly(Dependencies.jsr305)
}
animalsniffer {
isIgnoreFailures = true
}
sourceSets {
// Not included in IDE as this confuses Intellij for obvious reasons.
main {
java.srcDirs(
"../okhttp/src/test/java",
"../okhttp-brotli/src/test/java",
"../okhttp-dnsoverhttps/src/test/java",
"../okhttp-logging-interceptor/src/test/java",
"../okhttp-sse/src/test/java"
)
}
}
graal {
mainClass("okhttp3.RunTestsKt")
outputName("ConsoleLauncher")
graalVersion("21.2.0")
javaVersion("11")
option("--no-fallback")
option("--allow-incomplete-classpath")
option("--report-unsupported-elements-at-runtime")
option("-H:+ReportExceptionStackTraces")
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
// May be possible without, but autodetection is problematic on Windows 10
// see https://github.com/palantir/gradle-graal
// see https://www.graalvm.org/docs/reference-manual/native-image/#prerequisites
windowsVsVarsPath("C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat")
}
}

View File

@@ -1,66 +0,0 @@
plugins {
id "com.palantir.graal" version "0.9.0"
}
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'com.github.johnrengelman.shadow'
jar {
manifest {
attributes 'Automatic-Module-Name': 'okhttp3.curl'
attributes 'Main-Class': 'okhttp3.curl.Main'
}
}
// resources-templates.
sourceSets {
main.resources.srcDirs += "$buildDir/generated/resources-templates"
}
processResources {
dependsOn 'copyResourcesTemplates'
}
sourcesJar {
dependsOn 'copyResourcesTemplates'
}
task copyResourcesTemplates(type: Copy) {
from 'src/main/resources-templates'
into "$buildDir/generated/resources-templates"
expand('projectVersion': "${project.version}")
filteringCharset = 'UTF-8'
}
dependencies {
api project(':okhttp')
api project(':okhttp-logging-interceptor')
implementation Dependencies.picocli
implementation Dependencies.guava
implementation 'info.picocli:picocli-codegen:4.5.2'
annotationProcessor 'info.picocli:picocli-codegen:4.5.2'
testImplementation project(':okhttp-testing-support')
testImplementation Dependencies.junit5Api
testImplementation Dependencies.assertj
}
shadowJar {
mergeServiceFiles()
}
graal {
mainClass "okhttp3.curl.Main"
outputName "okcurl"
graalVersion "21.2.0"
javaVersion "11"
option "--no-fallback"
option "--allow-incomplete-classpath"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
// May be possible without, but autodetection is problematic on Windows 10
// see https://github.com/palantir/gradle-graal
// see https://www.graalvm.org/docs/reference-manual/native-image/#prerequisites
windowsVsVarsPath("C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat")
}
}

72
okcurl/build.gradle.kts Normal file
View File

@@ -0,0 +1,72 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.nio.charset.StandardCharsets
import org.apache.tools.ant.taskdefs.condition.Os
plugins {
id("com.palantir.graal")
id("com.github.johnrengelman.shadow")
}
tasks.jar {
manifest {
attributes("Automatic-Module-Name" to "okhttp3.curl")
attributes("Main-Class" to "okhttp3.curl.Main")
}
}
// resources-templates.
sourceSets {
main {
resources.srcDirs("$buildDir/generated/resources-templates")
}
}
tasks.create<Copy>("copyResourcesTemplates") {
from("src/main/resources-templates")
into("$buildDir/generated/resources-templates")
expand("projectVersion" to "${project.version}")
filteringCharset = StandardCharsets.UTF_8.toString()
}
tasks.getByName<ProcessResources>("processResources") {
dependsOn("copyResourcesTemplates")
}
tasks.getByName<Jar>("sourcesJar") {
dependsOn("copyResourcesTemplates")
}
dependencies {
api(project(":okhttp"))
api(project(":okhttp-logging-interceptor"))
implementation(Dependencies.picocli)
implementation(Dependencies.guava)
implementation("info.picocli:picocli-codegen:4.5.2")
annotationProcessor("info.picocli:picocli-codegen:4.5.2")
testImplementation(project(":okhttp-testing-support"))
testImplementation(Dependencies.junit5Api)
testImplementation(Dependencies.assertj)
}
tasks.getByName<ShadowJar>("shadowJar") {
mergeServiceFiles()
}
graal {
mainClass("okhttp3.curl.Main")
outputName("okcurl")
graalVersion("21.2.0")
javaVersion("11")
option("--no-fallback")
option("--allow-incomplete-classpath")
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
// May be possible without, but autodetection is problematic on Windows 10
// see https://github.com/palantir/gradle-graal
// see https://www.graalvm.org/docs/reference-manual/native-image/#prerequisites
windowsVsVarsPath("C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Auxiliary\\Build\\vcvars64.bat")
}
}

View File

@@ -16,5 +16,5 @@ dependencies {
}
animalsniffer {
setIgnoreFailures(true)
isIgnoreFailures = true
}