-
-
Notifications
You must be signed in to change notification settings - Fork 66
feat: allow for specifying ATs for upstream sources #377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Toffikk
wants to merge
14
commits into
PaperMC:main
Choose a base branch
from
CraftCanvasMC:feat/ats-for-upstream-sources
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3665104
feat: allow for specifying ATs for upstream sources
Toffikk 55d76c0
chore: remove unnecessary this@PatchingTasks specifier
Toffikk 3ddbc21
chore: cleanup tagging logic
Toffikk 4f1edf1
fix: provide compile classpath for JST
Toffikk 617e64b
chore: indent
Toffikk aca60da
fix: provide the classpaths of subprojects
Toffikk 6fd4a2a
fix: append the mache minecraft jar to JST's classpath
Toffikk 575a6a0
format
Toffikk 09cce04
fix(normal AT logic/paperweight issue): append compile classpath for …
Toffikk d6b74bf
Revert "fix(normal AT logic/paperweight issue): append compile classp…
Toffikk d7015e4
chore: cleanup impl
Toffikk 81c147d
fix: resolve gradle errors while running upstream setup
Toffikk a20d4ac
fix: workaround the latest review
Toffikk 9b14741
chore: format
Toffikk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...weight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/SetupForkUpstreamSources.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /* | ||
| * paperweight is a Gradle plugin for the PaperMC project. | ||
| * | ||
| * Copyright (c) 2023 Kyle Wood (DenWav) | ||
| * Contributors | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; | ||
| * version 2.1 only, no later versions. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | ||
| * USA | ||
| */ | ||
|
|
||
| package io.papermc.paperweight.core.tasks | ||
|
|
||
| import io.papermc.paperweight.core.util.ApplySourceATs | ||
| import io.papermc.paperweight.tasks.* | ||
| import io.papermc.paperweight.util.* | ||
| import kotlin.io.path.* | ||
| import org.eclipse.jgit.api.Git | ||
| import org.gradle.api.file.DirectoryProperty | ||
| import org.gradle.api.file.RegularFileProperty | ||
| import org.gradle.api.provider.Property | ||
| import org.gradle.api.tasks.Input | ||
| import org.gradle.api.tasks.InputDirectory | ||
| import org.gradle.api.tasks.InputFile | ||
| import org.gradle.api.tasks.Nested | ||
| import org.gradle.api.tasks.Optional | ||
| import org.gradle.api.tasks.OutputDirectory | ||
| import org.gradle.api.tasks.TaskAction | ||
| import org.gradle.kotlin.dsl.* | ||
|
|
||
| abstract class SetupForkUpstreamSources : JavaLauncherTask() { | ||
|
|
||
| @get:InputDirectory | ||
| abstract val inputDir: DirectoryProperty | ||
|
|
||
| @get:OutputDirectory | ||
| abstract val outputDir: DirectoryProperty | ||
|
|
||
| @get:Nested | ||
| val ats: ApplySourceATs = objects.newInstance() | ||
|
|
||
| @get:InputFile | ||
| @get:Optional | ||
| abstract val atFile: RegularFileProperty | ||
|
|
||
| @get:Input | ||
| abstract val identifier: Property<String> | ||
|
|
||
| @TaskAction | ||
| fun run() { | ||
| val out = outputDir.path.cleanDir() | ||
| inputDir.path.copyRecursivelyTo(out) | ||
|
|
||
| val git = Git.open(outputDir.path.toFile()) | ||
|
|
||
| if (atFile.isPresent && atFile.path.readText().isNotBlank()) { | ||
| println("Applying access transformers...") | ||
| ats.run( | ||
| launcher.get(), | ||
| inputDir.path, | ||
| outputDir.path, | ||
| atFile.path, | ||
| temporaryDir.toPath(), | ||
| ) | ||
| commitAndTag(git, "ATs", "${identifier.get()} ATs") | ||
| } | ||
| commitAndTag(git, "base") | ||
|
|
||
| git.close() | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mapNotNull and then returning null. Shouldn't that fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, mapNotNull is for accepting elements that aren’t null and skipping those that are.
This whole logic tbh is a bit not to my liking as i’m worried if this won’t cause issues further down the road with isolated projects in gradle, so a better solution has to be found; Unfortunately it would probably mean rewriting paperweight to treat the api projects the same way as server projects and not pin them under the root project which is an effort i didn’t want to undertake as i’m not sure if that’s something remotely desirable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks. Didn't expect that it merges map and filter(nonNull) together.