Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate buildSrc scripts to build-logic #218

Merged
merged 4 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
`kotlin-dsl`
}
15 changes: 15 additions & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@file:Suppress("UnstableApiUsage")

dependencyResolutionManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
versionCatalogs {
register("libs") {
from(files("../gradle/libs.versions.toml")) // include from parent project
}
}
}

rootProject.name = "build-logic"
53 changes: 53 additions & 0 deletions build-logic/src/main/kotlin/jagr-publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import java.net.URI

plugins {
java
`maven-publish`
}

extensions.configure<JavaPluginExtension> {
withJavadocJar()
withSourcesJar()
}

extensions.configure<PublishingExtension> {
repositories {
maven {
credentials {
username = project.findProperty("sonatypeUsername") as? String
password = project.findProperty("sonatypePassword") as? String
}
val releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots"
url = URI(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
}
}
publications {
register<MavenPublication>("maven") {
from(components["java"])
pom {
name.set("jagr")
description.set("An automated tool for grading programming assignments")
url.set("https://www.sourcegrade.org")
scm {
url.set("https://github.com/sourcegrade/jagr")
connection.set("scm:git:https://github.com/sourcegrade/jagr.git")
developerConnection.set("scm:git:https://github.com/sourcegrade/jagr.git")
}
licenses {
license {
name.set("GNU AFFERO GENERAL PUBLIC LICENSE Version 3")
url.set("https://www.gnu.org/licenses/agpl-3.0.html")
distribution.set("repo")
}
}
developers {
rootProject.file("authors").readLines()
.asSequence()
.map { it.split(",") }
.forEach { (_id, _name) -> developer { id.set(_id); name.set(_name) } }
}
}
}
}
}
12 changes: 12 additions & 0 deletions build-logic/src/main/kotlin/jagr-sign.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins {
signing
}

extensions.configure<PublishingExtension> {
publications {
val maven = getByName<MavenPublication>("maven")
extensions.configure<SigningExtension> {
sign(maven)
}
}
}

This file was deleted.

6 changes: 2 additions & 4 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import org.sourcegrade.jagr.script.JagrPublishPlugin

plugins {
kotlin("jvm")
kotlin("plugin.serialization")
id("jagr-publish")
id("jagr-sign")
}

apply<JagrPublishPlugin>()

dependencies {
api(project(":jagr-launcher"))
implementation(libs.csv)
Expand Down
6 changes: 2 additions & 4 deletions grader-api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import org.sourcegrade.jagr.script.JagrPublishPlugin

plugins {
`java-library`
id("jagr-publish")
id("jagr-sign")
}

apply<JagrPublishPlugin>()

tasks {
withType<PublishToMavenRepository> {
// check if rootProject version ends with .0 or .0-SNAPSHOT
Expand Down
5 changes: 2 additions & 3 deletions launcher/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import org.sourcegrade.jagr.script.JagrPublishPlugin
import org.sourcegrade.jagr.script.apiProject

plugins {
kotlin("jvm")
kotlin("kapt")
kotlin("plugin.serialization")
id("com.github.johnrengelman.shadow")
id("jagr-publish")
id("jagr-sign")
}

apply<JagrPublishPlugin>()

dependencies {
apiProject(project, "jagr-grader-api")
api(libs.coroutines)
Expand Down
6 changes: 2 additions & 4 deletions launcher/gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import org.sourcegrade.jagr.script.JagrPublishPlugin

@Suppress("DSL_SCOPE_VIOLATION") // https://youtrack.jetbrains.com/issue/KTIJ-19369
plugins {
`java-gradle-plugin`
alias(libs.plugins.gradle.publish)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.serialization)
id("jagr-publish")
// signing done by gradle-publish plugin
}

apply<JagrPublishPlugin>()

tasks {
withType<PublishToMavenRepository> {
onlyIf { project.version.toString().endsWith("-SNAPSHOT") }
Expand Down
8 changes: 8 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ dependencyResolutionManagement {
}
}

pluginManagement {
includeBuild("build-logic")
repositories {
mavenCentral()
gradlePluginPortal()
}
}

rootProject.name = "jagr"

include(":jagr-launcher-gradle-plugin")
Expand Down