Skip to content

Commit

Permalink
Use the new JARRemapperDev plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
YoungerMax committed Dec 24, 2021
1 parent 0e24f10 commit c9892fa
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 339 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ build/

/output.jar

src/test/resources/mappings
src/test/resources/minecraft-*
src/test/resources/*
src/test/java/com/pocolifo/jarremapper/tests/*
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Making remapping JARs easy, organized, and painless
#### Remapping Engines
- Multiple different engines to remap JARs
- StandardRemappingEngine by the devs of JAR Remapper
- FabricMC's TinyRemapper using a Remapping Engine (*requires extension dependency*)
- FabricMC's TinyRemapper using a Remapping Engine (*requires additional dependency, see [jar-remapper-extension](https://github.com/pocolifo/jar-remapper-extension)*)

#### Remapping
- Class remapping
Expand Down Expand Up @@ -89,4 +89,8 @@ JarRemapper.newRemap()

1. Clone this repository
2. Import the project into IntelliJ IDEA
3. Run the `setup` Gradle task

### To test
1. Edit the `jarremapper` extension configuration in [build.gradle](build.gradle) to add readers and engines
2. Run the `generateTests` Gradle task under the `jarremapperdev` group to generate test classes
3. Test like normal
314 changes: 90 additions & 224 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java'
id 'maven-publish'
id 'de.undercouch.download' version '4.1.2'
id 'java'
id 'maven-publish'
id 'com.pocolifo.jarremapper.devplugin' version '1.0-SNAPSHOT'
}

group 'com.pocolifo'
Expand All @@ -10,236 +10,102 @@ version '2.0.0'
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
implementation 'org.ow2.asm:asm-commons:9.2'
implementation 'org.ow2.asm:asm-commons:9.2'

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
}

test {
useJUnitPlatform()
useJUnitPlatform()
}

publishing {
publications {
maven(MavenPublication) {
pom {
name = 'JAR Remapper'
description = 'Library for remapping JARs'
artifactId = 'jar-remapper'

licenses {
license {
name = 'Mozilla Public License 2.0'
url = 'https://www.mozilla.org/en-US/MPL/2.0/'
}
}

developers {
developer {
id = 'youngermax'
}
}
}

from components.java
}
}

repositories {
mavenLocal()
}
}

final legacyYarnVersion = '1.8.9+build.202110031151'

final resources = new File('src/test/resources')
final mappings = new File(resources, 'mappings')
final mcp = new File(mappings, 'mcp')

final mcp_189 = new File(mcp, '1.8.9')
final yarn1 = new File(mappings, 'yarn')
final yarn2merged = new File(mappings, 'yarnv2')

task setupDirectories {
mcp_189.mkdirs()
yarn1.mkdirs()
yarn2merged.mkdirs()
// jarremapper-dev plugin extension
// - downloads mappings
// - downloads input jars
// - automatically generates tests base on readers, engines, mappings, and input jars
jarremapper {
// how to use the jarremapper extension:

// mappings to use.
// mcp format: mcp/<channel>/<minecraft version>/<mappings version>
// yarn (legacyfabric & fabric) format: <(legacyfabric|fabric)>/<minecraft version>/<build id>
mappings = [
// mcp
'mcp/stable/1.8.9/22',

// legacyfabric
'legacyfabric/1.8.9/202112162000',

// fabric
'fabric/1.18.1/1'
]

// minecraft binaries to use.
// format: <(client|server)>/<minecraft version>/<binary hash>
minecraft = ['client/1.8.9/3870888a6c3d349d3771a3e9d16c9bf5e076b908',
'client/1.18.1/7e46fb47609401970e2818989fa584fd467cd036']

// mapping readers to generate tests for.
// format: <canonical path of reader class>/<how to obtain a JarMapping>/<mappings this applies to>(+<more mappings>+...): [<files required for constructing>]
readers = ['com.pocolifo.jarremapper.reader.mcp.McpMappingReader/.read()/mcp': ['joined.srg', 'joined.exc', 'methods.csv', 'fields.csv', 'params.csv'],
'com.pocolifo.jarremapper.reader.tiny.Tiny1MappingReader/.read(\"official\", \"named\")/fabric+legacyfabric': ['mappings.tiny'],
'com.pocolifo.jarremapper.reader.tiny.Tiny2MappingReader/.read(\"official\", \"named\")/fabric+legacyfabric': ['mappings-merged.tiny']]

// remapping engines to generate tests for.
// format: <canonical name of engine>/<how to obtain an AbstractRemappingEngine>
engines = [
// all StandardRemappingEngine options
'com.pocolifo.jarremapper.engine.standard.StandardRemappingEngine/new StandardRemappingEngine()',
'com.pocolifo.jarremapper.engine.standard.StandardRemappingEngine/new StandardRemappingEngine().excludeMetaInf()',
'com.pocolifo.jarremapper.engine.standard.StandardRemappingEngine/new StandardRemappingEngine().setRemappingPlugin(new com.pocolifo.jarremapper.SimpleProgressListener())',
'com.pocolifo.jarremapper.engine.standard.StandardRemappingEngine/new StandardRemappingEngine().setRemappingPlugin(new com.pocolifo.jarremapper.SimpleProgressListener()).excludeMetaInf()'
]
}

// minecraft 1.8.9
task mcpMappings189(dependsOn: setupDirectories) {
final csv = new File(mcp_189, 'stable.zip')
final srg = new File(mcp_189, 'srg.zip')

// csv: params.csv, fields.csv, methods.csv
download {
src 'https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp_stable/22-1.8.9/mcp_stable-22-1.8.9.zip'
dest csv
overwrite false
}

copy {
from zipTree(csv)
into mcp_189
}

delete csv

// srg: joined.srg. joined.exc
download {
src 'https://maven.minecraftforge.net/de/oceanlabs/mcp/mcp/1.8.9/mcp-1.8.9-srg.zip'
dest srg
overwrite false
}



copy {
from zipTree(srg).matching {
include 'joined.srg', 'joined.exc'
}
into mcp_189
}

delete srg
}

task yarn189(dependsOn: setupDirectories) {
final yarn1_dest = new File(yarn1, legacyYarnVersion + '.jar')
final yarn2_dest = new File(yarn2merged, legacyYarnVersion + '-mergedv2.jar')

// yarn v1
download {
src 'https://maven.legacyfabric.net/net/fabricmc/yarn/' + legacyYarnVersion + '/yarn-' + legacyYarnVersion + '.jar'
dest yarn1_dest
overwrite true
}

copy {
from zipTree(yarn1_dest).filter {
it.isFile() && it.name == 'mappings.tiny'
}.singleFile

into yarn1

rename {
'mappings.tiny'
'mappings-1.8.9.tiny'
}
}

delete yarn1_dest

// yarn v2 merged
download {
src 'https://maven.legacyfabric.net/net/fabricmc/yarn/' + legacyYarnVersion + '/yarn-' + legacyYarnVersion + '-mergedv2.jar'
dest yarn2_dest
overwrite true
}

copy {
from zipTree(yarn2_dest).filter {
it.isFile() && it.name == 'mappings.tiny'
}.singleFile

into yarn2merged

rename {
'mappings.tiny'
'mappings-merged-v2-1.8.9.tiny'
}
}

delete yarn2_dest
}

task minecraft189(type: Download, dependsOn: setupDirectories) {
src 'https://launcher.mojang.com/v1/objects/3870888a6c3d349d3771a3e9d16c9bf5e076b908/client.jar'
dest new File(resources, 'minecraft-1.8.9.jar')
overwrite true
}

task setup189 {
dependsOn setupDirectories
dependsOn mcpMappings189
dependsOn yarn189
dependsOn minecraft189
}

// minecraft latest
// updated to 1.17.1
final String yarn = '1.17.1+build.61'
final String mc = '1.17.1'

task minecraftLatest(type: Download, dependsOn: setupDirectories) {
// needs to be updated
src 'https://launcher.mojang.com/v1/objects/8d9b65467c7913fcf6f5b2e729d44a1e00fde150/client.jar'
dest new File(resources, 'minecraft-' + mc + '.jar')
overwrite true
}

task yarnLatest(dependsOn: setupDirectories) {
final yarn1_dest = new File(yarn1, yarn + '.jar')
final yarn2_dest = new File(yarn2merged, yarn + '-mergedv2.jar')

// yarn v1
download {
src 'https://maven.fabricmc.net/net/fabricmc/yarn/' + yarn + '/yarn-' + yarn + '.jar'
dest yarn1_dest
overwrite true
}

copy {
from zipTree(yarn1_dest).filter {
it.isFile() && it.name == 'mappings.tiny'
}.singleFile

into yarn1

rename {
'mappings.tiny'
'mappings-' + mc + '.tiny'
}
}

delete yarn1_dest

// yarn v2 merged
download {
src 'https://maven.fabricmc.net/net/fabricmc/yarn/' + yarn + '/yarn-' + yarn + '-mergedv2.jar'
dest yarn2_dest
overwrite true
}

copy {
from zipTree(yarn2_dest).filter {
it.isFile() && it.name == 'mappings.tiny'
}.singleFile

into yarn2merged

rename {
'mappings.tiny'
'mappings-merged-v2-' + mc + '.tiny'
}
}

delete yarn2_dest
}

task setupLatest {
dependsOn setupDirectories
dependsOn minecraftLatest
dependsOn yarnLatest
publishing {
publications {
maven(MavenPublication) {
pom {
name = 'JAR Remapper'
description = 'Library for remapping JARs'
artifactId = 'jarremapper'

licenses {
license {
name = 'Mozilla Public License 2.0'
url = 'https://www.mozilla.org/en-US/MPL/2.0/'
}
}

developers {
developer {
id = 'youngermax'
}
}
}

from components['java']
}
}

repositories {
maven {
url System.getenv("REPO_URL")
name 'pocolifo'

credentials {
username = System.getenv("REPO_USERNAME")
password = System.getenv("REPO_PASSWORD")
}

authentication {
basic(BasicAuthentication)
}
}
}
}

// setup all
task setup {
dependsOn setup189
dependsOn setupLatest
}
10 changes: 9 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
rootProject.name = 'jar-remapper'
pluginManagement {
repositories {
maven {
url 'https://maven.services.pocolifo.com'
name 'Pocolifo'
}
}
}

rootProject.name = 'jarremapper'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.pocolifo.jarremapper.test;
package com.pocolifo.jarremapper;

import com.pocolifo.jarremapper.mapping.ClassMapping;
import com.pocolifo.jarremapper.engine.standard.IRemappingPlugin;
Expand Down
Loading

0 comments on commit c9892fa

Please sign in to comment.