Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Oct 25, 2024
2 parents 5416ec4 + 55bc832 commit 0344b5b
Show file tree
Hide file tree
Showing 31 changed files with 593 additions and 259 deletions.
32 changes: 32 additions & 0 deletions docs/MULTIPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ unimined.minecraft {
accessWidener {
accessWidener "src/main/resources/accessWidenerName.aw"
}
// you may want to set this if you want to include architectury mods in common
mods.modImplementation {
namespace("intermediary")
}
// if you don't want to build/remap a "common" jar
if (sourceSet == sourceSets.main) {
defaultRemapJar = false
}
}
// if not disabling remapJar above,
// you may want to set this so the "common" jar is in intermediary to match architectury
tasks.named("remapJar") {
prodNamespace("intermediary")
}
// forge
Expand Down Expand Up @@ -80,6 +96,22 @@ unimined.minecraft {
accessWidener {
accessWidener "src/main/resources/accessWidenerName.aw"
}
// you may want to set this if you want to include arch mods in common
mods.modImplementation {
namespace("intermediary")
}
// if you don't want to build/remap a "common" jar
if (sourceSet == sourceSets.main) {
defaultRemapJar = false
}
}
// if not disabling remapJar above,
// you may want to set this so the "common" jar is in intermediary to match architectury
tasks.named("remapJar") {
prodNamespace("intermediary")
}
```

Expand Down
9 changes: 8 additions & 1 deletion docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ configurations {
unimined.minecraft {
...
mods {
remap(configurations.modCompileOnly)
remap(configurations.modCompileOnly) {
}
// this is basically just a shortcut for `remap(configurations.modImplementation)`
modImplementation {
// you can do this is mods have the wrong access widener mapping, but it may break runs
catchAWNamespaceAssertion()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import xyz.wagyourtail.unimined.api.minecraft.resolver.MinecraftData
import xyz.wagyourtail.unimined.api.mod.ModsConfig
import xyz.wagyourtail.unimined.api.runs.RunsConfig
import xyz.wagyourtail.unimined.api.source.SourceConfig
import xyz.wagyourtail.unimined.api.minecraft.task.AbstractRemapJarTask
import xyz.wagyourtail.unimined.api.minecraft.task.RemapJarTask
import xyz.wagyourtail.unimined.api.minecraft.task.RemapSourcesJarTask
import xyz.wagyourtail.unimined.api.unimined
import xyz.wagyourtail.unimined.mapping.EnvType
import xyz.wagyourtail.unimined.mapping.Namespace
Expand Down Expand Up @@ -183,7 +185,7 @@ abstract class MinecraftConfig(val project: Project, val sourceSet: SourceSet) :
val proj = this.project.project(path)
combineWith(proj, proj.sourceSets.getByName(name))
}
};
}

/**
* the minecraft version to use
Expand Down Expand Up @@ -260,6 +262,63 @@ abstract class MinecraftConfig(val project: Project, val sourceSet: SourceSet) :
}
}

/**
* @since 1.3.10
*/
fun remapSources(task: Task) {
remapSources(task) {}
}

/**
* @since 1.3.10
*/
fun remapSources(task: Task, action: RemapSourcesJarTask.() -> Unit) {
remapSources(task, "remap${task.name.capitalized()}", action)
}

/**
* @since 1.3.10
*/
fun remapSources(
task: Task,
@DelegatesTo(value = RemapSourcesJarTask::class, strategy = Closure.DELEGATE_FIRST)
action: Closure<*>
) {
remapSources(task) {
action.delegate = this
action.resolveStrategy = Closure.DELEGATE_FIRST
action.call()
}
}

/**
* @since 1.3.10
*/
fun remapSources(task: Task, name: String) {
remapSources(task, name) {}
}

/**
* @since 1.3.10
*/
abstract fun remapSources(task: Task, name: String, action: RemapSourcesJarTask.() -> Unit)

/**
* @since 1.3.10
*/
fun remapSources(
task: Task,
name: String,
@DelegatesTo(value = RemapSourcesJarTask::class, strategy = Closure.DELEGATE_FIRST)
action: Closure<*>
) {
remapSources(task, name) {
action.delegate = this
action.resolveStrategy = Closure.DELEGATE_FIRST
action.call()
}
}

fun mods(action: ModsConfig.() -> Unit) {
mods.action()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
import org.gradle.api.file.FileCollection
import org.jetbrains.annotations.ApiStatus
import org.objectweb.asm.tree.ClassNode
import xyz.wagyourtail.unimined.api.minecraft.task.AbstractRemapJarTask
import xyz.wagyourtail.unimined.api.minecraft.task.RemapJarTask
import xyz.wagyourtail.unimined.mapping.Namespace
import java.nio.file.FileSystem
Expand Down Expand Up @@ -53,10 +54,10 @@ interface MinecraftPatcher {
}

@ApiStatus.Internal
fun beforeRemapJarTask(remapJarTask: RemapJarTask, input: Path): Path
fun beforeRemapJarTask(remapJarTask: AbstractRemapJarTask, input: Path): Path

@ApiStatus.Internal
fun afterRemapJarTask(remapJarTask: RemapJarTask, output: Path)
fun afterRemapJarTask(remapJarTask: AbstractRemapJarTask, output: Path)

@get:ApiStatus.Internal
@set:ApiStatus.Experimental
Expand All @@ -67,7 +68,7 @@ interface MinecraftPatcher {
var unprotectRuntime: Boolean

@ApiStatus.Internal
fun configureRemapJar(task: RemapJarTask)
fun configureRemapJar(task: AbstractRemapJarTask)

@ApiStatus.Internal
fun createSourcesJar(classpath: FileCollection, patchedJar: Path, outputPath: Path, linemappedPath: Path?)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package xyz.wagyourtail.unimined.api.minecraft.task

import groovy.lang.Closure
import groovy.lang.DelegatesTo
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.bundling.Jar
import org.jetbrains.annotations.ApiStatus
import xyz.wagyourtail.unimined.api.mapping.mixin.MixinRemapOptions
import xyz.wagyourtail.unimined.mapping.Namespace
import xyz.wagyourtail.unimined.util.FinalizeOnRead

/**
* task responsible for transforming your built jar to production.
* @since 0.1.0
*/
@Suppress("LeakingThis")
abstract class AbstractRemapJarTask : Jar() {

@get:InputFile
abstract val inputFile: RegularFileProperty

@get:Internal
@set:Internal
var devNamespace: Namespace? by FinalizeOnRead(null)

@get:Internal
@set:Internal
var prodNamespace: Namespace? by FinalizeOnRead(null)

/**
* whether to remap AccessTransformers to the legacy format (<=1.7.10)
*/
@get:Input
@get:Optional
abstract val remapATToLegacy: Property<Boolean?>

@get:Internal
@set:Internal
@set:ApiStatus.Experimental
abstract var allowImplicitWildcards: Boolean

abstract fun devNamespace(namespace: String)

@Deprecated(message = "no longer needed", replaceWith = ReplaceWith(""))
fun devFallbackNamespace(namespace: String) {}

abstract fun prodNamespace(namespace: String)

abstract fun mixinRemap(action: MixinRemapOptions.() -> Unit)

fun mixinRemap(
@DelegatesTo(value = MixinRemapOptions::class, strategy = Closure.DELEGATE_FIRST)
action: Closure<*>
) {
mixinRemap {
action.delegate = this
action.resolveStrategy = Closure.DELEGATE_FIRST
action.call()
}
}

init {
remapATToLegacy.convention(null as Boolean?).finalizeValueOnRead()
}

}
Original file line number Diff line number Diff line change
@@ -1,68 +1,5 @@
package xyz.wagyourtail.unimined.api.minecraft.task

import groovy.lang.Closure
import groovy.lang.DelegatesTo
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Optional
import org.gradle.jvm.tasks.Jar
import org.jetbrains.annotations.ApiStatus
import xyz.wagyourtail.unimined.api.mapping.mixin.MixinRemapOptions
import xyz.wagyourtail.unimined.mapping.Namespace
import xyz.wagyourtail.unimined.util.FinalizeOnRead
import xyz.wagyourtail.unimined.util.JarInterface

/**
* task responsible for transforming your built jar to production.
* @since 0.1.0
*/
@Suppress("LeakingThis")
abstract class RemapJarTask : Jar() {

@get:InputFile
abstract val inputFile: RegularFileProperty

@get:Internal
@set:Internal
var devNamespace: Namespace? by FinalizeOnRead(null)

@get:Internal
@set:Internal
var prodNamespace: Namespace? by FinalizeOnRead(null)

/**
* whether to remap AccessTransformers to the legacy format (<=1.7.10)
*/
@get:Input
@get:Optional
abstract val remapATToLegacy: Property<Boolean?>

@get:Internal
@set:Internal
@set:ApiStatus.Experimental
abstract var allowImplicitWildcards: Boolean

abstract fun devNamespace(namespace: String)

abstract fun prodNamespace(namespace: String)

abstract fun mixinRemap(action: MixinRemapOptions.() -> Unit)

fun mixinRemap(
@DelegatesTo(value = MixinRemapOptions::class, strategy = Closure.DELEGATE_FIRST)
action: Closure<*>
) {
mixinRemap {
action.delegate = this
action.resolveStrategy = Closure.DELEGATE_FIRST
action.call()
}
}

init {
remapATToLegacy.convention(null as Boolean?).finalizeValueOnRead()
}

}
interface RemapJarTask : JarInterface<AbstractRemapJarTask>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package xyz.wagyourtail.unimined.api.minecraft.task

import xyz.wagyourtail.unimined.util.JarInterface

interface RemapSourcesJarTask : JarInterface<AbstractRemapJarTask>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package xyz.wagyourtail.unimined.api.source.remapper

import groovy.lang.Closure
import groovy.lang.DelegatesTo
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.ExternalModuleDependency
import org.gradle.api.file.FileCollection
import org.gradle.process.JavaExecSpec
import org.jetbrains.annotations.ApiStatus
import xyz.wagyourtail.unimined.mapping.Namespace
import java.nio.file.Path
Expand All @@ -25,11 +26,11 @@ interface SourceRemapper {
* set the remapper to use (defaults to https://github.com/unimined/source-remap)
* @since 1.2.0
*/
fun remapper(dep: Any, action: Dependency.() -> Unit)
fun remapper(dep: Any, action: ExternalModuleDependency.() -> Unit)

fun remapper(
dep: Any,
@DelegatesTo(value = Dependency::class, strategy = Closure.DELEGATE_FIRST)
@DelegatesTo(value = ExternalModuleDependency::class, strategy = Closure.DELEGATE_FIRST)
action: Closure<*>
) {
remapper(dep) {
Expand All @@ -44,6 +45,7 @@ interface SourceRemapper {
inputOutput: Map<Path, Path>,
classpath: FileCollection,
source: Namespace,
target: Namespace
target: Namespace,
specConfig: JavaExecSpec.() -> Unit = {}
)
}
29 changes: 29 additions & 0 deletions src/api/kotlin/xyz/wagyourtail/unimined/util/JarInterface.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package xyz.wagyourtail.unimined.util

import groovy.lang.Closure
import groovy.lang.DelegatesTo
import org.gradle.api.Task
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.bundling.Jar

interface JarInterface<T : Jar> : Task {

@Suppress("UNCHECKED_CAST")
val asJar: T
@Internal
get() = this as T

fun asJar(action: T.() -> Unit) {
asJar.action()
}

fun asJar(
@DelegatesTo(Jar::class, strategy = Closure.DELEGATE_FIRST)
closure: Closure<*>
) {
asJar {
closure.delegate = this
closure.call()
}
}
}
Loading

0 comments on commit 0344b5b

Please sign in to comment.