Skip to content
Open
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
25 changes: 9 additions & 16 deletions .github/workflows/build-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,15 @@ on:
- opened
- ready_for_review
- reopened
push:
branches:
- 'feature/**'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1000
fetch-tags: true
- name: Setup JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: build
uses: neoforged/actions/.github/workflows/build-prs.yml@main
with:
java: 17
gradle_tasks: build
jar_compatibility: false
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build:
uses: neoforged/actions/.github/workflows/gradle-publish.yml@main
with:
java: 8
java: 17
version_task: 'configureGitHubActions'
gradle_tasks: 'publish publishPlugins'
secrets:
Expand All @@ -21,4 +21,4 @@ jobs:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_KEY_PASSWORD: ${{ secrets.GPG_KEY_PASSWORD }}
GPP_KEY: ${{ secrets.GPP_KEY }}
GPP_SECRET: ${{ secrets.GPP_SECRET }}
GPP_SECRET: ${{ secrets.GPP_SECRET }}
55 changes: 21 additions & 34 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ plugins {
id 'java-gradle-plugin'
id 'groovy'
id 'maven-publish'
id 'org.cadixdev.licenser' version '0.6.1'
id 'com.gradle.plugin-publish' version '1.1.0'
id 'net.neoforged.licenser' version '0.7.5'
id 'com.gradle.plugin-publish' version '2.0.0'
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
languageVersion = JavaLanguageVersion.of(17)
}
withSourcesJar()
}
Expand All @@ -25,18 +25,6 @@ repositories {
gradlePluginPortal()
}

// Immaculate runs on J17
tasks.named('compileImmaculateJava', JavaCompile).configure {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(17)
}
}
tasks.named('compileImmaculateGroovy', GroovyCompile).configure {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
}

if (System.getenv('GPP_KEY')) {
project.ext {
set('gradle.publish.key', System.getenv('GPP_KEY'))
Expand All @@ -49,7 +37,7 @@ configurations {
}

dependencies {
api 'org.eclipse.jgit:org.eclipse.jgit:5.10.0.202012080955-r'
api 'org.eclipse.jgit:org.eclipse.jgit:7.6.0.202603022253-r'
api 'io.github.gradle-nexus:publish-plugin:2.0.0'

api("net.neoforged:groovydslimprover:${gdi_version}") {
Expand All @@ -59,7 +47,7 @@ dependencies {
}

immaculateImplementation(gradleApi())
immaculateImplementation "dev.lukebemish.immaculate:dev.lukebemish.immaculate.gradle.plugin:0.1.6"
immaculateImplementation "dev.lukebemish.immaculate:dev.lukebemish.immaculate.gradle.plugin:0.2.4"
}

sourceSets {
Expand All @@ -77,22 +65,20 @@ tasks.named(sourceSets.main.processResourcesTaskName, Copy) {
}

tasks.named('jar', Jar) {
try {
final ByteArrayOutputStream bos = new ByteArrayOutputStream()
project.exec {
commandLine('git', 'rev-parse', 'HEAD')
standardOutput(bos)
}.rethrowFailure().assertNormalExitValue()

final gitCommit = new String(bos.toByteArray())
// Store the git commit as the Implementation-Version of the tasks package
// TODO - re-evaluate: find a better way of storing this sha for use in template generation
manifest.attributes([
'Implementation-Version': gitCommit
], 'net/neoforged/gradleutils/tasks/')
} catch (Exception ex) {
throw new IllegalStateException("Failed to determine the latest commit hash; check if 'git' is on the PATH", ex)
var gitCommitResult = project.providers.exec {
commandLine('git', 'rev-parse', 'HEAD')
}
var gitCommit = gitCommitResult.result.zip(gitCommitResult.standardOutput.asText) { result, stdout ->
result.rethrowFailure()
result.assertNormalExitValue()
stdout
}

// Store the git commit as the Implementation-Version of the tasks package
// TODO - re-evaluate: find a better way of storing this sha for use in template generation
manifest.attributes([
'Implementation-Version': gitCommit.get()
], 'net/neoforged/gradleutils/tasks/')
}

license {
Expand All @@ -110,7 +96,7 @@ license {

gradlePlugin {
website = 'https://github.com/neoforged/GradleUtils'
vcsUrl = 'https://github.com/neoforged/GradleUtils.git'
vcsUrl = 'https://github.com/neoforged/GradleUtils.git'

plugins {
gradleutils {
Expand Down Expand Up @@ -225,7 +211,8 @@ abstract class GenerateChangelogTask extends DefaultTask {
@OutputFile
abstract RegularFileProperty getChangelogFile()

@javax.inject.Inject // This might look like a compile error in IDE, but it actually compiles okay
@javax.inject.Inject
// This might look like a compile error in IDE, but it actually compiles okay
abstract ExecOperations getExecOperations()

@TaskAction
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
gdi_version=1.0.15
gdi_version=2.0.0

org.gradle.configuration-cache=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Comment thread
sciwhiz12 marked this conversation as resolved.
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
15 changes: 7 additions & 8 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven { url = 'https://maven.neoforged.net/releases' }
Comment thread
sciwhiz12 marked this conversation as resolved.
}
}

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
}

rootProject.name = 'GradleUtils'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import groovy.transform.NamedVariant
import groovy.transform.PackageScope
import io.github.gradlenexus.publishplugin.NexusPublishExtension
import io.github.gradlenexus.publishplugin.NexusPublishPlugin
import net.minecraftforge.gdi.annotations.DSLProperty
import net.minecraftforge.gdi.annotations.ProjectGetter
import net.neoforged.gdi.annotations.DSLProperty
import net.neoforged.gdi.annotations.ProjectGetter
import net.neoforged.gradleutils.specs.VersionSpec
import org.gradle.api.Action
import org.gradle.api.Project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package net.neoforged.gradleutils.specs

import groovy.transform.CompileStatic
import net.minecraftforge.gdi.annotations.DSLProperty
import net.neoforged.gdi.annotations.DSLProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.SetProperty
import org.gradle.api.tasks.Input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
package net.neoforged.gradleutils.specs

import groovy.transform.CompileStatic
import net.minecraftforge.gdi.annotations.DSLProperty
import net.neoforged.gdi.annotations.DSLProperty
import net.neoforged.gradleutils.InternalAccessor
import org.gradle.api.Action
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Nested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package net.neoforged.gradleutils.specs

import groovy.transform.CompileStatic
import net.minecraftforge.gdi.annotations.DSLProperty
import net.neoforged.gdi.annotations.DSLProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.SetProperty
import org.gradle.api.tasks.Input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.options.Option;
import org.gradle.jvm.toolchain.JavaLanguageVersion;
import org.gradle.work.DisableCachingByDefault;

import java.io.File;
import java.io.FileOutputStream;
Expand All @@ -27,9 +28,10 @@
import java.util.List;
import java.util.zip.ZipEntry;

@DisableCachingByDefault(because = "Task deletes its output directory")
public abstract class CIConfigExtractionTask extends DefaultTask {

Check warning on line 32 in src/main/groovy/net/neoforged/gradleutils/tasks/CIConfigExtractionTask.java

View workflow job for this annotation

GitHub Actions / build / build

no comment
private final String templateZipName, targetDirName;
protected CIConfigExtractionTask(String templateZipName, String targetDirName) {

Check warning on line 34 in src/main/groovy/net/neoforged/gradleutils/tasks/CIConfigExtractionTask.java

View workflow job for this annotation

GitHub Actions / build / build

no comment
this.templateZipName = templateZipName;
this.targetDirName = targetDirName;
getDestination().convention(getProject().getRootProject().getLayout().getProjectDirectory().dir(getProject().provider(() -> "./")));
Expand All @@ -38,7 +40,7 @@
}

@TaskAction
public void run() throws Exception {

Check warning on line 43 in src/main/groovy/net/neoforged/gradleutils/tasks/CIConfigExtractionTask.java

View workflow job for this annotation

GitHub Actions / build / build

no comment
//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.
Expand All @@ -65,11 +67,11 @@
extractZip(fileZip, destDir);
}

protected abstract void extractZip(String fileZip, File destDir) throws Exception;

Check warning on line 70 in src/main/groovy/net/neoforged/gradleutils/tasks/CIConfigExtractionTask.java

View workflow job for this annotation

GitHub Actions / build / build

no comment

@InputDirectory
@PathSensitive(PathSensitivity.NONE)
public abstract DirectoryProperty getDestination();

Check warning on line 74 in src/main/groovy/net/neoforged/gradleutils/tasks/CIConfigExtractionTask.java

View workflow job for this annotation

GitHub Actions / build / build

no comment

/**
* Creates a new file or directory.
Expand All @@ -78,7 +80,7 @@
* @param zipEntry The entry in the .teamcity.zip file.
* @return The new file or directory.
*/
protected static File newFile(File destinationDir, ZipEntry zipEntry) throws Exception {

Check warning on line 83 in src/main/groovy/net/neoforged/gradleutils/tasks/CIConfigExtractionTask.java

View workflow job for this annotation

GitHub Actions / build / build

no @throws for java.lang.Exception
File destFile = new File(destinationDir, zipEntry.getName());

String destDirPath = destinationDir.getCanonicalPath();
Expand All @@ -91,7 +93,7 @@
return destFile;
}

protected String determineJDKVersion() {

Check warning on line 96 in src/main/groovy/net/neoforged/gradleutils/tasks/CIConfigExtractionTask.java

View workflow job for this annotation

GitHub Actions / build / build

no comment
if (getProject().getExtensions().findByType(JavaPluginExtension.class) == null) {
getProject().getLogger().warn("Could not find the Java extension, falling back to JDK 8.");
return "8";
Expand Down Expand Up @@ -135,7 +137,7 @@
private boolean deleteExisting;

@Input
public boolean getDeleteExisting() {

Check warning on line 140 in src/main/groovy/net/neoforged/gradleutils/tasks/CIConfigExtractionTask.java

View workflow job for this annotation

GitHub Actions / build / build

no comment
return this.deleteExisting;
}

Expand All @@ -147,7 +149,7 @@
/**
* Finds the most common prefix of all {@code groups}.
*/
protected static String findCommonPrefix(List<String> groups) {

Check warning on line 152 in src/main/groovy/net/neoforged/gradleutils/tasks/CIConfigExtractionTask.java

View workflow job for this annotation

GitHub Actions / build / build

Check warning on line 152 in src/main/groovy/net/neoforged/gradleutils/tasks/CIConfigExtractionTask.java

View workflow job for this annotation

GitHub Actions / build / build

no @param for groups
if (groups.isEmpty()) {
return "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.gradle.api.plugins.BasePluginExtension;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.options.Option;
import org.gradle.work.DisableCachingByDefault;

import java.io.File;
import java.io.FileInputStream;
Expand All @@ -25,6 +26,7 @@
/**
* Task to extract the GitHub Action workflows from the included template zip file.
*/
@DisableCachingByDefault(because = "Task deletes its output directory")
public abstract class ExtractActionsWorkflowsTask extends CIConfigExtractionTask {

public ExtractActionsWorkflowsTask() {
Expand Down
Loading