Skip to content

Commit

Permalink
paperweight v2
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniDigger committed Oct 26, 2024
1 parent 6408556 commit 3c6d8b0
Show file tree
Hide file tree
Showing 102 changed files with 3,450 additions and 79 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,9 @@ 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

[*.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 }}
12 changes: 11 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ jobs:
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Execute Gradle build
run: ./gradlew build --no-daemon --stacktrace
run: |
git config --global user.email "no-reply@github.com"
git config --global user.name "GitHub Actions"
./gradlew build --no-daemon --stacktrace
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: always()
with:
report_paths: '**/build/test-results/test/TEST-*.xml'
detailed_summary: true
annotate_notice: true
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/
41 changes: 38 additions & 3 deletions buildSrc/src/main/kotlin/config-kotlin.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import com.diffplug.gradle.spotless.SpotlessExtension
import net.kyori.indra.licenser.spotless.IndraSpotlessLicenserExtension
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

plugins {
idea
Expand All @@ -11,7 +13,7 @@ java {
}

tasks.withType(JavaCompile::class).configureEach {
options.release = 11
options.release = 17
}

kotlin {
Expand All @@ -21,14 +23,15 @@ kotlin {
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 +41,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 +80,16 @@ testing {
useKotlinTest(embeddedKotlinVersion)
dependencies {
implementation("org.junit.jupiter:junit-jupiter-engine:5.10.1")
implementation("org.junit.platform:junit-platform-launcher:1.10.1")
}

targets.configureEach {
testTask {
testLogging {
events(TestLogEvent.FAILED)
exceptionFormat = TestExceptionFormat.FULL
}
}
}
}
}
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.7.5-SNAPSHOT
version = 2.0.0-SNAPSHOT

org.gradle.caching = true
org.gradle.parallel = true
27 changes: 22 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
[versions]
asm = "9.7"
asm = "9.7.1"
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"
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,18 +35,29 @@ slf4j-jdk14 = "org.slf4j:slf4j-jdk14:1.7.32"
lorenzTiny = "net.fabricmc:lorenz-tiny:3.0.0"
jbsdiff = "io.sigpipe:jbsdiff:1.0"

diffpatch = "codechicken:DiffPatch:1.5.0.29"
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.30"

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.1-SNAPSHOT"

# 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"
gradle-shadow = "com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:8.1.1"
gradle-kotlin-dsl = "org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:4.3.0"
gradle-kotlin-dsl = "org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:4.5.0"
gradle-plugin-kotlin = { module = "org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin" }
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"]
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
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 Down Expand Up @@ -53,7 +54,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 @@ -69,6 +72,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 @@ -90,10 +94,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 @@ -124,21 +130,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/features")

@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 @@ -101,6 +101,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 @@ -126,7 +143,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 @@ -151,7 +168,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
Loading

0 comments on commit 3c6d8b0

Please sign in to comment.