From 7c10b771ec10f23081f3e70b2b4e58c88e8abcd1 Mon Sep 17 00:00:00 2001 From: solonovamax Date: Mon, 28 Oct 2024 17:43:27 -0400 Subject: [PATCH] Add Jenkinsfile, update buildscripts --- Jenkinsfile | 151 ++++++++++++++++++ build.gradle.kts | 15 +- .../main/kotlin/tectonic-common.gradle.kts | 27 ---- .../main/kotlin/tectonic-compile.gradle.kts | 32 ++++ .../kotlin/tectonic-publishing.gradle.kts | 12 +- .../main/kotlin/tectonic-testing.gradle.kts | 5 - common/build.gradle.kts | 1 + gradle/libs.versions.toml | 4 + lang/hocon/build.gradle.kts | 1 + lang/json/build.gradle.kts | 1 + lang/toml/build.gradle.kts | 1 + lang/yaml/build.gradle.kts | 1 + 12 files changed, 211 insertions(+), 40 deletions(-) create mode 100644 Jenkinsfile create mode 100644 buildSrc/src/main/kotlin/tectonic-compile.gradle.kts diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..1df1ee4 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,151 @@ +pipeline { + agent any + + tools { + jdk "Temurin Java 21" + } + + triggers { + githubPush() + } + + environment { + DISCORD_WEBHOOK_URL = credentials('polydev-discord-webhook-url') + } + + stages { + stage('Checkout') { + steps { + scmSkip(deleteBuild: true) + } + } + + stage('Setup Gradle') { + steps { + sh 'chmod +x gradlew' + } + } + + stage('Build') { + steps { + withGradle { + sh './gradlew build --rerun-tasks -x check' + } + } + + post { + success { + archiveArtifacts artifacts: '**/build/libs/*.jar', fingerprint: true, onlyIfSuccessful: true + + javadoc javadocDir: 'build/docs/javadoc/', keepAll: true + } + } + } + + stage('Tests') { + steps { + withGradle { + sh './gradlew test --rerun-tasks' + } + } + + post { + success { + junit testResults: '**/build/test-results/*/*.xml' + } + } + } + + stage('Deploy to snapshots repositories') { + when { + allOf { + not { buildingTag() } + not { expression { env.TAG_NAME != null && env.TAG_NAME.matches('v\\d+\\.\\d+\\.\\d+') } } + } + } + + steps { + withCredentials([ + string(credentialsId: 'maven-signing-key', variable: 'ORG_GRADLE_PROJECT_signingKey'), + string(credentialsId: 'maven-signing-key-password', variable: 'ORG_GRADLE_PROJECT_signingPassword'), + usernamePassword( + credentialsId: 'solo-studios-maven', + passwordVariable: 'ORG_GRADLE_PROJECT_SoloStudiosSnapshotsPassword', + usernameVariable: 'ORG_GRADLE_PROJECT_SoloStudiosSnapshotsUsername' + ) + ]) { + withGradle { + sh './gradlew publishAllPublicationsToSoloStudiosSnapshotsRepository' + } + } + } + } + + stage('Deploy to releases repositories') { + when { + allOf { + buildingTag() + expression { env.TAG_NAME != null && env.TAG_NAME.matches('v\\d+\\.\\d+\\.\\d+') } + } + } + + steps { + withCredentials([ + string(credentialsId: 'maven-signing-key', variable: 'ORG_GRADLE_PROJECT_signingKey'), + string(credentialsId: 'maven-signing-key-password', variable: 'ORG_GRADLE_PROJECT_signingPassword'), + usernamePassword( + credentialsId: 'solo-studios-maven', + passwordVariable: 'ORG_GRADLE_PROJECT_SoloStudiosReleasesPassword', + usernameVariable: 'ORG_GRADLE_PROJECT_SoloStudiosReleasesUsername' + ), + // TODO: does not yet exist (uncomment once added) + // usernamePassword( + // credentialsId: 'sonatype-maven-credentials', + // passwordVariable: 'ORG_GRADLE_PROJECT_SonatypePassword', + // usernameVariable: 'ORG_GRADLE_PROJECT_SonatypeUsername' + // ), + // usernamePassword( + // credentialsId: 'codemc-maven-credentials', + // passwordVariable: 'ORG_GRADLE_PROJECT_CodeMCPassword', + // usernameVariable: 'ORG_GRADLE_PROJECT_CodeMCUsername' + // ) + ]) { + withGradle { + sh './gradlew publishAllPublicationsToSoloStudiosReleasesRepository' + // sh './gradlew publishAllPublicationsToSonatypeRepository' + // sh './gradlew publishAllPublicationsToCodeMCRepository' + } + } + } + } + } + + post { + always { + discoverReferenceBuild() + + recordIssues( + aggregatingResults: true, + enabledForFailure: true, + minimumSeverity: 'ERROR', + sourceCodeEncoding: 'UTF-8', + checksAnnotationScope: 'ALL', + sourceCodeRetention: 'LAST_BUILD', + tools: [java(), javaDoc()] + ) + + discordSend( + title: env.JOB_NAME + ' ' + env.BUILD_DISPLAY_NAME, + showChangeset: true, + enableArtifactsList: true, + link: env.BUILD_URL, + result: currentBuild.currentResult, + customAvatarUrl: 'https://github.com/PolyhedralDev.png', + customUsername: 'Solo Studios Jenkins', + webhookURL: env.DISCORD_WEBHOOK_URL, + ) + + cleanWs() + } + } +} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 907d9ff..f1c7b6e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,15 @@ plugins { - java - `maven-publish` - + `tectonic-common` + alias(libs.plugins.freefair.aggregate.javadoc) alias(libs.plugins.axion.release) } -version = scmVersion.version \ No newline at end of file +version = scmVersion.version + +dependencies { + rootProject.subprojects.forEach { subproject -> + subproject.plugins.withId("java") { + javadoc(subproject) + } + } +} diff --git a/buildSrc/src/main/kotlin/tectonic-common.gradle.kts b/buildSrc/src/main/kotlin/tectonic-common.gradle.kts index cb8112b..44647ab 100644 --- a/buildSrc/src/main/kotlin/tectonic-common.gradle.kts +++ b/buildSrc/src/main/kotlin/tectonic-common.gradle.kts @@ -1,25 +1,10 @@ import ca.solostudios.nyx.util.codeMC -import gradle.kotlin.dsl.accessors._e054d9723d982fdb55b1e388b8ab0cbf.implementation plugins { - `java-library` - id("ca.solo-studios.nyx") } nyx { - compile { - jvmTarget = 8 - - javadocJar = true - sourcesJar = true - - allWarnings = true - distributeLicense = true - buildDependsOnJar = true - reproducibleBuilds = true - } - info { group = "com.dfsek.tectonic" version = rootProject.version.toString() @@ -49,16 +34,4 @@ nyx { repositories { mavenCentral() - codeMC() } - -dependencies { - implementation(libs.jetbrains.annotations) -} - -tasks { - withType().configureEach { - options.isFork = true - options.isIncremental = true - } -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/tectonic-compile.gradle.kts b/buildSrc/src/main/kotlin/tectonic-compile.gradle.kts new file mode 100644 index 0000000..a88d329 --- /dev/null +++ b/buildSrc/src/main/kotlin/tectonic-compile.gradle.kts @@ -0,0 +1,32 @@ +import ca.solostudios.nyx.util.codeMC + +plugins { + `java-library` + + id("ca.solo-studios.nyx") +} + +nyx { + compile { + jvmTarget = 8 + + javadocJar = true + sourcesJar = true + + allWarnings = true + distributeLicense = true + buildDependsOnJar = true + reproducibleBuilds = true + } +} + +dependencies { + implementation(libs.jetbrains.annotations) +} + +tasks { + withType().configureEach { + options.isFork = true + options.isIncremental = true + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/tectonic-publishing.gradle.kts b/buildSrc/src/main/kotlin/tectonic-publishing.gradle.kts index bcda8d6..f029d20 100644 --- a/buildSrc/src/main/kotlin/tectonic-publishing.gradle.kts +++ b/buildSrc/src/main/kotlin/tectonic-publishing.gradle.kts @@ -1,3 +1,5 @@ +import ca.solostudios.nyx.util.reposiliteMaven + plugins { java `maven-publish` @@ -25,11 +27,13 @@ nyx { name = "CodeMC" credentials(PasswordCredentials::class) } - maven("https://maven.solo-studios.ca/releases/") { + reposiliteMaven("https://maven.solo-studios.ca/releases/") { + name = "SoloStudiosReleases" + credentials(PasswordCredentials::class) + } + reposiliteMaven("https://maven.solo-studios.ca/snapshots/") { + name = "SoloStudiosSnapshots" credentials(PasswordCredentials::class) - authentication { // publishing doesn't work without this for some reason - create("basic") - } } } } diff --git a/buildSrc/src/main/kotlin/tectonic-testing.gradle.kts b/buildSrc/src/main/kotlin/tectonic-testing.gradle.kts index d4ef2b6..afdfbee 100644 --- a/buildSrc/src/main/kotlin/tectonic-testing.gradle.kts +++ b/buildSrc/src/main/kotlin/tectonic-testing.gradle.kts @@ -14,10 +14,5 @@ tasks { ignoreFailures = false failFast = true maxParallelForks = (Runtime.getRuntime().availableProcessors() - 1).coerceAtLeast(1) - - reports { - html.required = false - junitXml.required = false - } } } \ No newline at end of file diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 7376752..cb9cb9c 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,5 +1,6 @@ plugins { `tectonic-common` + `tectonic-compile` `tectonic-testing` `tectonic-publishing` } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b226054..52ce7ee 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,8 @@ [versions] nyx = "0.2.3" +freefair = "8.10.2" + axion-release = "1.18.12" jetbrains-annotations = "24.0.1" @@ -21,6 +23,8 @@ junit-jupiter = "5.10.3" nyx = { id = "ca.solo-studios.nyx", version.ref = "nyx" } +freefair-aggregate-javadoc = { id = "io.freefair.aggregate-javadoc", version.ref = "freefair" } + axion-release = { id = "pl.allegro.tech.build.axion-release", version.ref = "axion-release" } [libraries] diff --git a/lang/hocon/build.gradle.kts b/lang/hocon/build.gradle.kts index f1cb24d..155fed0 100644 --- a/lang/hocon/build.gradle.kts +++ b/lang/hocon/build.gradle.kts @@ -1,5 +1,6 @@ plugins { `tectonic-common` + `tectonic-compile` `tectonic-testing` `tectonic-publishing` } diff --git a/lang/json/build.gradle.kts b/lang/json/build.gradle.kts index 1b70509..5973d1e 100644 --- a/lang/json/build.gradle.kts +++ b/lang/json/build.gradle.kts @@ -1,5 +1,6 @@ plugins { `tectonic-common` + `tectonic-compile` `tectonic-testing` `tectonic-publishing` } diff --git a/lang/toml/build.gradle.kts b/lang/toml/build.gradle.kts index 1bea0dd..7b15036 100644 --- a/lang/toml/build.gradle.kts +++ b/lang/toml/build.gradle.kts @@ -1,5 +1,6 @@ plugins { `tectonic-common` + `tectonic-compile` `tectonic-testing` `tectonic-publishing` } diff --git a/lang/yaml/build.gradle.kts b/lang/yaml/build.gradle.kts index 68014e1..7a55172 100644 --- a/lang/yaml/build.gradle.kts +++ b/lang/yaml/build.gradle.kts @@ -1,5 +1,6 @@ plugins { `tectonic-common` + `tectonic-compile` `tectonic-testing` `tectonic-publishing` }