-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
FilterSpigotExcludes.kt
61 lines (56 loc) · 2.08 KB
/
FilterSpigotExcludes.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* paperweight is a Gradle plugin for the PaperMC project.
*
* Copyright (c) 2021 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.tasks
import io.papermc.paperweight.util.deleteForcefully
import io.papermc.paperweight.util.path
import java.nio.file.Path
import kotlin.io.path.*
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
/**
* Because Spigot doesn't remap all classes, there are class and package name clashes if we don't do this in the source
* remap step. Other than that, we don't need this jar
*/
@CacheableTask
abstract class FilterSpigotExcludes : ZippedTask() {
@get:InputFile
@get:PathSensitive(PathSensitivity.NONE)
abstract val excludesFile: RegularFileProperty
override fun run(rootDir: Path) {
excludesFile.path.useLines { lines ->
for (line in lines) {
if (line.startsWith('#') || line.isBlank()) {
continue
}
val file = if (line.contains('/')) {
rootDir.resolve("$line.class")
} else {
rootDir.resolve("net/minecraft/server/$line.class")
}
file.deleteForcefully()
}
}
}
}