mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2026-06-28 07:38:51 +00:00
Revert previous commit, fix illuaminate
This commit is contained in:
@@ -33,7 +33,7 @@ repos:
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: license
|
||||
- id: spotless
|
||||
name: Spotless
|
||||
files: ".*\\.(java|kt|kts)$"
|
||||
language: system
|
||||
|
||||
@@ -13,7 +13,6 @@ SPDX-License-Identifier = "CC0-1.0"
|
||||
path = [
|
||||
# Generated/data files are CC0.
|
||||
"gradle/gradle-daemon-jvm.properties",
|
||||
"gradle/verification-keyring.keys",
|
||||
"gradle/verification-metadata.xml",
|
||||
"projects/common/src/main/resources/assets/computercraft/sounds.json",
|
||||
"projects/common/src/main/resources/assets/computercraft/sounds/empty.ogg",
|
||||
|
||||
@@ -4,11 +4,14 @@
|
||||
|
||||
package cc.tweaked.gradle
|
||||
|
||||
import cc.tweaked.vanillaextract.utils.Dependencies
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.api.file.RegularFile
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.AbstractExecTask
|
||||
@@ -21,21 +24,26 @@ abstract class IlluaminateExtension {
|
||||
abstract val version: Property<String>
|
||||
|
||||
/** The path to illuaminate. If not given, illuaminate will be downloaded automatically. */
|
||||
abstract val file: Property<File>
|
||||
abstract val file: RegularFileProperty
|
||||
|
||||
init {
|
||||
version.finalizeValueOnRead()
|
||||
file.finalizeValueOnRead()
|
||||
}
|
||||
}
|
||||
|
||||
class IlluaminatePlugin : Plugin<Project> {
|
||||
abstract class IlluaminatePlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
val extension = project.extensions.create("illuaminate", IlluaminateExtension::class.java)
|
||||
extension.file.convention(setupDependency(project, extension.version))
|
||||
|
||||
project.tasks.register(SetupIlluaminate.NAME, SetupIlluaminate::class.java) {
|
||||
file.set(extension.file.map { it.absolutePath })
|
||||
file.set(extension.file.map { it.asFile.absolutePath })
|
||||
}
|
||||
}
|
||||
|
||||
/** Set up a repository for illuaminate and download our binary from it. */
|
||||
private fun setupDependency(project: Project, version: Provider<String>): Provider<File> {
|
||||
private fun setupDependency(project: Project, version: Provider<String>): Provider<RegularFile> {
|
||||
project.repositories.ivy {
|
||||
name = "Illuaminate"
|
||||
setUrl("https://squiddev.cc/illuaminate/bin/")
|
||||
@@ -50,12 +58,25 @@ class IlluaminatePlugin : Plugin<Project> {
|
||||
}
|
||||
}
|
||||
|
||||
return version.map {
|
||||
val dep = illuaminateArtifact(project, it)
|
||||
val configuration = project.configurations.detachedConfiguration(dep)
|
||||
configuration.isTransitive = false
|
||||
configuration.resolve().single()
|
||||
val configuration = Dependencies.createDetachedConfiguration(
|
||||
project.configurations, "Illuaminate", version.map { illuaminateArtifact(project, it) },
|
||||
)
|
||||
|
||||
if (project.gradle.startParameter.writeDependencyVerifications.isNotEmpty()) {
|
||||
val allNatives = project.configurations.detachedConfiguration()
|
||||
allNatives.isCanBeConsumed = false
|
||||
allNatives.isCanBeResolved = true
|
||||
for (ext in listOf("linux-x86_64", "macos-x86_64", "windows-x86_64.exe")) {
|
||||
allNatives.dependencies.addLater(
|
||||
version.map {
|
||||
project.dependencyFactory.create("cc.squiddev", "illuaminate", it, null, ext)
|
||||
},
|
||||
)
|
||||
}
|
||||
project.afterEvaluate { allNatives.resolve() }
|
||||
}
|
||||
|
||||
return project.layout.file(project.provider { configuration.singleFile })
|
||||
}
|
||||
|
||||
/** Define a dependency for illuaminate from a version number and the current operating system. */
|
||||
@@ -84,7 +105,7 @@ class IlluaminatePlugin : Plugin<Project> {
|
||||
}
|
||||
|
||||
private val Task.illuaminatePath: String? // "?" needed to avoid overload ambiguity in setExecutable below.
|
||||
get() = project.extensions.getByType(IlluaminateExtension::class.java).file.get().absolutePath
|
||||
get() = project.extensions.getByType(IlluaminateExtension::class.java).file.getAbsolutePath()
|
||||
|
||||
/** Prepares illuaminate for being run. This simply requests the dependency and then marks it as executable. */
|
||||
abstract class SetupIlluaminate : DefaultTask() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+4786
-497
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user