Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
ShirasawaSama committed Sep 11, 2021
1 parent 7fd5ea0 commit 46cc253
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ buildscript {
plugins {
id 'java'
id 'cn.apisium.papershelled' version '1.0.1'
id 'cn.apisium.papershelled' version '1.0.2'
}
paperShelled {
Expand All @@ -28,12 +28,6 @@ dependencies {
```

Then run `setupPaperShelled` task:

```bash
gradle setupPaperShelled
```

### Complete example

[See also](./example)
Expand All @@ -46,7 +40,7 @@ buildscript {
}
plugins {
id 'cn.apisium.papershelled' version '1.0.1'
id 'cn.apisium.papershelled' version '1.0.2'
id 'com.github.johnrengelman.shadow' version '7.0.0'
}
Expand Down
2 changes: 1 addition & 1 deletion plugin-build/buildSrc/src/main/java/Coordinates.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object PluginCoordinates {
const val ID = "cn.apisium.papershelled"
const val GROUP = "cn.apisium.papershelled"
const val VERSION = "1.0.1"
const val VERSION = "1.0.2"
const val IMPLEMENTATION_CLASS = "cn.apisium.papershelled.gradle.Plugin"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package cn.apisium.papershelled.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.bundling.Jar
import java.nio.file.Files

internal var lastJarTask: Jar? = null

Expand All @@ -25,6 +26,11 @@ abstract class Plugin : Plugin<Project> {
it.spigotMap.set(extension.spigotMap)
it.mojangMap.set(extension.mojangMap)
it.paperShelledJar.set(extension.paperShelledJar)
it.shouldRunAfter(download)
}

val setup = project.tasks.register("setupPaperShelled", SetupTask::class.java) {
it.dependsOn(download, gmj)
}

val reobf = project.tasks.register("reobf", ReobfTask::class.java) {
Expand All @@ -34,10 +40,8 @@ abstract class Plugin : Plugin<Project> {
it.mojangMap.set(extension.mojangMap)
it.craftBukkitVersion.set(extension.craftBukkitVersion)
it.paperShelledJar.set(extension.paperShelledJar)
}

project.tasks.register("setupPaperShelled", SetupTask::class.java) {
it.dependsOn(download, gmj)
if (!Files.exists(it.reobfFile.get().asFile.toPath()) ||
!Files.exists(it.paperShelledJar.get().asFile.toPath())) it.dependsOn(setup)
}

project.tasks.withType(Jar::class.java) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ abstract class GenerateMappedJarTask : DefaultTask() {
@ExperimentalPathApi
@TaskAction
fun run() {
val reobf = reobfFile.asFile.get().toPath()
val reobf = reobfFile.get().asFile.toPath()
val path = URLClassLoader(arrayOf(jarFile.get().asFile.toURI().toURL())).use {
val m = it.loadClass("io.papermc.paperclip.Paperclip").getDeclaredMethod("setupEnv")
m.isAccessible = true
Expand Down Expand Up @@ -172,7 +172,7 @@ abstract class ReobfTask : DefaultTask() {
@TaskAction
fun run() {
val remapper = TinyRemapper.newRemapper()
.withMappings(TinyUtils.createTinyMappingProvider(reobfFile.asFile.get().toPath(),
.withMappings(TinyUtils.createTinyMappingProvider(reobfFile.get().asFile.toPath(),
mojangMap.get(), spigotMap.get()))
.ignoreConflicts(true)
.fixPackageAccess(true)
Expand Down

0 comments on commit 46cc253

Please sign in to comment.