mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-19 15:09:18 +00:00
fix compile
This commit is contained in:
@@ -109,18 +109,19 @@ nmsBindings.forEach { (key, value) ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val jarJar: Configuration by configurations.creating
|
||||||
dependencies {
|
dependencies {
|
||||||
for (key in nmsBindings.keys) {
|
for (key in nmsBindings.keys) {
|
||||||
implementation(project(":nms:$key", "reobf"))
|
implementation(project(":nms:$key", "reobf"))
|
||||||
}
|
}
|
||||||
implementation(project(":core", "shadow"))
|
implementation(project(":core", "shadow"))
|
||||||
implementation(project(":core:agent"))
|
jarJar(project(":core:agent"))
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
jar {
|
jar {
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
from(configurations.runtimeClasspath.map { it.resolve().map(::zipTree) })
|
from(jarJar, configurations.runtimeClasspath.map { it.resolve().map(::zipTree) })
|
||||||
archiveFileName.set("Iris-${project.version}.jar")
|
archiveFileName.set("Iris-${project.version}.jar")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,12 @@ import org.gradle.api.attributes.LibraryElements
|
|||||||
import org.gradle.api.attributes.Usage
|
import org.gradle.api.attributes.Usage
|
||||||
import org.gradle.api.model.ObjectFactory
|
import org.gradle.api.model.ObjectFactory
|
||||||
import org.gradle.api.plugins.JavaPluginExtension
|
import org.gradle.api.plugins.JavaPluginExtension
|
||||||
import org.gradle.api.tasks.CacheableTask
|
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
import org.gradle.internal.extensions.core.extra
|
import org.gradle.internal.extensions.core.extra
|
||||||
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
||||||
import org.gradle.jvm.toolchain.JavaToolchainService
|
import org.gradle.jvm.toolchain.JavaToolchainService
|
||||||
|
import org.gradle.work.DisableCachingByDefault
|
||||||
|
import java.io.RandomAccessFile
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class NMSBinding : Plugin<Project> {
|
class NMSBinding : Plugin<Project> {
|
||||||
@@ -70,8 +71,8 @@ class NMSBinding : Plugin<Project> {
|
|||||||
rootProject.tasks.named("prepareKotlinBuildScriptModel") { it.dependsOn("$path:convert") }
|
rootProject.tasks.named("prepareKotlinBuildScriptModel") { it.dependsOn("$path:convert") }
|
||||||
}
|
}
|
||||||
|
|
||||||
@CacheableTask
|
@DisableCachingByDefault
|
||||||
open class ConversionTask @Inject constructor(type: Type) : DefaultTask() {
|
abstract class ConversionTask @Inject constructor(type: Type) : DefaultTask() {
|
||||||
private val pattern: Regex
|
private val pattern: Regex
|
||||||
private val replacement: String
|
private val replacement: String
|
||||||
|
|
||||||
@@ -79,7 +80,8 @@ class NMSBinding : Plugin<Project> {
|
|||||||
group = "nms"
|
group = "nms"
|
||||||
inputs.property("type", type)
|
inputs.property("type", type)
|
||||||
val java = project.extensions.findByType(JavaPluginExtension::class.java) ?: throw GradleException("Java plugin not found")
|
val java = project.extensions.findByType(JavaPluginExtension::class.java) ?: throw GradleException("Java plugin not found")
|
||||||
val source = java.sourceSets.findByName("main")?.allJava ?: throw GradleException("No main source set found")
|
val source = java.sourceSets.named("main").map { it.allJava }
|
||||||
|
inputs.files(source)
|
||||||
outputs.files(source)
|
outputs.files(source)
|
||||||
|
|
||||||
if (type == Type.USER_DEV) {
|
if (type == Type.USER_DEV) {
|
||||||
@@ -95,17 +97,16 @@ class NMSBinding : Plugin<Project> {
|
|||||||
fun process() {
|
fun process() {
|
||||||
val dispatcher = Dispatchers.IO.limitedParallelism(16)
|
val dispatcher = Dispatchers.IO.limitedParallelism(16)
|
||||||
runBlocking {
|
runBlocking {
|
||||||
for (file in outputs.files) {
|
for (file in inputs.files) {
|
||||||
if (file.extension !in listOf("java"))
|
if (file.extension !in listOf("java"))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
launch(dispatcher) {
|
launch(dispatcher) {
|
||||||
val output = ArrayList<String>()
|
val output = ArrayList<String>()
|
||||||
var changed = false
|
var changed = false
|
||||||
|
|
||||||
file.useLines {
|
file.bufferedReader().use {
|
||||||
for (line in it) {
|
for (line in it.lines()) {
|
||||||
if (line.startsWith("package") || line.isBlank()) {
|
if (line.startsWith("package") || line.isBlank()) {
|
||||||
output += line
|
output += line
|
||||||
continue
|
continue
|
||||||
@@ -127,11 +128,17 @@ class NMSBinding : Plugin<Project> {
|
|||||||
output += line.replace(pattern, replacement)
|
output += line.replace(pattern, replacement)
|
||||||
changed = true
|
changed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
RandomAccessFile(file, "r").use { raf ->
|
||||||
|
val bytes = ByteArray(NEW_LINE_BYTES.size)
|
||||||
|
raf.seek(raf.length() - bytes.size)
|
||||||
|
raf.readFully(bytes)
|
||||||
|
if (bytes.contentEquals(NEW_LINE_BYTES))
|
||||||
|
output += ""
|
||||||
|
}
|
||||||
|
|
||||||
file.writer().use {
|
file.writer().use {
|
||||||
val iterator = output.iterator()
|
val iterator = output.iterator()
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@@ -155,6 +162,7 @@ class NMSBinding : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val NEW_LINE = System.lineSeparator()
|
private val NEW_LINE = System.lineSeparator()
|
||||||
|
private val NEW_LINE_BYTES = NEW_LINE.encodeToByteArray()
|
||||||
private fun String.parseVersion() = substringBefore('-').split(".").let {
|
private fun String.parseVersion() = substringBefore('-').split(".").let {
|
||||||
it[1].toInt() to it[2].toInt()
|
it[1].toInt() to it[2].toInt()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user