Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Use this map to choose the right build file before editing.
| Shared dependency strategy | `buildSrc/.../strategy/DependencyStrategy.kt` | Default Kotlin, Retrofit, OkHttp, coroutines, and test libraries per module type |
| Shared Dokka behavior | `buildSrc/.../components/AndroidOptions.kt` | `dokkaHtml` task, `reportUndocumented = true`, internal packages suppressed, Android docs linked |
| Shared formatting | `buildSrc/.../components/AndroidConfiguration.kt` (Spotless config), `spotless/copyright.kt` | Ktlint and license header configuration |
| Publishing options | `buildSrc/.../components/AndroidOptions.kt` | Sources jar, classes jar, Maven publication for JitPack |
| Publishing options | `buildSrc/.../components/AndroidOptions.kt` (Android), per-module `build.gradle.kts` (JVM) | AGP component-backed publications via `singleVariant("release")` + `withSourcesJar()`. JVM modules (`:annotations`, `:codegen-core`) inline publishing. Publication name `"maven"` for all modules. |
| Dependency versions and aliases | `gradle/libs.versions.toml` | Add or update aliases here first |
| Library build | `library/build.gradle.kts` | Applies the shared plugin; no module-specific overrides needed for standard changes |
| Sample app build | `app/build.gradle.kts` | Applies the shared plugin; Room compiler options, build config fields from `.config/` |
Expand Down
44 changes: 44 additions & 0 deletions annotations/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,54 @@
import co.anitrend.retrofit.graphql.buildSrc.plugin.components.configureDokkaForJvm
import co.anitrend.retrofit.graphql.buildSrc.plugin.components.configureSpotlessForJvm
import java.util.Properties
import org.gradle.api.tasks.bundling.Jar

plugins {
kotlin("jvm")
`maven-publish`
}

configureSpotlessForJvm()
configureDokkaForJvm()

// Read version from root version.properties for publishing.
// projectDir is annotations/, so parent dir is the main project root.
val versionProps = Properties()
file("${projectDir}/../gradle/version.properties").inputStream().use { versionProps.load(it) }
val libVersion = versionProps.getProperty("name")

val sourcesJar = tasks.register<Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(file("src/main/java"), file("src/main/kotlin"))
}

publishing {
publications {
create<MavenPublication>("maven") {
groupId = "co.anitrend"
artifactId = project.name
version = libVersion
from(components["java"])
artifact(sourcesJar)
pom {
name.set("Retrofit GraphQL")
description.set("This is a retrofit converter which uses annotations to inject .graphql query or mutation files into a request body along with any GraphQL variables.")
url.set("https://github.com/anitrend/retrofit-graphql")
licenses {
license {
name.set("Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("wax911")
name.set("Maxwell Mapako")
organizationUrl.set("https://github.com/anitrend")
}
}
}
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import com.android.build.api.dsl.ApplicationDefaultConfig
import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.Project
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.getValue
import org.gradle.kotlin.dsl.invoke
import java.util.*

Expand Down Expand Up @@ -64,36 +61,45 @@ private fun ApplicationDefaultConfig.applyRoomCompilerOptions(project: Project)
}
}

private fun Project.createMavenPublicationUsing(sourcesJar: Jar) {
logger.lifecycle("Applying publication configuration on ${project.path}")
publishingExtension().publications {
val component = components.findByName("android")

logger.lifecycle("Configuring maven publication options for ${project.path}:maven with component-> ${component?.name}")
create("maven", MavenPublication::class.java) {
groupId = "co.anitrend"
artifactId = "retrofit-graphql"
version = props[PropertyTypes.NAME]

artifact(sourcesJar)
artifact("${project.layout.buildDirectory.get()}/outputs/aar/${project.name}-release.aar")
from(component)
private fun Project.configurePublishing() {
// Tell AGP to produce a component-backed release variant.
// The component is created during task graph resolution, *after* project
// configuration, so the publication itself must be deferred via afterEvaluate.
libraryExtension().run {
publishing {
singleVariant("release") {
withSourcesJar()
}
}
}

pom {
name.set("Retrofit GraphQL")
description.set("This is a retrofit converter which uses annotations to inject .graphql query or mutation files into a request body along with any GraphQL variables.")
url.set("https://github.com/anitrend/retrofit-graphql")
licenses {
license {
name.set("Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
// The "release" software component is the source of truth for the Maven
// publication, which lets Gradle emit correct variant-aware POM/module metadata.
afterEvaluate {
publishingExtension().publications {
create("maven", MavenPublication::class.java) {
groupId = "co.anitrend"
// Keep backward-compatible artifactId for the deprecated :library facade
artifactId = if (isFacadeModule()) "retrofit-graphql" else project.name
version = props[PropertyTypes.NAME]
from(components.getByName("release"))

pom {
name.set("Retrofit GraphQL")
description.set("This is a retrofit converter which uses annotations to inject .graphql query or mutation files into a request body along with any GraphQL variables.")
url.set("https://github.com/anitrend/retrofit-graphql")
licenses {
license {
name.set("Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}
developers {
developer {
id.set("wax911")
name.set("Maxwell Mapako")
organizationUrl.set("https://github.com/anitrend")
developers {
developer {
id.set("wax911")
name.set("Maxwell Mapako")
organizationUrl.set("https://github.com/anitrend")
}
}
}
}
Expand Down Expand Up @@ -122,30 +128,10 @@ private fun Project.configureDokka() {
internal fun Project.configureOptions() {
logger.lifecycle("Applying extension options for ${project.path}")
if (isLibraryModule()) {
val baseExt = libraryExtension()

logger.lifecycle("Applying additional tasks options for dokka and javadoc on ${project.path}")

configureDokka()

val sourcesJar by tasks.register("sourcesJar", Jar::class.java) {
archiveClassifier.set("sources")
from("src/main/java", "src/main/kotlin")
}

val classesJar by tasks.register("classesJar", Jar::class.java) {
from("${project.layout.buildDirectory.get()}/intermediates/classes/release")
}

artifacts {
add("archives", classesJar)
add("archives", sourcesJar)
}

// Only publish from the facade :library module
if (isFacadeModule()) {
createMavenPublicationUsing(sourcesJar)
}
configurePublishing()
}
else
baseAppExtension().run {
Expand Down
44 changes: 44 additions & 0 deletions codegen-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,57 @@
import co.anitrend.retrofit.graphql.buildSrc.plugin.components.configureDokkaForJvm
import co.anitrend.retrofit.graphql.buildSrc.plugin.components.configureSpotlessForJvm
import java.util.Properties
import org.gradle.api.tasks.bundling.Jar

plugins {
kotlin("jvm")
`maven-publish`
}

configureSpotlessForJvm()
configureDokkaForJvm()

// Read version from root version.properties for publishing.
// projectDir is codegen-core/, so parent dir is the main project root.
val versionProps = Properties()
file("${projectDir}/../gradle/version.properties").inputStream().use { versionProps.load(it) }
val libVersion = versionProps.getProperty("name")

val sourcesJar = tasks.register<Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(file("src/main/java"), file("src/main/kotlin"))
}

publishing {
publications {
create<MavenPublication>("maven") {
groupId = "co.anitrend"
artifactId = project.name
version = libVersion
from(components["java"])
artifact(sourcesJar)
pom {
name.set("Retrofit GraphQL")
description.set("This is a retrofit converter which uses annotations to inject .graphql query or mutation files into a request body along with any GraphQL variables.")
url.set("https://github.com/anitrend/retrofit-graphql")
licenses {
license {
name.set("Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("wax911")
name.set("Maxwell Mapako")
organizationUrl.set("https://github.com/anitrend")
}
}
}
}
}
}

dependencies {
implementation(libs.graphql.java)
implementation(libs.kotlinpoet)
Expand Down
Loading