-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update to develocity plugin * properly support toolchains
- Loading branch information
1 parent
8da1c9c
commit 4d40e30
Showing
8 changed files
with
121 additions
and
123 deletions.
There are no files selected for viewing
This file contains 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 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 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
13 changes: 0 additions & 13 deletions
13
src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJavaExtension.kt
This file was deleted.
Oops, something went wrong.
12 changes: 2 additions & 10 deletions
12
src/main/kotlin/dev/mythicdrops/gradle/conventions/MythicDropsJavaPlugin.kt
This file contains 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 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 |
---|---|---|
|
@@ -3,108 +3,126 @@ package dev.mythicdrops.gradle.spigot | |
import org.gradle.api.DefaultTask | ||
import org.gradle.api.file.FileSystemOperations | ||
import org.gradle.api.file.RegularFileProperty | ||
import org.gradle.api.plugins.JavaPluginExtension | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.services.ServiceReference | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.InputFile | ||
import org.gradle.api.tasks.Nested | ||
import org.gradle.api.tasks.TaskAction | ||
import org.gradle.jvm.toolchain.JavaLauncher | ||
import org.gradle.jvm.toolchain.JavaToolchainService | ||
import org.gradle.kotlin.dsl.getByType | ||
import org.gradle.process.ExecOperations | ||
import java.io.File | ||
import java.nio.file.Paths | ||
import javax.inject.Inject | ||
|
||
abstract class RunSpigotBuildToolsTask | ||
@Inject | ||
constructor( | ||
private val execOperations: ExecOperations, | ||
private val fileSystemOperations: FileSystemOperations, | ||
) : DefaultTask() { | ||
@get:ServiceReference(SyncTaskBuildService.NAME) | ||
abstract val syncTask: Property<SyncTaskBuildService> | ||
abstract class RunSpigotBuildToolsTask : DefaultTask() { | ||
@get:ServiceReference(SyncTaskBuildService.NAME) | ||
Check warning on line 22 in src/main/kotlin/dev/mythicdrops/gradle/spigot/RunSpigotBuildToolsTask.kt GitHub Actions / qodanaUnstable API Usage
|
||
abstract val syncTask: Property<SyncTaskBuildService> | ||
|
||
@get:InputFile | ||
abstract val buildToolsLocation: RegularFileProperty | ||
@get:InputFile | ||
abstract val buildToolsLocation: RegularFileProperty | ||
|
||
@get:Input | ||
abstract val includeRemapped: Property<Boolean> | ||
@get:Input | ||
abstract val includeRemapped: Property<Boolean> | ||
|
||
@get:Input | ||
abstract val version: Property<String> | ||
@get:Input | ||
abstract val version: Property<String> | ||
|
||
init { | ||
description = "Runs Spigot BuildTools.jar for a specific Minecraft version" | ||
group = "spigot" | ||
@get:Nested | ||
abstract val launcher: Property<JavaLauncher> | ||
|
||
@get:Inject | ||
abstract val execOperations: ExecOperations | ||
|
||
@get:Inject | ||
abstract val fileSystemOperations: FileSystemOperations | ||
|
||
@get:Inject | ||
abstract val javaToolchainService: JavaToolchainService | ||
|
||
init { | ||
description = "Runs Spigot BuildTools.jar for a specific Minecraft version" | ||
group = "spigot" | ||
|
||
val toolchain = project.extensions.getByType<JavaPluginExtension>().toolchain | ||
val defaultLauncher = javaToolchainService.launcherFor(toolchain) | ||
launcher.convention(defaultLauncher) | ||
} | ||
|
||
@TaskAction | ||
fun runSpigotBuildTools() { | ||
val version = version.getOrElse("") | ||
if (version.isBlank()) { | ||
logger.lifecycle("Not running Spigot build tools as the version is blank") | ||
return | ||
} | ||
|
||
@TaskAction | ||
fun runSpigotBuildTools() { | ||
val version = version.getOrElse("") | ||
if (version.isBlank()) { | ||
logger.lifecycle("Not running Spigot build tools as the version is blank") | ||
return | ||
} | ||
|
||
val mavenLocalDirectory = Paths.get(project.repositories.mavenLocal().url).toFile() | ||
if (!mavenLocalDirectory.exists()) { | ||
logger.lifecycle("Creating Maven Local repository at ${mavenLocalDirectory.absolutePath}") | ||
mavenLocalDirectory.mkdirs() | ||
} | ||
|
||
normalVersion(mavenLocalDirectory, version) | ||
if (includeRemapped.getOrElse(false)) { | ||
remappedVersion(mavenLocalDirectory, version) | ||
} | ||
val mavenLocalDirectory = Paths.get(project.repositories.mavenLocal().url).toFile() | ||
if (!mavenLocalDirectory.exists()) { | ||
logger.lifecycle("Creating Maven Local repository at ${mavenLocalDirectory.absolutePath}") | ||
mavenLocalDirectory.mkdirs() | ||
} | ||
|
||
private fun normalVersion( | ||
mavenLocalDirectory: File, | ||
version: String, | ||
) { | ||
val versionJar = | ||
mavenLocalDirectory.resolve( | ||
"org/spigotmc/spigot/$version-R0.1-SNAPSHOT/spigot-$version-R0.1-SNAPSHOT.jar", | ||
) | ||
if (versionJar.exists()) { | ||
logger.lifecycle("Skipping $version as Spigot JAR is found at ${versionJar.absolutePath}") | ||
return | ||
} | ||
val jar = buildToolsLocation.get().asFile | ||
val versionDir = jar.parentFile.resolve(version) | ||
fileSystemOperations.copy { | ||
from(jar) | ||
into(versionDir) | ||
} | ||
execOperations.javaexec { | ||
args(listOf("--rev", version)) | ||
workingDir = versionDir.absoluteFile | ||
jvmArgs = listOf("-Xmx1024M") | ||
classpath(buildToolsLocation) | ||
} | ||
normalVersion(mavenLocalDirectory, version) | ||
if (includeRemapped.getOrElse(false)) { | ||
remappedVersion(mavenLocalDirectory, version) | ||
} | ||
} | ||
|
||
private fun remappedVersion( | ||
mavenLocalDirectory: File, | ||
version: String, | ||
) { | ||
val versionJar = | ||
mavenLocalDirectory.resolve( | ||
"org/spigotmc/spigot/$version-R0.1-SNAPSHOT/spigot-$version-R0.1-SNAPSHOT-remapped-mojang.jar", | ||
) | ||
if (versionJar.exists()) { | ||
logger.lifecycle("Skipping $version as Spigot remapped JAR is found at ${versionJar.absolutePath}") | ||
return | ||
} | ||
val jar = buildToolsLocation.get().asFile | ||
val versionDir = jar.parentFile.resolve(version) | ||
fileSystemOperations.copy { | ||
from(jar) | ||
into(versionDir) | ||
} | ||
execOperations.javaexec { | ||
args(listOf("--rev", version, "--remapped")) | ||
workingDir = versionDir.absoluteFile | ||
jvmArgs = listOf("-Xmx1024M") | ||
classpath(buildToolsLocation) | ||
} | ||
private fun normalVersion( | ||
mavenLocalDirectory: File, | ||
version: String, | ||
) { | ||
val versionJar = | ||
mavenLocalDirectory.resolve( | ||
"org/spigotmc/spigot/$version-R0.1-SNAPSHOT/spigot-$version-R0.1-SNAPSHOT.jar", | ||
) | ||
if (versionJar.exists()) { | ||
logger.lifecycle("Skipping $version as Spigot JAR is found at ${versionJar.absolutePath}") | ||
return | ||
} | ||
val jar = buildToolsLocation.get().asFile | ||
val versionDir = jar.parentFile.resolve(version) | ||
fileSystemOperations.copy { | ||
from(jar) | ||
into(versionDir) | ||
} | ||
execOperations.javaexec { | ||
args(listOf("--rev", version)) | ||
workingDir = versionDir.absoluteFile | ||
jvmArgs = listOf("-Xmx1024M") | ||
classpath(buildToolsLocation) | ||
executable(launcher.get().executablePath) | ||
} | ||
} | ||
|
||
private fun remappedVersion( | ||
mavenLocalDirectory: File, | ||
version: String, | ||
) { | ||
val versionJar = | ||
mavenLocalDirectory.resolve( | ||
"org/spigotmc/spigot/$version-R0.1-SNAPSHOT/spigot-$version-R0.1-SNAPSHOT-remapped-mojang.jar", | ||
) | ||
if (versionJar.exists()) { | ||
logger.lifecycle("Skipping $version as Spigot remapped JAR is found at ${versionJar.absolutePath}") | ||
return | ||
} | ||
val jar = buildToolsLocation.get().asFile | ||
val versionDir = jar.parentFile.resolve(version) | ||
fileSystemOperations.copy { | ||
from(jar) | ||
into(versionDir) | ||
} | ||
execOperations.javaexec { | ||
args(listOf("--rev", version, "--remapped")) | ||
workingDir = versionDir.absoluteFile | ||
jvmArgs = listOf("-Xmx1024M") | ||
classpath(buildToolsLocation) | ||
executable(launcher.get().executablePath) | ||
} | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -1 +1 @@ | ||
version=7.2.* | ||
version=8.0.* |
This file contains 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