Skip to content

Commit

Permalink
Add a PR workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Dec 9, 2024
1 parent 60a5526 commit bde60d4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 185 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/build-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1000
fetch-tags: true

# Switch to a new branch with the PR number and PR branch name,
# for the projects where the buildscript uses the branch name
- name: Create branch for commit
run:
git switch -C pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.ref }}

- name: Setup Java ${{ inputs.java }}
uses: neoforged/actions/setup-java@main
Expand Down Expand Up @@ -77,6 +68,11 @@ jobs:
# the maven-metadata will only be from a single repo and thus wrong
- name: Remove incorrect maven-metadata files
run: find -name maven-metadata.xml* -exec rm {} \;
- name: Upload repository for manual consumption
uses: actions/upload-artifact@v4
with:
name: repo
path: repo
- name: Upload repository for PR-Publishing
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 0 additions & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ repositories {

dependencies {
implementation 'de.undercouch.download:de.undercouch.download.gradle.plugin:5.5.0'
implementation 'org.apache.maven:maven-artifact:3.9.9'
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package net.neoforged.minecraftdependencies
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import groovy.transform.CompileStatic
import org.apache.maven.artifact.versioning.ComparableVersion
import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
Expand Down Expand Up @@ -48,7 +47,7 @@ abstract class GenerateModuleMetadata extends DefaultTask implements HasMinecraf
// 1.7.10 server jar contained guava 16 instead of 15
"com.google.guava:guava:15.0", "com.google.guava:guava:16.0",
"org.apache.commons:commons-lang3:3.1", "org.apache.commons:commons-lang3:3.2.1"
);
)

@TaskAction
void run() {
Expand All @@ -63,10 +62,9 @@ abstract class GenerateModuleMetadata extends DefaultTask implements HasMinecraf
metadata.variants = variants

List<String> clientDeps = []
List<String> clientCompileOnlyDeps = []
List<String> serverDeps = []
Map<String, List<String>> clientNatives = [:]
getMcDeps(serverDeps, clientDeps, clientCompileOnlyDeps, clientNatives)
getMcDeps(serverDeps, clientDeps, clientNatives)

Map metaJson = new JsonSlurper().parse(meta.get().asFile) as Map
int javaVersion = (metaJson.javaVersion as Map).majorVersion as int
Expand Down Expand Up @@ -95,7 +93,6 @@ abstract class GenerateModuleMetadata extends DefaultTask implements HasMinecraf
if (objcBridge) {
clientDepEntries.add(depOf(objcBridge))
}
clientDepEntries.addAll(depsOf(clientCompileOnlyDeps))

variants.add([
name : 'clientCompileDependencies',
Expand Down Expand Up @@ -222,7 +219,7 @@ abstract class GenerateModuleMetadata extends DefaultTask implements HasMinecraf
return hashes
}

private void getMcDeps(List<String> server, List<String> client, List<String> clientCompileOnly, Map<String, List<String>> clientNatives) {
private void getMcDeps(List<String> server, List<String> client, Map<String, List<String>> clientNatives) {
Map metaJson = new JsonSlurper().parse(meta.get().asFile) as Map
(metaJson.libraries as List<Map<String, Object>>).each { Map lib ->
Map downloads = lib.downloads as Map
Expand All @@ -246,50 +243,6 @@ abstract class GenerateModuleMetadata extends DefaultTask implements HasMinecraf
}
}
}

// Remove duplicates in natives
for (var libs in clientNatives.values()) {
var dedupedLibs = new LinkedHashSet(libs)
libs.clear()
libs.addAll(dedupedLibs)
}

// Promote natives to compile time dependencies if the same G+A+Classifier is present for all platforms
// Use the lowest version. This happens on some versions (i.e. 1.18.2) where lwjgl and all such dependencies
// are used in a lower version on OSX
for (String windowNativeArtifact in clientNatives.getOrDefault(platforms[0], [])) {
var coordinate = MavenCoordinate.parse(windowNativeArtifact)
var version = new ComparableVersion(coordinate.version())

var inAllPlatforms = true
for (var otherPlatform in platforms.drop(1)) {
var found = false
for (var otherPlatformArtifact in clientNatives.getOrDefault(otherPlatform, [])) {
var otherPlatformCoordinate = MavenCoordinate.parse(otherPlatformArtifact)
if (coordinate.equalsIgnoringVersion(otherPlatformCoordinate)) {
found = true
var otherVersion = new ComparableVersion(otherPlatformCoordinate.version())
if (otherVersion < version) {
version = otherVersion // use lowest
}
break
}
}
if (!found) {
inAllPlatforms = false
break
}
}

if (inAllPlatforms) {
println("Promoting " + coordinate + " (" + version + ") from natives to compile time dependency")
coordinate = coordinate.withVersion(version.toString())
if (client.stream().map(MavenCoordinate::parse).noneMatch { c -> c.equalsIgnoringVersion(coordinate) }) {
clientCompileOnly.add(coordinate.toString())
}
}
}

try (def zf = new ZipFile(serverJar.get().getAsFile())) {
def librariesListEntry = zf.getEntry('META-INF/libraries.list')
if (librariesListEntry != null) {
Expand Down

This file was deleted.

4 changes: 1 addition & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ group=net.neoforged

org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache=true

minecraftVersion=1.7.2
org.gradle.configuration-cache=true

0 comments on commit bde60d4

Please sign in to comment.