From b09f8d0fc8f199921e1f3c8a856286708d5d528c Mon Sep 17 00:00:00 2001 From: Marc Hermans Date: Sat, 15 Jan 2022 16:39:09 +0100 Subject: [PATCH] Enable the TeamCity CI pipeline (#8368) * Setup the build.gradle * Setup the teamcity toolchain. * Revert the usage of the local build of GU. * Automatically add it now, it will always exist and is added to maven automatically by GU. * Implement the branch filter and move the constant for the minimal changelog tag to a constant in the extension. * Adding the JDK and Gradle version to the build script. --- .teamcity/pom.xml | 104 +++++++++++++++++++++++++++++++++++++++++ .teamcity/settings.kts | 104 +++++++++++++++++++++++++++++++++++++++++ build.gradle | 44 ++++++++--------- 3 files changed, 227 insertions(+), 25 deletions(-) create mode 100644 .teamcity/pom.xml create mode 100644 .teamcity/settings.kts diff --git a/.teamcity/pom.xml b/.teamcity/pom.xml new file mode 100644 index 0000000000..a8a6f382b4 --- /dev/null +++ b/.teamcity/pom.xml @@ -0,0 +1,104 @@ + + + 4.0.0 + MinecraftForge_Forge Config DSL Script + MinecraftForge_Forge + MinecraftForge_Forge_dsl + 1.0-SNAPSHOT + + + org.jetbrains.teamcity + configs-dsl-kotlin-parent + 1.0-SNAPSHOT + + + + + jetbrains-all + https://download.jetbrains.com/teamcity-repository + + true + + + + teamcity-server + https://teamcity.minecraftforge.net/app/dsl-plugins-repository + + true + + + + + + + JetBrains + https://download.jetbrains.com/teamcity-repository + + + + + ${basedir} + + + kotlin-maven-plugin + org.jetbrains.kotlin + ${kotlin.version} + + + + + compile + process-sources + + compile + + + + test-compile + process-test-sources + + test-compile + + + + + + org.jetbrains.teamcity + teamcity-configs-maven-plugin + ${teamcity.dsl.version} + + kotlin + target/generated-configs + + + + + + + + org.jetbrains.teamcity + configs-dsl-kotlin + ${teamcity.dsl.version} + compile + + + org.jetbrains.teamcity + configs-dsl-kotlin-plugins + 1.0-SNAPSHOT + pom + compile + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + compile + + + org.jetbrains.kotlin + kotlin-script-runtime + ${kotlin.version} + compile + + + \ No newline at end of file diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts new file mode 100644 index 0000000000..8748ac9ca2 --- /dev/null +++ b/.teamcity/settings.kts @@ -0,0 +1,104 @@ +import jetbrains.buildServer.configs.kotlin.v2019_2.* +import jetbrains.buildServer.configs.kotlin.v2019_2.projectFeatures.githubIssues + +/* +The settings script is an entry point for defining a TeamCity +project hierarchy. The script should contain a single call to the +project() function with a Project instance or an init function as +an argument. + +VcsRoots, BuildTypes, Templates, and subprojects can be +registered inside the project using the vcsRoot(), buildType(), +template(), and subProject() methods respectively. + +To debug settings scripts in command-line, run the + + mvnDebug org.jetbrains.teamcity:teamcity-configs-maven-plugin:generate + +command and attach your debugger to the port 8000. + +To debug in IntelliJ Idea, open the 'Maven Projects' tool window (View +-> Tool Windows -> Maven Projects), find the generate task node +(Plugins -> teamcity-configs -> teamcity-configs:generate), the +'Debug' option is available in the context menu for the task. +*/ + +version = "2021.2" + +project { + + buildType(Build) + buildType(BuildSecondaryBranches) + buildType(PullRequests) + + params { + text("docker_jdk_version", "17", label = "Gradle version", description = "The version of the JDK to use during execution of tasks in a JDK.", display = ParameterDisplay.HIDDEN, allowEmpty = false) + text("docker_gradle_version", "7.3", label = "Gradle version", description = "The version of Gradle to use during execution of Gradle tasks.", display = ParameterDisplay.HIDDEN, allowEmpty = false) + text("git_main_branch", "1.18.x", label = "Git Main Branch", description = "The git main or default branch to use in VCS operations.", display = ParameterDisplay.HIDDEN, allowEmpty = false) + text("git_branch_spec", """ + +:refs/heads/(main*) + +:refs/heads/(master*) + +:refs/heads/(develop|release|staging|main|master) + +:refs/heads/(1.*) + """.trimIndent(), label = "The branch specification of the repository", description = "By default all main branches are build by the configuration. Modify this value to adapt the branches build.", display = ParameterDisplay.HIDDEN, allowEmpty = true) + text("github_repository_name", "MinecraftForge", label = "The github repository name. Used to connect to it in VCS Roots.", description = "This is the repository slug on github. So for example `MinecraftForge` or `MinecraftForge`. It is interpolated into the global VCS Roots.", display = ParameterDisplay.HIDDEN, allowEmpty = false) + text("env.PUBLISHED_JAVA_ARTIFACT_ID", "forge", label = "Published artifact id", description = "The maven coordinate artifact id that has been published by this build. Can not be empty.", allowEmpty = false) + text("env.PUBLISHED_JAVA_FML_ARTIFACT_ID", "fmlonly", label = "Published fmlonly artifact id", description = "The maven coordinate artifact id for fml only that has been published by this build. Can not be empty.", allowEmpty = false) + text("env.PUBLISHED_JAVA_FML_ARTIFACT_VERSION", "0.0.0-SNAPSHOT", label = "Published fmlonly artifact version", description = "The version for fml only that has been published by this build. Can not be empty.", allowEmpty = false) + text("env.PUBLISHED_JAVA_GROUP", "net.minecraftforge", label = "Published group", description = "The maven coordinate group that has been published by this build. Can not be empty.", allowEmpty = false) + } + + features { + githubIssues { + id = "MinecraftForge_MinecraftForge__IssueTracker" + displayName = "MinecraftForge/MinecraftForge" + repositoryURL = "https://github.com/MinecraftForge/MinecraftForge" + } + } +} + +object Build : BuildType({ + templates(AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_BuildMainBranches"), AbsoluteId("MinecraftForge_BuildUsingGradle"), AbsoluteId("MinecraftForge_PublishProjectUsingGradle"), AbsoluteId("MinecraftForge_TriggersStaticFilesWebpageGenerator")) + id("MinecraftForge_MinecraftForge__Build") + name = "Build" + description = "Builds and Publishes the main branches of the project." + + features { + feature { + id = "trigger_fml_only_files_generator" + type = "triggerBuildFeature" + param("triggers", "MinecraftForge_FilesGenerator_GeneratePages") + param("parameters", """ + env.PUBLISHED_JAVA_FML_ARTIFACT_ID~env.PUBLISHED_JAVA_ARTIFACT_ID + env.PUBLISHED_JAVA_FML_ARTIFACT_VERSION~env.PUBLISHED_JAVA_ARTIFACT_VERSION + env.PUBLISHED_JAVA_GROUP + """.trimIndent()) + } + } +}) + +object BuildSecondaryBranches : BuildType({ + templates(AbsoluteId("MinecraftForge_ExcludesBuildingDefaultBranch"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_BuildMainBranches"), AbsoluteId("MinecraftForge_BuildUsingGradle")) + id("MinecraftForge_MinecraftForge__BuildSecondaryBranches") + name = "Build - Secondary Branches" + description = "Builds and Publishes the secondary branches of the project." + + vcs { + branchFilter = """ + +:* + -:refs/heads/(develop|release|staging|main|master) + -: + -:refs/heads/%git_main_branch% + -:refs/heads/main* + -:refs/heads/master* + -:refs/heads/1.* + """.trimIndent() + } +}) + +object PullRequests : BuildType({ + templates(AbsoluteId("MinecraftForge_BuildPullRequests"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_BuildUsingGradle")) + id("MinecraftForge_MinecraftForge__PullRequests") + name = "Pull Requests" + description = "Builds pull requests for the project" +}) diff --git a/build.gradle b/build.gradle index 313529f084..2cf7e451c9 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ import org.gradle.plugins.ide.eclipse.model.SourceFolder plugins { id 'org.cadixdev.licenser' version '0.6.1' id 'com.github.ben-manes.versions' version '0.36.0' - id 'net.minecraftforge.gradleutils' version '1.+' + id 'net.minecraftforge.gradleutils' version '2.+' id 'eclipse' id 'de.undercouch.download' version '4.1.2' } @@ -68,6 +68,7 @@ ext { INSTALLER_TOOLS = 'net.minecraftforge:installertools:1.2.10' JAR_SPLITTER = 'net.minecraftforge:jarsplitter:1.1.4' FART = 'net.minecraftforge:ForgeAutoRenamingTool:0.1.17:all' + MIN_TAG_FOR_CHANGELOG = "39.0" } println('Version: ' + VERSION + @@ -77,13 +78,10 @@ println('Version: ' + VERSION + def extraTxts = [ rootProject.file('CREDITS.txt'), - rootProject.file('LICENSE.txt') + rootProject.file('LICENSE.txt'), + rootProject.file('build/changelog.txt') //Now gets generated on build. ] -def changelog = rootProject.file('build/changelog.txt') -if (changelog.exists()) - extraTxts += changelog - task downloadVersionManifest(type: Download) { src 'https://launchermeta.mojang.com/mc/game/version_manifest_v2.json' dest file('build/versions/version_manifest.json') @@ -181,20 +179,7 @@ subprojects { } } repositories { - maven { - if (System.env.MAVEN_USER) { - url 'https://maven.minecraftforge.net/releases/' - authentication { - basic(BasicAuthentication) - } - credentials { - username = System.env.MAVEN_USER ?: 'not' - password = System.env.MAVEN_PASSWORD ?: 'set' - } - } else { - url 'file://' + rootProject.file('repo').getAbsolutePath() - } - } + maven gradleutils.getPublishingForgeMaven() } } } @@ -1509,11 +1494,6 @@ project(':forge') { publications { mavenJava(MavenPublication) { artifact universalJar - if (changelog.exists()) { - artifact(changelog) { - classifier = 'changelog' - } - } artifact installerJar //TODO: installer-win artifact makeMdk @@ -1533,3 +1513,17 @@ task setup() { //These must be strings so that we can do lazy resolution. Else dependsOn ':fmlonly:extractMapped' dependsOn ':forge:extractMapped' } + +//Also output FMLOnly when building a version. +if (System.env.TEAMCITY_VERSION) { + //Only setup the CI environment if and only if the environment variables are set. + tasks.configureTeamCity { + doLast { + println "##teamcity[setParameter name='env.PUBLISHED_JAVA_FML_ARTIFACT_VERSION' value='${project(':fmlonly').version}']" + } + } +} + +changelog { + fromTag MIN_TAG_FOR_CHANGELOG +} \ No newline at end of file