-
-
Notifications
You must be signed in to change notification settings - Fork 19
Add Gradle Plugin #32
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
base: master
Are you sure you want to change the base?
Conversation
- Includes changes from GradleUtils 3.4.0 (needs to be squashed and tagged) - DSL changes (comments on those would be nice, but not a blocker) - renamedJar (default name) is now very similar to renamedJarJar - Gradle 9.1.0 for `AttributeContainer#addAllLater`
|
Okay so skimming over your changes. Super stupid question, everything seems to boil down to trying to get the specified configurations. And trying to get a task that can be passed to artifact As for the DSL. As discussed on discord, ideally the normal user would just do renamer.classes(jar) // Makes a renameJar task and configures these defaults
tasks.named('renameJar') {
dependsOn jar
input = jar.getArchiveFile
output = file("libs/$archiveBaseName-$version-renamed.jar")
map = renamer.mappings
classifier = 'renamed'
libararies = sourcesets.main.compileClasspath
}
configurations {
renamed
}
artifacts {
renamed new RenamedArtifact(renameJar, jar) // The wrapper for PublishArtifact like I mentioned above
}I'm not sure how to add variants to the publish with the correct attributes. But this could be a different/easier approach. |
| @@ -0,0 +1,2 @@ | |||
| #!/bin/sh | |||
| ../gradlew "$@" No newline at end of file | |||
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.
Note to self: Need to just use the full normal gradle wrapper cuz intellij is dumb
| this.getLibraries().convention(getProject().getExtensions().getByType(JavaPluginExtension.class).getSourceSets().named(SourceSet.MAIN_SOURCE_SET_NAME).map(SourceSet::getCompileClasspath)); | ||
|
|
||
| this.getArchiveExtension().convention("jar"); | ||
| this.getArchiveDate().convention(this.getInput().map(input -> new Date(input.getAsFile().lastModified()))); |
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.
Is this delayed until the task is executed so that the value is valid?
|
|
||
| @Inject | ||
| public RenamerPlugin() { | ||
| super(NAME, DISPLAY_NAME, "renamerTools"); |
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.
Somewhat related question, is it possible to have a shared 'tools' extension so that modders can configure things in one place? Yes I know this means we will have to coordinate the names across all the plugins, but that shouldnt be an issue.
| } | ||
|
|
||
| tasks.named('javadoc', Javadoc) { | ||
| javadocTool = javaToolchains.javadocToolFor { languageVersion = JavaLanguageVersion.of(25) } |
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.
Does this variant still include the 4MB of font files?
First pass at making a gradle plugin.
This is functional. See the demo for the examples.
Need to speak with @Jonathing about a lot of the implementation.
I did not use ToolExecBase because I have a few issues with it.
Namely, the Tool object is very clunky to work with.
It doesn't auto-detect main classes.
It doesn't support maven coordinates, or downloading the tools from configured repositories.
My implementation in theory (gradle didn't yell at me) is compatible with the config cache.
It uses detached configurations to download the mappings and tool.
So a basic overview:
plugins { id 'net.minecraftforge.renamer' } renamer { mappings(channel, version) // Shorthand for mappings('net.minecraft:mappings_channel:[email protected]') mappings(string) // Shorthand for mappings(dependencies.create(string)) mappings(Dependency) // Will use this dependency as the mapping file for subsequent calls to renamer.rename(task) } // Creates a 'jarRename' task using the compileClasspath // input is set to task.archiveFile // output is set to a renamed task.archiveFile (adding -renamed before the extension) // map is set from the previous call to renamer.mappings (or null if unset) // tool is set to `net.minecraftforge:ForgeAutoRenamingTool:1.1.2:all` // args is set to "--input", "{input}", "--output", "{output}", "--map", "{map}", "--lib={library}" // javaLauncher is set to javaToolchains.launcherFor(java.toolchain) // Shorthand for renamer.rename(jar, jar.name + 'Rename', null) renamer.rename(jar) // It also support specifying a closure renamer.rename(jar) { map = file('map.tsrg') } // Or configuring the task itself tasks.named('jarRename') { map = file('map.tsrg') }I have not done anything to mark the task as an artifact/publish.