Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Gradle, use Mapping-io, add action to test #28

Merged
merged 4 commits into from
Apr 21, 2023
Merged
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
9 changes: 4 additions & 5 deletions .github/workflows/re-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
container:
image: openjdk:15-jdk
image: gradle:8.1.0-jdk17
options: --user root
steps:
- uses: actions/checkout@v1
- uses: gradle/wrapper-validation-action@v1
- run: ./gradlew build publish --stacktrace
- uses: actions/checkout@v3
- run: gradle build publish --stacktrace
env:
MAVEN_URL: ${{ secrets.MAVEN_URL }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ on:
- master
jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
container:
image: openjdk:15-jdk
image: gradle:8.1.0-jdk17
options: --user root
steps:
- uses: actions/checkout@v1
- uses: gradle/wrapper-validation-action@v1
- run: ./gradlew build publish --stacktrace
- uses: actions/checkout@v3
- run: gradle build publish --stacktrace
env:
MAVEN_URL: ${{ secrets.MAVEN_URL }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-22.04
container:
image: gradle:8.1.0-jdk17
options: --user root
steps:
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
- run: gradle build publishToMavenLocal --stacktrace --warning-mode fail
env:
FORCE_PUBLISH: 1.19.4
- uses: actions/upload-artifact@v3
with:
name: Maven Local
path: /root/.m2/repository
61 changes: 30 additions & 31 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import cuchaz.enigma.command.ConvertMappingsCommand

buildscript {
repositories {
maven {
Expand All @@ -9,22 +7,27 @@ buildscript {
}

dependencies {
classpath "cuchaz:enigma:0.14.2.138"
classpath "net.fabricmc:mapping-io:0.3.0"
}
}

plugins {
id 'maven'
id 'maven-publish'
}

import net.fabricmc.mappingio.MappingReader;
import net.fabricmc.mappingio.MappingWriter;
import net.fabricmc.mappingio.format.MappingFormat;

static List<String> getPublishedVersions() {
def xml = new URL("https://maven.fabricmc.net/net/fabricmc/intermediary/maven-metadata.xml").text
def metadata = new XmlSlurper().parseText(xml)
def metadata = new groovy.xml.XmlSlurper().parseText(xml)
def versions = metadata.versioning.versions.version*.text();
return versions
}

tasks.register("build")

def publishedVersions = getPublishedVersions()

def ENV = System.getenv()
Expand All @@ -37,53 +40,48 @@ file('mappings').eachFile {

def mcVer = it.name.replace(".tiny", "")

if (publishedVersions.contains(mcVer) && !(ENV.FORCE_PUBLISH == mcVer)) {
project.logger.lifecycle("Skipping ${mcVer} as it has already been released")
return
} else {
project.logger.lifecycle("Building ${mcVer}")
}

published = true

File v1MappingFile = it
File v2MappingFile = new File("$localMappingsPath/${it.name}")

def conversionTask = "convert${it.name}ToV2"
tasks.register(conversionTask) {
def conversionTask = tasks.register("convert${it.name}ToV2") {
group = "V2 Conversion"
inputs.file(v1MappingFile)
outputs.file(v2MappingFile)

doLast {
new ConvertMappingsCommand().run(
"tiny",
v1MappingFile.path,
"tinyv2:official:intermediary",
v2MappingFile.path
)
MappingWriter.create(v2MappingFile.toPath(), MappingFormat.TINY_2).withCloseable {
MappingReader.read(v1MappingFile.toPath(), it)
}
}
}

Jar makeV1Jar = makeJar(mcVer, v1MappingFile, false)
Jar makeV2Jar = makeJar(mcVer, v2MappingFile, true)
def makeV1Jar = makeJar(mcVer, v1MappingFile, false)
def makeV2Jar = makeJar(mcVer, v2MappingFile, true)
makeV2Jar.configure {
dependsOn conversionTask
}

if (publishedVersions.contains(mcVer) && !(ENV.FORCE_PUBLISH == mcVer)) {
project.logger.lifecycle("Skipping ${mcVer} as it has already been released")
return
}

project.logger.lifecycle("Publishing ${mcVer}")
published = true

build.dependsOn makeV1Jar
build.dependsOn makeV2Jar

makeV2Jar.dependsOn conversionTask

publishing {
publications {
create("${mcVer.replace(" ", "")}_mavenJava", MavenPublication) {
groupId 'net.fabricmc'
artifactId "intermediary"
version mcVer
artifact(makeV1Jar.archiveFile) {
artifact(makeV1Jar.get().archiveFile) {
builtBy makeV1Jar
}
artifact(makeV2Jar.archiveFile) {
artifact(makeV2Jar.get().archiveFile) {
builtBy makeV2Jar
classifier = "v2"
}
Expand All @@ -97,9 +95,10 @@ if (!published) {
}

def makeJar(String mcVersion, File mappings, boolean v2) {
def jarFilename = "intermediary-" + mcVersion + (v2 ? "-v2" : "")
return task("${mcVersion}_makeJar" + (v2 ? "v2" : ""), type: Jar) {
baseName jarFilename
def jarFilename = "intermediary-" + mcVersion + (v2 ? "-v2" : "") + ".jar"
return tasks.register("${mcVersion}_makeJar" + (v2 ? "v2" : ""), Jar) {
archiveFileName = jarFilename
group = "jar"
from(file(mappings)) {
into "mappings"
rename mappings.name, "mappings.tiny"
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading