Skip to content

Commit

Permalink
start to fiddle with mache
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniDigger committed Mar 29, 2024
1 parent 8c3c62d commit 37aea2c
Show file tree
Hide file tree
Showing 103 changed files with 3,520 additions and 74 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,6 @@ ij_kotlin_field_annotation_wrap = split_into_lines
ij_kotlin_finally_on_new_line = false
ij_kotlin_if_rparen_on_new_line = true
ij_kotlin_import_nested_classes = false

[*.patch]
trim_trailing_whitespace=false
4 changes: 2 additions & 2 deletions .github/workflows/deploy-snapshot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Deploy Snapshot
on:
push:
branches: [ 'main' ]
branches: [ 'main', 'softspoon-v2' ]
paths-ignore:
- 'license/*'
- 'readme.md'
Expand Down Expand Up @@ -29,7 +29,7 @@ jobs:
echo version=$project_version >> $GITHUB_OUTPUT
- name: Deploy snapshot version
if: endsWith(steps.get_version.outputs.version, '-SNAPSHOT')
run: ./gradlew -Dorg.gradle.parallel=true publish --no-daemon --stacktrace
run: ./gradlew -Dorg.gradle.parallel=true publish --no-daemon --stacktrace -Dorg.gradle.internal.http.socketTimeout=90000 -Dorg.gradle.internal.http.connectionTimeout=90000
env:
ORG_GRADLE_PROJECT_paperUsername: ${{ secrets.DEPLOY_USER }}
ORG_GRADLE_PROJECT_paperPassword: ${{ secrets.DEPLOY_PASS }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@ ehthumbs_vista.db

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.ja

/test/
/testpaper/
/testfork/
/testhistory/
30 changes: 27 additions & 3 deletions buildSrc/src/main/kotlin/config-kotlin.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ tasks.withType(JavaCompile::class).configureEach {

kotlin {
jvmToolchain {
languageVersion = JavaLanguageVersion.of(17)
languageVersion = JavaLanguageVersion.of(11)
}
target {
compilations.configureEach {
kotlinOptions {
jvmTarget = "11"
freeCompilerArgs = listOf("-Xjvm-default=all", "-Xjdk-release=11")
jvmTarget = "17"
freeCompilerArgs = listOf("-Xjvm-default=all", "-Xjdk-release=17", "-opt-in=kotlin.io.path.ExperimentalPathApi")
}
}
}
}

repositories {
mavenLocal() // TODO remove again
maven("https://repo.papermc.io/repository/maven-snapshots/") {
mavenContent {
includeModule("org.cadixdev", "mercury")
Expand All @@ -38,6 +39,28 @@ repositories {
mavenContent {
includeGroup("codechicken")
includeGroup("net.fabricmc")
includeGroupAndSubgroups("io.papermc")
}
}
maven("https://maven.parchmentmc.org") {
name = "ParchmentMC"
mavenContent {
releasesOnly()
includeGroupAndSubgroups("org.parchmentmc")
}
}
maven("https://maven.neoforged.net/releases") {
name = "NeoForged"
mavenContent {
releasesOnly()
includeGroupAndSubgroups("net.neoforged")
}
}
maven("https://maven.fabricmc.net") {
name = "FabricMC"
mavenContent {
releasesOnly()
includeGroupAndSubgroups("net.fabricmc")
}
}
mavenCentral()
Expand All @@ -55,6 +78,7 @@ testing {
useKotlinTest(embeddedKotlinVersion)
dependencies {
implementation("org.junit.jupiter:junit-jupiter-engine:5.10.1")
implementation("org.junit.platform:junit-platform-launcher:1.10.1")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group = io.papermc.paperweight
version = 1.5.13-SNAPSHOT
version = 2.0.0-SNAPSHOT

org.gradle.caching = true
org.gradle.parallel = true
22 changes: 20 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
[versions]
asm = "9.7"
lorenz = "0.5.8"
hypo = "1.2.4"
hypo = "2.3.0"
serialize = "1.5.1"
feather = "1.1.0"

[libraries]
asm-core = { module = "org.ow2.asm:asm", version.ref = "asm" }
asm-tree = { module = "org.ow2.asm:asm-tree", version.ref = "asm" }

httpclient = "org.apache.httpcomponents:httpclient:4.5.14"
kotson = "com.github.salomonbrys.kotson:kotson:2.5.0"
coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2"
jgit = "org.eclipse.jgit:org.eclipse.jgit:6.6.0.202305301015-r"
diffutils = "io.github.java-diff-utils:java-diff-utils:4.12"
gson = "com.google.code.gson:gson:2.10.1"

cadix-lorenz-core = { module = "org.cadixdev:lorenz", version.ref = "lorenz" }
cadix-lorenz-asm = { module = "org.cadixdev:lorenz-asm", version.ref = "lorenz" }
cadix-lorenz-proguard = { module = "org.cadixdev:lorenz-io-proguard", version.ref = "lorenz" }
cadix-atlas = "org.cadixdev:atlas:0.2.1"
cadix-at = "org.cadixdev:at:0.1.0-rc1"
#cadix-mercury = "org.cadixdev:mercury:0.1.2-paperweight-local-SNAPSHOT" # todo local mods for patch remapping
cadix-mercury = "org.cadixdev:mercury:0.1.2-paperweight-SNAPSHOT"
cadix-bombe-jar = "org.cadixdev:bombe-jar:0.4.4"

hypo-model = { module = "dev.denwav.hypo:hypo-model", version.ref = "hypo" }
hypo-core = { module = "dev.denwav.hypo:hypo-core", version.ref = "hypo" }
Expand All @@ -29,8 +36,19 @@ slf4j-jdk14 = "org.slf4j:slf4j-jdk14:1.7.32"
lorenzTiny = "net.fabricmc:lorenz-tiny:3.0.0"
jbsdiff = "io.sigpipe:jbsdiff:1.0"

feather-core = { module = "org.parchmentmc:feather", version.ref = "feather" }
feather-gson = { module = "org.parchmentmc.feather:io-gson", version.ref = "feather" }

diffpatch = "codechicken:DiffPatch:1.5.0.29"

serialize-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "serialize" }
serialize-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialize" }

restamp = "io.papermc.restamp:restamp:1.1.0"

# test
mockk = "io.mockk:mockk:1.13.8"

# Gradle
gradle-licenser = "net.kyori:indra-licenser-spotless:3.1.3"
gradle-spotless = "com.diffplug.spotless:spotless-plugin-gradle:6.23.1"
Expand All @@ -41,6 +59,6 @@ gradle-plugin-publish = "com.gradle.publish:plugin-publish-plugin:1.2.1"

[bundles]
asm = ["asm-core", "asm-tree"]
cadix = ["cadix-lorenz-core", "cadix-lorenz-asm", "cadix-lorenz-proguard", "cadix-atlas", "cadix-at", "cadix-mercury"]
cadix = ["cadix-lorenz-core", "cadix-lorenz-asm", "cadix-lorenz-proguard", "cadix-atlas", "cadix-at", "cadix-mercury", "cadix-bombe-jar"]
hypo = ["hypo-model", "hypo-core", "hypo-hydrate", "hypo-asm-core", "hypo-asm-hydrate", "hypo-mappings"]
kotson = ["kotson", "gson"]
1 change: 1 addition & 0 deletions paperweight-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies {
shade(projects.paperweightLib)

implementation(libs.bundles.kotson)
implementation(libs.coroutines)
}

gradlePlugin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ package io.papermc.paperweight.core
import io.papermc.paperweight.DownloadService
import io.papermc.paperweight.core.extension.PaperweightCoreExtension
import io.papermc.paperweight.core.taskcontainers.AllTasks
import io.papermc.paperweight.core.taskcontainers.SoftSpoonTasks
import io.papermc.paperweight.core.tasks.PaperweightCorePrepareForDownstream
import io.papermc.paperweight.taskcontainers.BundlerJarTasks
import io.papermc.paperweight.taskcontainers.DevBundleTasks
Expand All @@ -48,7 +49,9 @@ class PaperweightCore : Plugin<Project> {

val ext = target.extensions.create(PAPERWEIGHT_EXTENSION, PaperweightCoreExtension::class, target)

target.gradle.sharedServices.registerIfAbsent(DOWNLOAD_SERVICE_NAME, DownloadService::class) {}
target.gradle.sharedServices.registerIfAbsent(DOWNLOAD_SERVICE_NAME, DownloadService::class) {
parameters.projectPath.set(target.projectDir)
}

target.tasks.register<Delete>("cleanCache") {
group = "paper"
Expand All @@ -64,6 +67,7 @@ class PaperweightCore : Plugin<Project> {
target.configurations.create(REMAPPER_CONFIG)
target.configurations.create(DECOMPILER_CONFIG)
target.configurations.create(PAPERCLIP_CONFIG)
target.configurations.create(MACHE_CONFIG)

if (target.providers.gradleProperty("paperweight.dev").orNull == "true") {
target.tasks.register<CreateDiffOutput>("diff") {
Expand All @@ -85,10 +89,12 @@ class PaperweightCore : Plugin<Project> {
ext.mainClass
)

val softSpoonTasks = SoftSpoonTasks(target, tasks)

target.createPatchRemapTask(tasks)

target.tasks.register<PaperweightCorePrepareForDownstream>(PAPERWEIGHT_PREPARE_DOWNSTREAM) {
dependsOn(tasks.applyPatches)
dependsOn(tasks.applyPatchesLegacy)
vanillaJar.set(tasks.downloadServerJar.flatMap { it.outputJar })
remappedJar.set(tasks.lineMapJar.flatMap { it.outputJar })
decompiledJar.set(tasks.decompileJar.flatMap { it.outputJar })
Expand Down Expand Up @@ -119,21 +125,35 @@ class PaperweightCore : Plugin<Project> {
}

target.afterEvaluate {
println("SoftSpoon: ${ext.softSpoon.get()}")

target.repositories {
maven(ext.paramMappingsRepo) {
name = PARAM_MAPPINGS_REPO_NAME
content { onlyForConfigurations(PARAM_MAPPINGS_CONFIG) }
}
maven(ext.remapRepo) {
name = REMAPPER_REPO_NAME
content { onlyForConfigurations(REMAPPER_CONFIG) }
}
maven(ext.decompileRepo) {
name = DECOMPILER_REPO_NAME
content { onlyForConfigurations(DECOMPILER_CONFIG) }
if (!ext.softSpoon.get()) {
maven(ext.paramMappingsRepo) {
name = PARAM_MAPPINGS_REPO_NAME
content { onlyForConfigurations(PARAM_MAPPINGS_CONFIG) }
}
maven(ext.remapRepo) {
name = REMAPPER_REPO_NAME
content { onlyForConfigurations(REMAPPER_CONFIG) }
}
maven(ext.decompileRepo) {
name = DECOMPILER_REPO_NAME
content { onlyForConfigurations(DECOMPILER_CONFIG) }
}
} else {
maven(ext.macheRepo) {
name = MACHE_REPO_NAME
content { onlyForConfigurations(MACHE_CONFIG) }
}
}
}

if (ext.softSpoon.get()) {
softSpoonTasks.afterEvaluate()
return@afterEvaluate
}

// Setup the server jar
val cache = target.layout.cache

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ open class PaperExtension(objects: ObjectFactory, layout: ProjectLayout) {
val spigotServerPatchDir: DirectoryProperty = objects.dirFrom(baseTargetDir, "patches/server")
val remappedSpigotServerPatchDir: DirectoryProperty = objects.dirFrom(baseTargetDir, "patches/server-remapped")
val unmappedSpigotServerPatchDir: DirectoryProperty = objects.dirFrom(baseTargetDir, "patches/server-unmapped")
val paperApiDir: DirectoryProperty = objects.dirFrom(baseTargetDir, "Paper-API")
val paperServerDir: DirectoryProperty = objects.dirFrom(baseTargetDir, "Paper-Server")
val paperApiDir: DirectoryProperty = objects.dirFrom(baseTargetDir, "paper-api")
val paperServerDir: DirectoryProperty = objects.dirFrom(baseTargetDir, "paper-server")
val sourcePatchDir: DirectoryProperty = objects.dirFrom(paperServerDir, "patches/sources")
val resourcePatchDir: DirectoryProperty = objects.dirFrom(paperServerDir, "patches/resources")
val featurePatchDir: DirectoryProperty = objects.dirFrom(paperServerDir, "patches/feature")

@Suppress("MemberVisibilityCanBePrivate")
val buildDataDir: DirectoryProperty = objects.dirWithDefault(layout, "build-data")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ import org.gradle.kotlin.dsl.*

open class PaperweightCoreExtension(project: Project, objects: ObjectFactory, layout: ProjectLayout) {

val softSpoon: Property<Boolean> = objects.property<Boolean>().convention(false)

@Suppress("MemberVisibilityCanBePrivate")
val workDir: DirectoryProperty = objects.dirWithDefault(layout, "work")

val minecraftVersion: Property<String> = objects.property()
val minecraftManifestUrl: Property<String> = objects.property<String>().convention(MC_MANIFEST_URL)
val serverProject: Property<Project> = objects.property()

val mainClass: Property<String> = objects.property<String>().convention("org.bukkit.craftbukkit.Main")
Expand All @@ -50,6 +53,7 @@ open class PaperweightCoreExtension(project: Project, objects: ObjectFactory, la
val paramMappingsRepo: Property<String> = objects.property()
val decompileRepo: Property<String> = objects.property()
val remapRepo: Property<String> = objects.property()
val macheRepo: Property<String> = objects.property<String>().convention("https://repo.papermc.io/repository/maven-public/")

val vanillaJarIncludes: ListProperty<String> = objects.listProperty<String>().convention(
listOf("/*.class", "/net/minecraft/**", "/com/mojang/math/**")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ open class AllTasks(
downloader.set(downloadService)
}

val downloadPaperLibrariesSources by tasks.registering<DownloadPaperLibraries> {
paperDependencies.set(
project.ext.serverProject.map { p ->
val configuration = p.configurations["implementation"]
configuration.isCanBeResolved = true
configuration.resolvedConfiguration.resolvedArtifacts.map {
"${it.moduleVersion.id.group}:${it.moduleVersion.id.name}:${it.moduleVersion.id.version}"
}
}
)
repositories.set(listOf(MAVEN_CENTRAL_URL, PAPER_MAVEN_REPO_URL))
outputDir.set(cache.resolve(PAPER_SOURCES_JARS_PATH))
sources.set(true)

downloader.set(downloadService)
}

@Suppress("DuplicatedCode")
val applyServerPatches by tasks.registering<ApplyPaperPatches> {
group = "paper"
Expand All @@ -127,7 +144,7 @@ open class AllTasks(
mcDevSources.set(extension.mcDevSourceDir)
}

val applyPatches by tasks.registering<Task> {
val applyPatchesLegacy by tasks.registering<Task> {
group = "paper"
description = "Set up the Paper development environment"
dependsOn(applyApiPatches, applyServerPatches)
Expand All @@ -152,7 +169,7 @@ open class AllTasks(
}

@Suppress("unused")
val rebuildPatches by tasks.registering<Task> {
val rebuildPatchesLegacy by tasks.registering<Task> {
group = "paper"
description = "Rebuilds patches to api and server"
dependsOn(rebuildApiPatches, rebuildServerPatches)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ open class InitialTasks(
) {

val downloadMcManifest by tasks.registering<DownloadTask> {
url.set(MC_MANIFEST_URL)
url.set(project.ext.minecraftManifestUrl)
outputFile.set(cache.resolve(MC_MANIFEST))

doNotTrackState("The Minecraft manifest is a changing resource")
Expand All @@ -54,7 +54,7 @@ open class InitialTasks(
}
private val mcManifest = downloadMcManifest.flatMap { it.outputFile }.map { gson.fromJson<MinecraftManifest>(it) }

val downloadMcVersionManifest by tasks.registering<DownloadTask> {
val downloadMcVersionManifest by tasks.registering<CacheableDownloadTask> {
url.set(
mcManifest.zip(extension.minecraftVersion) { manifest, version ->
manifest.versions.first { it.id == version }.url
Expand All @@ -71,7 +71,7 @@ open class InitialTasks(
}
private val versionManifest = downloadMcVersionManifest.flatMap { it.outputFile }.map { gson.fromJson<MinecraftVersionManifest>(it) }

val downloadMappings by tasks.registering<DownloadTask> {
val downloadMappings by tasks.registering<CacheableDownloadTask> {
url.set(versionManifest.map { version -> version.serverMappingsDownload().url })
expectedHash.set(versionManifest.map { version -> version.serverMappingsDownload().hash() })
outputFile.set(cache.resolve(SERVER_MAPPINGS))
Expand All @@ -94,5 +94,6 @@ open class InitialTasks(
serverLibrariesList.set(cache.resolve(SERVER_LIBRARIES_LIST))
serverVersionsList.set(cache.resolve(SERVER_VERSIONS_LIST))
serverLibraryJars.set(cache.resolve(MINECRAFT_JARS_PATH))
serverJar.set(cache.resolve(SERVER_JAR))
}
}

0 comments on commit 37aea2c

Please sign in to comment.