diff options
author | Linnea Gräf <nea@nea.moe> | 2023-12-10 15:43:14 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2023-12-10 15:43:14 +0100 |
commit | 17f0faaccb0db837a64b6ce7cecff7f8ab048410 (patch) | |
tree | d6dcd51e43d16873c14a696c565c0c343440b19e /plugin/src/main/kotlin/moe/nea/archenemy/mojang/ArchenemyMojangExtension.kt | |
parent | 67bf79815ec27c8b813480c11a45f35ef502fe5b (diff) | |
download | archenemy-17f0faaccb0db837a64b6ce7cecff7f8ab048410.tar.gz archenemy-17f0faaccb0db837a64b6ce7cecff7f8ab048410.tar.bz2 archenemy-17f0faaccb0db837a64b6ce7cecff7f8ab048410.zip |
Add crude mappings/transformer support
Diffstat (limited to 'plugin/src/main/kotlin/moe/nea/archenemy/mojang/ArchenemyMojangExtension.kt')
-rw-r--r-- | plugin/src/main/kotlin/moe/nea/archenemy/mojang/ArchenemyMojangExtension.kt | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/plugin/src/main/kotlin/moe/nea/archenemy/mojang/ArchenemyMojangExtension.kt b/plugin/src/main/kotlin/moe/nea/archenemy/mojang/ArchenemyMojangExtension.kt index b3b3cfd..b80fe89 100644 --- a/plugin/src/main/kotlin/moe/nea/archenemy/mojang/ArchenemyMojangExtension.kt +++ b/plugin/src/main/kotlin/moe/nea/archenemy/mojang/ArchenemyMojangExtension.kt @@ -4,6 +4,8 @@ import moe.nea.archenemy.MCSide import net.minecraftforge.artifactural.gradle.GradleRepositoryAdapter import org.gradle.api.Project import org.gradle.api.artifacts.Dependency +import org.gradle.api.artifacts.ModuleDependency +import java.io.File import java.net.URI abstract class ArchenemyMojangExtension(val project: Project) { @@ -16,12 +18,51 @@ abstract class ArchenemyMojangExtension(val project: Project) { sharedExtension.getLocalCacheDirectory().resolve("minecraft-provider"), sharedExtension.minecraftProvider ) + GradleRepositoryAdapter.add( + project.repositories, + "Minecraft Mapped Provider", + getLocalCacheDirectory().resolve("minecraft-transformation-provider"), + mappedRepositoryProvider + ) project.repositories.maven { it.name = "Minecraft Libraries" it.url = URI("https://libraries.minecraft.net/") } } + private val mappedRepositoryProvider = MappedRepositoryProvider(this) + + + fun officialMappings(version: String, side: MCSide): MappingDependency { + _registerMinecraftProvider + val dependency by lazy { + project.dependencies.create( + sharedExtension.minecraftProvider.getMappingsDependencyCoordinate( + MinecraftProvider.MinecraftCoordinate( + version, + side + ) + ) + ) + } + return OfficialMappingDependency(side, version, project.providers.provider { dependency }) + } + + fun mapJar( + dependency: ModuleDependency, + mappings: MappingDependency, + sourceNamespace: String, + destinationNamespace: String + ): Dependency { + _registerMinecraftProvider + return project.dependencies.create( + mappedRepositoryProvider.getDependencyCoordiante( + MappedRepositoryProvider.MappedCoordinates( + dependency, mappings, sourceNamespace, destinationNamespace + ) + ) + ) + } fun minecraft(version: String, side: MCSide): Dependency { _registerMinecraftProvider @@ -35,4 +76,9 @@ abstract class ArchenemyMojangExtension(val project: Project) { ) } + fun getLocalCacheDirectory(): File { + return sharedExtension.getLocalCacheDirectory().resolve("projectspecific") + .resolve(if (project == project.rootProject) "__root" else project.path.replace(":", "_")) + } + }
\ No newline at end of file |