mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2026-09-22 00:48:45 +00:00
Revert previous commit, fix illuaminate
This commit is contained in:
@@ -33,7 +33,7 @@ repos:
|
|||||||
|
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
- id: license
|
- id: spotless
|
||||||
name: Spotless
|
name: Spotless
|
||||||
files: ".*\\.(java|kt|kts)$"
|
files: ".*\\.(java|kt|kts)$"
|
||||||
language: system
|
language: system
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ SPDX-License-Identifier = "CC0-1.0"
|
|||||||
path = [
|
path = [
|
||||||
# Generated/data files are CC0.
|
# Generated/data files are CC0.
|
||||||
"gradle/gradle-daemon-jvm.properties",
|
"gradle/gradle-daemon-jvm.properties",
|
||||||
"gradle/verification-keyring.keys",
|
|
||||||
"gradle/verification-metadata.xml",
|
"gradle/verification-metadata.xml",
|
||||||
"projects/common/src/main/resources/assets/computercraft/sounds.json",
|
"projects/common/src/main/resources/assets/computercraft/sounds.json",
|
||||||
"projects/common/src/main/resources/assets/computercraft/sounds/empty.ogg",
|
"projects/common/src/main/resources/assets/computercraft/sounds/empty.ogg",
|
||||||
|
|||||||
@@ -4,11 +4,14 @@
|
|||||||
|
|
||||||
package cc.tweaked.gradle
|
package cc.tweaked.gradle
|
||||||
|
|
||||||
|
import cc.tweaked.vanillaextract.utils.Dependencies
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.artifacts.Dependency
|
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.Property
|
||||||
import org.gradle.api.provider.Provider
|
import org.gradle.api.provider.Provider
|
||||||
import org.gradle.api.tasks.AbstractExecTask
|
import org.gradle.api.tasks.AbstractExecTask
|
||||||
@@ -21,21 +24,26 @@ abstract class IlluaminateExtension {
|
|||||||
abstract val version: Property<String>
|
abstract val version: Property<String>
|
||||||
|
|
||||||
/** The path to illuaminate. If not given, illuaminate will be downloaded automatically. */
|
/** 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) {
|
override fun apply(project: Project) {
|
||||||
val extension = project.extensions.create("illuaminate", IlluaminateExtension::class.java)
|
val extension = project.extensions.create("illuaminate", IlluaminateExtension::class.java)
|
||||||
extension.file.convention(setupDependency(project, extension.version))
|
extension.file.convention(setupDependency(project, extension.version))
|
||||||
|
|
||||||
project.tasks.register(SetupIlluaminate.NAME, SetupIlluaminate::class.java) {
|
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. */
|
/** 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 {
|
project.repositories.ivy {
|
||||||
name = "Illuaminate"
|
name = "Illuaminate"
|
||||||
setUrl("https://squiddev.cc/illuaminate/bin/")
|
setUrl("https://squiddev.cc/illuaminate/bin/")
|
||||||
@@ -50,12 +58,25 @@ class IlluaminatePlugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return version.map {
|
val configuration = Dependencies.createDetachedConfiguration(
|
||||||
val dep = illuaminateArtifact(project, it)
|
project.configurations, "Illuaminate", version.map { illuaminateArtifact(project, it) },
|
||||||
val configuration = project.configurations.detachedConfiguration(dep)
|
)
|
||||||
configuration.isTransitive = false
|
|
||||||
configuration.resolve().single()
|
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. */
|
/** 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.
|
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. */
|
/** Prepares illuaminate for being run. This simply requests the dependency and then marks it as executable. */
|
||||||
abstract class SetupIlluaminate : DefaultTask() {
|
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