Skip to content

Commit

Permalink
Add apollo-execution and apollo-ksp (#5281)
Browse files Browse the repository at this point in the history
* add apollo-execution and apollo-ksp

* Allo to disable publication of modules (#5282)

* move build logic to plain APIS

* disable publishing

* remove unused function

* enable publishing of apollo-normalized-cache-*-incubating

* add comment

* remove unused source/target compatibility. They are overriden by --release

* Use apollo-execution in our integration tests (#5288)

* use apollo-execution for integration tests

* unhide a bunch of internals

* more comments

* hide some of the websocket implementation (#5291)

* Make CodegenLayout internal again, use CodegenMetadata.resolveSchemaType instead (#5292)

* make CodegenLayout internal again, use CodegenMetadata.resolveSchemaType instead

* Update libraries/apollo-ksp/src/main/kotlin/com/apollographql/apollo3/ksp/ksp-validation.kt

Co-authored-by: Benoit Lubek <[email protected]>

---------

Co-authored-by: Benoit Lubek <[email protected]>

---------

Co-authored-by: Benoit Lubek <[email protected]>
  • Loading branch information
martinbonnin and BoD authored Oct 12, 2023
1 parent 1ed167a commit bdf78aa
Show file tree
Hide file tree
Showing 257 changed files with 5,659 additions and 1,599 deletions.
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ invite [here](https://slack.kotl.in/))

You will need:

* Java17+. The build uses [Gradle toolchains](https://docs.gradle.org/current/userguide/toolchains.html) to ensure
reproducibility of the generated bytecode, but you still need a JVM to run Gradle itself.
* A Java17+ JDK installed locally on your machine.
* A recent version of IntelliJ IDEA community. Android Studio might work too, but we find out the experience for
multiplatform code to be better with IntelliJ IDEA.
* MacOS and the Xcode developer tools for iOS/MacOS targets.
Expand Down
14 changes: 6 additions & 8 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dependencies {
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}

tasks.withType<JavaCompile>().configureEach {
options.release.set(11)
}
Expand All @@ -63,14 +64,11 @@ tasks.withType(KotlinJvmCompile::class.java).configureEach {

gradlePlugin {
plugins {
register("apollo.library") {
id = "apollo.library"
implementationClass = "com.apollographql.apollo3.buildlogic.plugin.LibraryConventionPlugin"
}

register("apollo.test") {
id = "apollo.test"
implementationClass = "com.apollographql.apollo3.buildlogic.plugin.TestConventionPlugin"
register("build.logic") {
id = "build.logic"
// This plugin is only used for loading the jar using the Marker but never applied
// We don't need it.
implementationClass = "build.logic.Unused"
}
}
}
11 changes: 1 addition & 10 deletions build-logic/src/main/kotlin/CompilerOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,7 @@ fun setTestToolchain(project: Project, test: Test, javaVersion: Int) {

}

fun Project.configureTests(jvmVersion: Int) {
tasks.withType(Test::class.java).configureEach {
val javaToolchains = this@configureTests.extensions.getByName("javaToolchains") as JavaToolchainService
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(jvmVersion))
})
}
}

internal fun Project.optIn(vararg annotations: String) {
internal fun Project.addOptIn(vararg annotations: String) {
tasks.withType(KotlinCompile::class.java).configureEach {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + annotations.map { "-opt-in=$it" }
Expand Down
8 changes: 5 additions & 3 deletions build-logic/src/main/kotlin/Publishing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ fun Project.configureDokka() {
* Speed up development. When running the Gradle integration tests, we don't need KDoc to be generated
*/
onlyIf {
if (gradle.taskGraph.allTasks.any { it.name == "publishAllPublicationsToPluginTestRepository" ||
it.name == "publishToMavenLocal" } ) {
if (gradle.taskGraph.allTasks.any {
it.name == "publishAllPublicationsToPluginTestRepository" ||
it.name == "publishToMavenLocal"
}) {
return@onlyIf false
}

Expand Down Expand Up @@ -218,7 +220,7 @@ private fun Project.configurePublishingInternal() {
repositories {
maven {
name = "pluginTest"
url = uri("file://${rootProject.buildDir}/localMaven")
url = uri(rootProject.layout.buildDirectory.dir("localMaven"))
}

maven {
Expand Down
Empty file.
74 changes: 74 additions & 0 deletions build-logic/src/main/kotlin/api.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import org.gradle.api.Project
import org.gradle.jvm.tasks.Jar
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension

fun Project.apolloLibrary(
javaModuleName: String?,
withJs: Boolean = true,
withLinux: Boolean = true,
publish: Boolean = true
) {
group = property("GROUP")!!
version = property("VERSION_NAME")!!

commonSetup()

configureJavaAndKotlinCompilers()
addOptIn(
"com.apollographql.apollo3.annotations.ApolloExperimental",
"com.apollographql.apollo3.annotations.ApolloInternal"
)

configureTesting()

if (publish) {
configurePublishing()
}

// Within the 'tests' project (a composite build), dependencies are automatically substituted to use the project's one.
// But we don't want this, for example apollo-tooling depends on a published version of apollo-api.
// So disable this behavior (see https://docs.gradle.org/current/userguide/composite_builds.html#deactivate_included_build_substitutions).
configurations.all {
resolutionStrategy.useGlobalDependencySubstitutionRules.set(false)
}

if (extensions.findByName("kotlin") is KotlinMultiplatformExtension) {
configureMppDefaults(
withJs,
withLinux,
extensions.findByName("android") != null
)
}

if (javaModuleName != null) {
tasks.withType(Jar::class.java).configureEach {
manifest {
attributes(mapOf("Automatic-Module-Name" to javaModuleName))
}
}
}
}

fun Project.apolloTest(
withJs: Boolean = true,
withJvm: Boolean = true,
appleTargets: Set<String> = setOf(hostTarget),
browserTest: Boolean = false,
) {
commonSetup()
configureJavaAndKotlinCompilers()
addOptIn(
"com.apollographql.apollo3.annotations.ApolloExperimental",
"com.apollographql.apollo3.annotations.ApolloInternal",
)
configureTesting()

if (extensions.findByName("kotlin") is KotlinMultiplatformExtension) {
configureMppTestsDefaults(
withJs = withJs,
withJvm = withJvm,
browserTest = browserTest,
appleTargets = appleTargets,
)
}
}

This file was deleted.

This file was deleted.

5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

import JapiCmp.configureJapiCmp
import org.gradle.api.internal.tasks.testing.junit.result.TestClassResult
import org.gradle.api.internal.tasks.testing.junit.result.TestResultSerializer

plugins {
id("apollo.library") apply false
id("build.logic") apply false
}

apply(plugin = "com.github.ben-manes.versions")
Expand Down
12 changes: 9 additions & 3 deletions gradle/libraries.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ apollo-normalizedcache-sqlite = { group = "com.apollographql.apollo3", name = "a
apollo-normalizedcache-sqlite-incubating = { group = "com.apollographql.apollo3", name = "apollo-normalized-cache-sqlite-incubating", version.ref = "apollo" }
apollo-plugin = { group = "com.apollographql.apollo3", name = "apollo-gradle-plugin", version.ref = "apollo" }
apollo-runtime = { group = "com.apollographql.apollo3", name = "apollo-runtime", version.ref = "apollo" }
apollo-execution = { group = "com.apollographql.apollo3", name = "apollo-execution", version.ref = "apollo" }
# Used by the apollo-tooling project which uses a published version of Apollo
apollo-runtime-published = { group = "com.apollographql.apollo3", name = "apollo-runtime", version.ref = "apollo-published" }
apollo-annotations = { group = "com.apollographql.apollo3", name = "apollo-annotations", version.ref = "apollo" }
Expand Down Expand Up @@ -106,8 +107,11 @@ gr8 = { group = "com.gradleup", name = "gr8-plugin", version = "0.8" }
gradle-api-min = { group = "dev.gradleplugins", name = "gradle-api", version = "6.8" }
gradle-japicmp-plugin = { group = "me.champeau.gradle", name = "japicmp-gradle-plugin", version = "0.2.8" }
gradle-publish-plugin = { group = "com.gradle.publish", name = "plugin-publish-plugin", version = "1.1.0" }
graphqlkotlin = { group = "com.expediagroup", name = "graphql-kotlin-spring-server", version = "5.3.0" }
guava-jre = { group = "com.google.guava", name = "guava", version.ref = "guava" }
http4k-bom = "org.http4k:http4k-bom:5.8.0.0"
http4k-core = { module = "org.http4k:http4k-core" }
http4k-server-undertow = { module = "org.http4k:http4k-server-undertow" }
http4k-server-jetty = { module = "org.http4k:http4k-server-jetty" }
intellij-plugin = "org.jetbrains.intellij.plugins:gradle-intellij-plugin:1.16.0"
intellij-changelog = "org.jetbrains.intellij.plugins:gradle-changelog-plugin:2.0.0"
jetbrains-annotations = { group = "org.jetbrains", name = "annotations", version.ref = "jetbrains-annotations" }
Expand Down Expand Up @@ -144,7 +148,8 @@ kotlinx-serialization-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-
kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx-serialization-runtime" }
kotlinx-serialization-json-okio = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json-okio", version.ref = "kotlinx-serialization-runtime" }
kotlinx-binarycompatibilityvalidator = { group = "org.jetbrains.kotlinx", name = "binary-compatibility-validator", version = "0.13.2" }
ksp = { group = "com.google.devtools.ksp", name = "symbol-processing-gradle-plugin", version.ref = "ksp" }
ksp = { module = "com.google.devtools.ksp:symbol-processing-gradle-plugin", version.ref = "ksp" }
ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
ktor-client-core = { group = "io.ktor", name= "ktor-client-core", version.ref = "ktor" }
ktor-client-okhttp = { group = "io.ktor", name = "ktor-client-okhttp", version.ref = "ktor" }
ktor-client-darwin = { group = "io.ktor", name = "ktor-client-darwin", version.ref = "ktor" }
Expand Down Expand Up @@ -172,7 +177,7 @@ sqldelight-runtime = { group = "app.cash.sqldelight", name = "runtime", version.
sqldelight-sqlite = "app.cash.sqldelight:sqlite-dialect:2.0.0-alpha01"
jar-relocator = "me.lucko:jar-relocator:1.5"
benchmark-gradle-plugin = "androidx.benchmark:benchmark-gradle-plugin:1.1.1"
asm = "org.ow2.asm:asm-commons:9.3"
asm = "org.ow2.asm:asm-commons:9.5"
moshix-ksp = { group = "dev.zacsweers.moshix", name = "moshi-ksp", version.ref = "moshix" }
benchmark-junit4 = "androidx.benchmark:benchmark-junit4:1.1.1"
androidx-test-core = "androidx.test:core:1.5.0"
Expand All @@ -182,6 +187,7 @@ truth = { group = "com.google.truth", name = "truth", version.ref = "truth" }
turbine = { group = "app.cash.turbine", name = "turbine", version = "0.7.0" }
uuid = { group = "com.benasher44", name = "uuid", version = "0.8.0" }
vespene = { group = "net.mbonnin.vespene", name = "vespene-lib", version = "0.5" }
slf4j = "org.slf4j:slf4j-simple:2.0.9"

[plugins]
apollo = { id = "com.apollographql.apollo3", version.ref = "apollo" }
Expand Down
11 changes: 4 additions & 7 deletions libraries/apollo-adapters/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
plugins {
id("org.jetbrains.kotlin.multiplatform")
id("apollo.library")
}

apolloLibrary {
javaModuleName("com.apollographql.apollo3.adapter")
mpp {
withLinux.set(false)
}
}
apolloLibrary(
javaModuleName = "com.apollographql.apollo3.adapter",
withLinux = false
)

kotlin {
sourceSets {
Expand Down
10 changes: 10 additions & 0 deletions libraries/apollo-annotations/api/apollo-annotations.api
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ public abstract interface annotation class com/apollographql/apollo3/annotations
public abstract fun adapter ()Ljava/lang/Class;
}

public abstract interface annotation class com/apollographql/apollo3/annotations/ApolloAdapter : java/lang/annotation/Annotation {
}

public abstract interface annotation class com/apollographql/apollo3/annotations/ApolloDeprecatedSince : java/lang/annotation/Annotation {
public abstract fun version ()Lcom/apollographql/apollo3/annotations/ApolloDeprecatedSince$Version;
}
Expand Down Expand Up @@ -33,6 +36,13 @@ public abstract interface annotation class com/apollographql/apollo3/annotations
public abstract interface annotation class com/apollographql/apollo3/annotations/ApolloInternal : java/lang/annotation/Annotation {
}

public abstract interface annotation class com/apollographql/apollo3/annotations/ApolloObject : java/lang/annotation/Annotation {
}

public abstract interface annotation class com/apollographql/apollo3/annotations/ApolloRequiresOptIn : java/lang/annotation/Annotation {
}

public abstract interface annotation class com/apollographql/apollo3/annotations/GraphQLName : java/lang/annotation/Annotation {
public abstract fun name ()Ljava/lang/String;
}

Loading

0 comments on commit bdf78aa

Please sign in to comment.