From 859240da6c648ffe42a16c991919febd9544e7c2 Mon Sep 17 00:00:00 2001 From: LexManos Date: Mon, 13 Nov 2023 15:53:20 -0800 Subject: [PATCH] Fix duplication of sources Cleanup build script Change published artifact to: net.minecraft:gradleutils Out maven repo is pretty dirty with case sensitive versions of this project, but this follows our expected standards. Remove TeamCity related things Add getPom() to the gradleutils extension to allow easier access. --- .github/workflows/publish.yml | 2 +- .gitignore | 6 - build.gradle | 68 +--- buildSrc/build.gradle | 36 +- .../gradleutils/PomUtils.groovy | 79 ----- ...tractTeamCityProjectConfigurationTask.java | 308 ------------------ .../ChangelogGenerationExtension.java | 16 +- .../gradleutils/ChangelogUtils.groovy | 0 .../gradleutils/GradleUtils.groovy | 0 .../gradleutils/GradleUtilsExtension.groovy | 8 + .../gradleutils/GradleUtilsPlugin.groovy | 2 - .../gradleutils/PomUtils.groovy | 8 + .../tasks/GenerateChangelogTask.java | 0 teamcityTemplate/.teamcity/pom.xml | 104 ------ teamcityTemplate/.teamcity/settings.kts | 71 ---- 15 files changed, 61 insertions(+), 647 deletions(-) delete mode 100644 buildSrc/src/main/groovy/net/minecraftforge/gradleutils/PomUtils.groovy delete mode 100644 buildSrc/src/main/groovy/net/minecraftforge/gradleutils/tasks/ExtractTeamCityProjectConfigurationTask.java rename {buildSrc/src => src}/main/groovy/net/minecraftforge/gradleutils/ChangelogUtils.groovy (100%) rename {buildSrc/src => src}/main/groovy/net/minecraftforge/gradleutils/GradleUtils.groovy (100%) rename {buildSrc/src => src}/main/groovy/net/minecraftforge/gradleutils/tasks/GenerateChangelogTask.java (100%) delete mode 100644 teamcityTemplate/.teamcity/pom.xml delete mode 100644 teamcityTemplate/.teamcity/settings.kts diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f642600..06b5222 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,7 +13,7 @@ jobs: with: java: 8 gradle_tasks: "publish" - artifact_name: "GradleUtils" + artifact_name: "gradleutils" secrets: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} PROMOTE_ARTIFACT_WEBHOOK: ${{ secrets.PROMOTE_ARTIFACT_WEBHOOK }} diff --git a/.gitignore b/.gitignore index 6cf920a..1060c12 100644 --- a/.gitignore +++ b/.gitignore @@ -15,9 +15,3 @@ out *.idea *.iml -# src -src/main/groovy/net/minecraftforge/gradleutils/GradleUtils.groovy -src/main/groovy/net/minecraftforge/gradleutils/ChangelogUtils.groovy -src/main/groovy/net/minecraftforge/gradleutils/tasks/GenerateChangelogTask.java -src/main/groovy/net/minecraftforge/gradleutils/tasks/ExtractTeamCityProjectConfigurationTask.java -src/main/resources/.teamcity.zip diff --git a/build.gradle b/build.gradle index 2e43cc0..ac0c3aa 100644 --- a/build.gradle +++ b/build.gradle @@ -1,18 +1,13 @@ -import net.minecraftforge.gradleutils.ChangelogUtils -import net.minecraftforge.gradleutils.GradleUtils -import net.minecraftforge.gradleutils.PomUtils - -import net.minecraftforge.gradleutils.tasks.ExtractTeamCityProjectConfigurationTask - plugins { id 'java-gradle-plugin' id 'groovy' id 'maven-publish' id 'org.cadixdev.licenser' version '0.6.1' + id 'net.minecraftforge.gradleutils' } -group 'net.minecraftforge.gradleutils' -version GradleUtils.getTagOffsetVersion(GradleUtils.gitInfo(file('.'))) +group 'net.minecraftforge' +version gradleutils.tagOffsetVersion println "Version: $version" repositories { @@ -30,44 +25,10 @@ java { withSourcesJar() } -tasks.register('copyGradleUtilsGroovy', Copy) { - outputs.upToDateWhen { false } - into 'src/main/groovy' - from('buildSrc/src/main/groovy') { - include '**/*.groovy' - include '**/*.java' - } -} - -tasks.register('copyGradleUtilsResources', Copy) { - outputs.upToDateWhen { false } - into 'src/main/resources' - from('buildSrc/build/extraresources') { - include '**/*.zip' - } -} - tasks.withType(GroovyCompile).configureEach { - dependsOn 'copyGradleUtilsResources', 'copyGradleUtilsGroovy' groovyOptions.optimizationOptions.indy = true } -tasks.named('checkLicenseMain').configure { - dependsOn 'copyGradleUtilsResources', 'copyGradleUtilsGroovy' -} - -tasks.named('processResources', ProcessResources).configure { - dependsOn 'copyGradleUtilsResources' -} - -tasks.named('sourcesJar', Jar).configure { - dependsOn 'copyGradleUtilsResources', 'copyGradleUtilsGroovy' -} - -tasks.register('setupTeamCityProject', ExtractTeamCityProjectConfigurationTask) {} - -GradleUtils.setupCITasks(project) - license { header = file('LICENSE-header.txt') newLine = false @@ -83,30 +44,33 @@ gradlePlugin { } } -ChangelogUtils.setupChangelogGenerationFromTag(project, '1.0') +changelog { + fromTag '1.0' + publishAll = false +} publishing { - publications.register('pluginMaven', MavenPublication) { mavenPublication -> - ChangelogUtils.setupChangelogGenerationForPublishing(project, mavenPublication) - + publications.register('pluginMaven', MavenPublication) { + changelog.publish(it) pom { + artifactId = 'gradleutils' name = 'Gradle Utils' description = 'Used by MinecraftForge projects as a util library for Gradle buildscripts' url = 'https://github.com/MinecraftForge/GradleUtils' - PomUtils.setGitHubDetails(pom, 'GradleUtils') + gradleutils.pom.setGitHubDetails(pom, 'GradleUtils') - license PomUtils.Licenses.LGPLv2_1 + license gradleutils.pom.licenses.LGPLv2_1 developers { - developer PomUtils.Developers.LexManos - developer PomUtils.Developers.SizableShrimp - developer PomUtils.Developers.Paint_Ninja + developer gradleutils.pom.Developers.LexManos + developer gradleutils.pom.Developers.SizableShrimp + developer gradleutils.pom.Developers.Paint_Ninja } } } repositories { - maven GradleUtils.getPublishingForgeMaven(project) + maven gradleutils.publishingForgeMaven } } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 0fb11eb..d89bc7c 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -1,4 +1,5 @@ plugins { + id 'java-gradle-plugin' id 'org.cadixdev.licenser' version '0.6.1' } @@ -6,30 +7,25 @@ repositories { mavenCentral() } +java.toolchain.languageVersion = JavaLanguageVersion.of(8) + dependencies { implementation 'org.eclipse.jgit:org.eclipse.jgit:5.10.0.202012080955-r' } -license { - header = new File(projectDir.parentFile, 'LICENSE-header.txt') - newLine = false - exclude '**/*.properties' -} - -final extraResources = new File(layout.buildDirectory.getAsFile().get(), 'extraresources') - -sourceSets.main.resources.srcDir(extraResources) - -tasks.register('teamcityTemplateZip', Zip) { - from(project.file('../teamcityTemplate')) - archiveFileName.set('.teamcity.zip') - destinationDirectory.set(extraResources) -} - -tasks.named('processResources').configure { - dependsOn 'teamcityTemplateZip' +sourceSets { + main { + groovy { + srcDirs = ['../src/main/groovy'] + } + } } -tasks.named('classes').configure { - dependsOn 'teamcityTemplateZip' +gradlePlugin { + plugins { + gradleutils { + id = 'net.minecraftforge.gradleutils' + implementationClass = 'net.minecraftforge.gradleutils.GradleUtilsPlugin' + } + } } diff --git a/buildSrc/src/main/groovy/net/minecraftforge/gradleutils/PomUtils.groovy b/buildSrc/src/main/groovy/net/minecraftforge/gradleutils/PomUtils.groovy deleted file mode 100644 index a357a1f..0000000 --- a/buildSrc/src/main/groovy/net/minecraftforge/gradleutils/PomUtils.groovy +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ -package net.minecraftforge.gradleutils - -import groovy.transform.CompileStatic -import org.gradle.api.Action -import org.gradle.api.publish.maven.MavenPom -import org.gradle.api.publish.maven.MavenPomDeveloper -import org.gradle.api.publish.maven.MavenPomIssueManagement -import org.gradle.api.publish.maven.MavenPomLicense -import org.gradle.api.publish.maven.MavenPomScm - -/** - * Utilities for making configuring a {@link MavenPom} more ergonomic. - */ -@CompileStatic -final class PomUtils { - static final class Licenses { - @Lazy - public static final Closure Apache2_0 = { MavenPomLicense license -> - license.name.set('Apache License, Version 2.0') - license.url.set('https://www.apache.org/licenses/LICENSE-2.0.txt') - } - - @Lazy - public static final Closure LGPLv2_1 = { MavenPomLicense license -> - license.name.set('LGPLv2.1') - license.url.set('https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt') - } - - @Lazy - public static final Closure LGPLv3 = { MavenPomLicense license -> - license.name.set('LGPLv3') - license.url.set('https://www.gnu.org/licenses/lgpl-3.0.txt') - } - - @Lazy - public static final Closure MIT = { MavenPomLicense license -> - license.name.set('MIT') - license.url.set('https://opensource.org/license/mit/') - } - } - - public static final Map> Developers = [ - LexManos: makeDev('LexManos', 'Lex Manos'), - Paint_Ninja: makeDev('Paint_Ninja'), - SizableShrimp: makeDev('SizableShrimp'), - cpw: makeDev('cpw'), - ].withDefault(this.&makeDev) as Map> - - private static Action makeDev(String id, String name = id) { - return (MavenPomDeveloper developer) -> { - developer.id.set(id) - developer.name.set(name) - } as Action - } - - /** - * Reduces boilerplate when setting up GitHub details in a {@link org.gradle.api.publish.maven.MavenPom}. - * @param mavenPom The pom to configure - * @param org The organisation or username the GitHub project is under - * @param repo The name of the repository on GitHub - */ - static void setGitHubDetails(MavenPom mavenPom, String org = 'MinecraftForge', String repo) { - mavenPom.tap { - scm { MavenPomScm scm -> - scm.url.set("https://github.com/$org/$repo" as String) - scm.connection.set("scm:git:git://github.com/$org/${repo}.git" as String) - scm.developerConnection.set("scm:git:git@github.com:$org/${repo}.git" as String) - } - issueManagement { MavenPomIssueManagement issue -> - issue.system.set('github') - issue.url.set("https://github.com/$org/$repo/issues" as String) - } - } - } -} diff --git a/buildSrc/src/main/groovy/net/minecraftforge/gradleutils/tasks/ExtractTeamCityProjectConfigurationTask.java b/buildSrc/src/main/groovy/net/minecraftforge/gradleutils/tasks/ExtractTeamCityProjectConfigurationTask.java deleted file mode 100644 index 0d41476..0000000 --- a/buildSrc/src/main/groovy/net/minecraftforge/gradleutils/tasks/ExtractTeamCityProjectConfigurationTask.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright (c) Forge Development LLC and contributors - * SPDX-License-Identifier: LGPL-2.1-only - */ -package net.minecraftforge.gradleutils.tasks; - -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.Status; -import org.gradle.api.DefaultTask; -import org.gradle.api.UnknownDomainObjectException; -import org.gradle.api.file.DirectoryProperty; -import org.gradle.api.plugins.JavaPluginExtension; -import org.gradle.api.provider.Property; -import org.gradle.api.publish.PublishingExtension; -import org.gradle.api.publish.maven.MavenPublication; -import org.gradle.api.tasks.*; -import org.gradle.jvm.toolchain.JavaLanguageVersion; -import org.gradle.util.GradleVersion; - -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.Locale; -import java.util.Objects; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -/** - * Task to extract the TeamCity project configuration from the included template zpi file and the github remote information. - */ -public abstract class ExtractTeamCityProjectConfigurationTask extends DefaultTask -{ - - public ExtractTeamCityProjectConfigurationTask() - { - getDestination().convention(getProject().getRootProject().getLayout().getProjectDirectory().dir(getProject().provider(() -> "./"))); - - setGroup("publishing"); - setDescription("Creates (or recreates) a default TeamCity project configuration directory for use with the MinecraftForge TeamCity server."); - } - - @InputDirectory - @PathSensitive(PathSensitivity.NONE) - public abstract DirectoryProperty getDestination(); - - @TaskAction - public void run() throws Exception - { - //Get the destination directory (by default the current root project directory) - final File destDir = getDestination().getAsFile().get(); - //Grab the target directory, to check if it exists. - final File teamcityDir = new File(destDir, ".teamcity"); - - //Export the zip file from our resources. - String fileZip = exportResource(); - - //Check if the directory exists, if so then delete it. - if (teamcityDir.exists()) - { - //Try to delete it. - if (!teamcityDir.delete()) - { - //Something went really wrong.... - throw new IllegalStateException("Could not delete the existing .teamcity project directory!"); - } - } - - //Extract the zip from our runtime file. - extractTeamCityZip(fileZip, destDir); - //Replace the default project ids, with ours. - replaceTeamCityTestProjectIds(destDir); - } - - /** - * Extracts the .teamcity.zip file to our target directory. - * - * @param fileZip The teamcity zip file. - * @param destDir The target directory (generally the project directory), where the .teamcity.zip file will be extracted. - */ - private static void extractTeamCityZip(final String fileZip, final File destDir) throws Exception - { - byte[] buffer = new byte[1024]; - ZipInputStream zis = new ZipInputStream(new FileInputStream(fileZip)); - ZipEntry zipEntry = zis.getNextEntry(); - while (zipEntry != null) { - File newFile = newFile(destDir, zipEntry); - if (zipEntry.isDirectory()) { - if (!newFile.isDirectory() && !newFile.mkdirs()) { - throw new IOException("Failed to create directory " + newFile); - } - } else { - // fix for Windows-created archives - File parent = newFile.getParentFile(); - if (!parent.isDirectory() && !parent.mkdirs()) { - throw new IOException("Failed to create directory " + parent); - } - - // write file content - FileOutputStream fos = new FileOutputStream(newFile); - int len; - while ((len = zis.read(buffer)) > 0) { - fos.write(buffer, 0, len); - } - fos.close(); - } - zipEntry = zis.getNextEntry(); - } - zis.closeEntry(); - zis.close(); - } - - /** - * Extracts the .teamcity.zip file from our plugin jar. - * - * @return The path to the file. - */ - private static String exportResource() throws Exception - { - InputStream stream = null; - OutputStream resStreamOut = null; - String jarFolder; - try { - stream = ExtractTeamCityProjectConfigurationTask.class.getResourceAsStream("/.teamcity.zip");//note that each / is a directory down in the "jar tree" been the jar the root of the tree - if(stream == null) { - throw new Exception("Cannot get resource \"" + ".teamcity.zip" + "\" from Jar file."); - } - - int readBytes; - byte[] buffer = new byte[4096]; - jarFolder = new File(ExtractTeamCityProjectConfigurationTask.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getParentFile().getPath().replace('\\', '/'); - resStreamOut = new FileOutputStream(jarFolder + ".teamcity.zip"); - while ((readBytes = stream.read(buffer)) > 0) { - resStreamOut.write(buffer, 0, readBytes); - } - } - finally { - if (stream != null) - { - stream.close(); - } - if (resStreamOut != null) - { - resStreamOut.close(); - } - } - - return jarFolder + ".teamcity.zip"; - } - - /** - * Creates a new file or directory, used during the extraction of the .teamcity.zip file. - * - * @param destinationDir The target directory. - * @param zipEntry The entry in the .teamcity.zip file. - * @return The new file or directory. - */ - private static File newFile(File destinationDir, ZipEntry zipEntry) throws Exception - { - File destFile = new File(destinationDir, zipEntry.getName()); - - String destDirPath = destinationDir.getCanonicalPath(); - String destFilePath = destFile.getCanonicalPath(); - - if (!destFilePath.startsWith(destDirPath + File.separator)) { - throw new IOException("Entry is outside of the target dir: " + zipEntry.getName()); - } - - return destFile; - } - - /** - * Parses the existing .teamcity directory files for "TeamCityTest" and replaces it with a new project id, - * generated by checking the first remote on the current git project. - * - * @param projectDir The project directory to run the replacement in. - */ - @SuppressWarnings("ReadWriteStringCanBeUsed") //We still need to support older versions of the JDK. - private void replaceTeamCityTestProjectIds(final File projectDir) throws Exception - { - try (final Git git = Git.open(projectDir)) { - final String projectId = determineGitHubProjectName(git); - final File teamcityDir = new File(projectDir, ".teamcity"); - if (!teamcityDir.exists()) - { - return; - } - - for (final File file : Objects.requireNonNull(teamcityDir.listFiles((dir, name) -> name.endsWith("kts")))) - { - String content = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); - content = content.replaceAll("%projectName%", projectId); - content = content.replaceAll("%projectOrg%", determineGitHubProjectOrganisation(git)); - content = content.replaceAll("%projectArtifactId%", determineArtifactId(projectId)); - content = content.replaceAll("%projectArtifactGroup%", determineGroup(getProject().getGroup().toString())); - content = content.replaceAll("%jdkVersion%", determineJDKVersion()); - content = content.replaceAll("%gradleVersion%", GradleVersion.current().getVersion()); - Files.write(file.toPath(), content.getBytes(StandardCharsets.UTF_8)); - } - - String projectGroup = determineGitHubProjectOrganisation(git); - if (!projectGroup.equals("MinecraftForge")) { - projectGroup = "MinecraftForge_" + projectGroup; - } - - for (final File file : Objects.requireNonNull(teamcityDir.listFiles((dir, name) -> name.endsWith("xml")))) - { - String content = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8); - content = content.replaceAll("%projectName%", projectId); - content = content.replaceAll("%projectGroup%", projectGroup); - Files.write(file.toPath(), content.getBytes(StandardCharsets.UTF_8)); - } - } - } - - private String determineJDKVersion() { - if (getProject().getExtensions().findByType(JavaPluginExtension.class) == null) { - getProject().getLogger().warn("Could not find the Java extension, falling back to JDK 8."); - return "8"; - } - - return getProject().getExtensions().getByType(JavaPluginExtension.class) - .getToolchain().getLanguageVersion() - .orElse(getProject().provider(() -> JavaLanguageVersion.of(8))) - .get().toString(); - } - - private String determineArtifactId(String projectId) { - if (getProject().getExtensions().findByType(PublishingExtension.class) == null) { - getProject().getLogger().warn("Could not find the Maven publication extension, falling back to the lower cased project name."); - return projectId.toLowerCase(); - } - - try { - return getProject().getExtensions().getByType(PublishingExtension.class) - .getPublications() - .stream() - .filter(MavenPublication.class::isInstance) - .map(MavenPublication.class::cast) - .filter(publication -> !publication.getName().contains("PluginMarker")) //Exclude gradles plugin markers! - .findFirst() - .map(MavenPublication::getArtifactId) - .orElseGet(() -> { - getProject().getLogger().warn("Could not find the Maven artifact Id from normal publication falling back to the lower cased project name."); - return projectId.toLowerCase(); - }); - } - catch (UnknownDomainObjectException unknownDomainObjectException) { - getProject().getLogger().warn("Could not find the Maven publication extension, falling back to the lower cased project name."); - return projectId.toLowerCase(); - } - - } - - private String determineGroup(String fallback) { - if (getProject().getExtensions().findByType(PublishingExtension.class) == null) { - getProject().getLogger().warn("Could not find the Maven publication extension, falling back to the lower cased project group."); - return fallback.toLowerCase(); - } - - try { - return getProject().getExtensions().getByType(PublishingExtension.class) - .getPublications() - .stream() - .filter(MavenPublication.class::isInstance) - .map(MavenPublication.class::cast) - .filter(publication -> !publication.getName().contains("PluginMarker")) //Exclude gradles plugin markers! - .findFirst() - .map(MavenPublication::getGroupId) - .orElseGet(() -> { - getProject().getLogger().warn("Could not find the Maven artifact Id from normal publication falling back to the lower cased project group."); - return fallback.toLowerCase(); - }); - } - catch (UnknownDomainObjectException unknownDomainObjectException) { - getProject().getLogger().warn("Could not find the Maven publication extension, falling back to the lower cased project group."); - return fallback.toLowerCase(); - } - } - - /** - * Determines the project name of the project of github. - * Querries the first remote of the current git project and pulls its fetch URL information to extract the name. - * - * @param git the project git - * @return The project name of the project on github. - */ - private static String determineGitHubProjectName(final Git git) throws Exception - { - final String repositoryPath = git.remoteList().call().get(0).getURIs().get(0).getPath(); - - return repositoryPath.substring(repositoryPath.lastIndexOf("/") + 1).replace(".git", ""); - } - - /** - * Determines the project name of the organisation of github. - * Querries the first remote of the current git project and pulls its fetch URL information to extract the name. - * - * @param git the project git - * @return The organisation name of the project on github. - */ - private static String determineGitHubProjectOrganisation(final Git git) throws Exception - { - final String repositoryPath = git.remoteList().call().get(0).getURIs().get(0).getPath(); - - final String[] pathMembers = repositoryPath.split("/"); - return pathMembers[pathMembers.length - 2]; - } -} diff --git a/src/main/groovy/net/minecraftforge/gradleutils/ChangelogGenerationExtension.java b/src/main/groovy/net/minecraftforge/gradleutils/ChangelogGenerationExtension.java index 9d8d318..b3b6dcc 100644 --- a/src/main/groovy/net/minecraftforge/gradleutils/ChangelogGenerationExtension.java +++ b/src/main/groovy/net/minecraftforge/gradleutils/ChangelogGenerationExtension.java @@ -15,21 +15,29 @@ public class ChangelogGenerationExtension private boolean registerAllPublications = true; @Inject - public ChangelogGenerationExtension(final Project project) {this.project = project;} + public ChangelogGenerationExtension(final Project project) { + this.project = project; + project.afterEvaluate(this::afterEvaluate); + } public void fromMergeBase() { ChangelogUtils.setupChangelogGeneration(project); - project.afterEvaluate(this::afterEvaluate); } public void fromTag(final String tag) { ChangelogUtils.setupChangelogGenerationFromTag(project, tag); - project.afterEvaluate(this::afterEvaluate); } public void fromCommit(final String commit) { ChangelogUtils.setupChangelogGenerationFromCommit(project, commit); - project.afterEvaluate(this::afterEvaluate); + } + + public void setPublishAll(boolean value) { + this.registerAllPublications = value; + } + + public boolean isPublishAll() { + return this.registerAllPublications; } public void disableAutomaticPublicationRegistration() { diff --git a/buildSrc/src/main/groovy/net/minecraftforge/gradleutils/ChangelogUtils.groovy b/src/main/groovy/net/minecraftforge/gradleutils/ChangelogUtils.groovy similarity index 100% rename from buildSrc/src/main/groovy/net/minecraftforge/gradleutils/ChangelogUtils.groovy rename to src/main/groovy/net/minecraftforge/gradleutils/ChangelogUtils.groovy diff --git a/buildSrc/src/main/groovy/net/minecraftforge/gradleutils/GradleUtils.groovy b/src/main/groovy/net/minecraftforge/gradleutils/GradleUtils.groovy similarity index 100% rename from buildSrc/src/main/groovy/net/minecraftforge/gradleutils/GradleUtils.groovy rename to src/main/groovy/net/minecraftforge/gradleutils/GradleUtils.groovy diff --git a/src/main/groovy/net/minecraftforge/gradleutils/GradleUtilsExtension.groovy b/src/main/groovy/net/minecraftforge/gradleutils/GradleUtilsExtension.groovy index 0c514e6..d3879b7 100644 --- a/src/main/groovy/net/minecraftforge/gradleutils/GradleUtilsExtension.groovy +++ b/src/main/groovy/net/minecraftforge/gradleutils/GradleUtilsExtension.groovy @@ -131,4 +131,12 @@ class GradleUtilsExtension { static Closure getMinecraftLibsMaven() { return GradleUtils.getMinecraftLibsMaven() } + + /** + * Gets an instance of {@link PomUtils} allowing the groovy script to not need to import the PomUtils class. + */ + static PomUtils getPom() { + return POM_INSTANCE + } + private static final PomUtils POM_INSTANCE = new PomUtils() } diff --git a/src/main/groovy/net/minecraftforge/gradleutils/GradleUtilsPlugin.groovy b/src/main/groovy/net/minecraftforge/gradleutils/GradleUtilsPlugin.groovy index 7a61fd9..fcb4905 100644 --- a/src/main/groovy/net/minecraftforge/gradleutils/GradleUtilsPlugin.groovy +++ b/src/main/groovy/net/minecraftforge/gradleutils/GradleUtilsPlugin.groovy @@ -5,7 +5,6 @@ package net.minecraftforge.gradleutils import groovy.transform.CompileStatic -import net.minecraftforge.gradleutils.tasks.ExtractTeamCityProjectConfigurationTask import org.gradle.api.Plugin import org.gradle.api.Project @@ -17,7 +16,6 @@ class GradleUtilsPlugin implements Plugin { ChangelogGenerationExtension changelogGenerationExtension = project.extensions.create("changelog", ChangelogGenerationExtension, project) //Setup the teamcity project task. - project.tasks.register("setupTeamCityProject", ExtractTeamCityProjectConfigurationTask) GradleUtils.setupCITasks(project) } } diff --git a/src/main/groovy/net/minecraftforge/gradleutils/PomUtils.groovy b/src/main/groovy/net/minecraftforge/gradleutils/PomUtils.groovy index a357a1f..ce24f81 100644 --- a/src/main/groovy/net/minecraftforge/gradleutils/PomUtils.groovy +++ b/src/main/groovy/net/minecraftforge/gradleutils/PomUtils.groovy @@ -43,6 +43,14 @@ final class PomUtils { } } + /** + * Gets an instance of {@link Licenses} allowing the groovy script to not need to import the Licenses class. + */ + static Licenses getLicenses() { + return LICENSES_INSTANCE + } + private static final Licenses LICENSES_INSTANCE = new Licenses(); + public static final Map> Developers = [ LexManos: makeDev('LexManos', 'Lex Manos'), Paint_Ninja: makeDev('Paint_Ninja'), diff --git a/buildSrc/src/main/groovy/net/minecraftforge/gradleutils/tasks/GenerateChangelogTask.java b/src/main/groovy/net/minecraftforge/gradleutils/tasks/GenerateChangelogTask.java similarity index 100% rename from buildSrc/src/main/groovy/net/minecraftforge/gradleutils/tasks/GenerateChangelogTask.java rename to src/main/groovy/net/minecraftforge/gradleutils/tasks/GenerateChangelogTask.java diff --git a/teamcityTemplate/.teamcity/pom.xml b/teamcityTemplate/.teamcity/pom.xml deleted file mode 100644 index c9a058d..0000000 --- a/teamcityTemplate/.teamcity/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - 4.0.0 - %projectGroup%_%projectName% Config DSL Script - %projectGroup%_%projectName% - %projectGroup%_%projectName%_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/teamcityTemplate/.teamcity/settings.kts b/teamcityTemplate/.teamcity/settings.kts deleted file mode 100644 index 84365ef..0000000 --- a/teamcityTemplate/.teamcity/settings.kts +++ /dev/null @@ -1,71 +0,0 @@ -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("git_main_branch", "main", label = "Git Main Branch", description = "The git main or default branch to use in VCS operations.", display = ParameterDisplay.HIDDEN, allowEmpty = false) - text("github_repository_name", "%projectName%", label = "The github repository name. Used to connect to it in VCS Roots.", description = "This is the repository slug on github. So for example `%projectName%` or `MinecraftForge`. It is interpolated into the global VCS Roots.", display = ParameterDisplay.HIDDEN, allowEmpty = false) - text("env.PUBLISHED_JAVA_ARTIFACT_ID", "%projectArtifactId%", 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_GROUP", "%projectArtifactGroup%", label = "Published group", description = "The maven coordinate group that has been published by this build. Can not be empty.", allowEmpty = false) - text("docker_jdk_version", "%jdkVersion%", label = "JDK 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", "%gradleVersion%", label = "Gradle version", description = "The version of Gradle to use during execution of Gradle tasks.", display = ParameterDisplay.HIDDEN, allowEmpty = false) - } - - features { - githubIssues { - id = "%projectName%__IssueTracker" - displayName = "%projectOrg%/%projectName%" - repositoryURL = "https://github.com/%projectOrg%/%projectName%" - } - } -} - -object Build : BuildType({ - templates(AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_BuildMainBranches"), AbsoluteId("MinecraftForge_BuildUsingGradle"), AbsoluteId("MinecraftForge_PublishProjectUsingGradle"), AbsoluteId("MinecraftForge_TriggersStaticFilesWebpageGenerator")) - id("%projectName%__Build") - name = "Build" - description = "Builds and Publishes the main branches of the project." -}) - -object BuildSecondaryBranches : BuildType({ - templates(AbsoluteId("MinecraftForge_ExcludesBuildingDefaultBranch"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_BuildMainBranches"), AbsoluteId("MinecraftForge_BuildUsingGradle")) - id("%projectName%__BuildSecondaryBranches") - name = "Build - Secondary Branches" - description = "Builds and Publishes the secondary branches of the project." -}) - -object PullRequests : BuildType({ - templates(AbsoluteId("MinecraftForge_BuildPullRequests"), AbsoluteId("MinecraftForge_SetupGradleUtilsCiEnvironmen"), AbsoluteId("MinecraftForge_BuildWithDiscordNotifications"), AbsoluteId("MinecraftForge_BuildUsingGradle")) - id("%projectName%__PullRequests") - name = "Pull Requests" - description = "Builds pull requests for the project" -})