From 2b54db578a60ae8beeb1ebc9fa2fe3196207f97e Mon Sep 17 00:00:00 2001 From: Kevin Turner <83819+keturn@users.noreply.github.com> Date: Mon, 26 Apr 2021 11:14:33 -0700 Subject: [PATCH] build: disable build-time cacheReflections in a more consistent way Instead of commenting out the code in the reflection-manifest plugin, comment out its usages. (Yes commented code is bad either way but I still feel some doubt about which way this branch is going.) --- .../kotlin/reflections-manifest.gradle.kts | 28 +++++++++++-------- .../main/kotlin/terasology-module.gradle.kts | 10 +++---- engine/build.gradle | 4 +-- facades/PC/build.gradle.kts | 1 - subsystems/build.gradle | 14 +++++----- 5 files changed, 31 insertions(+), 26 deletions(-) diff --git a/build-logic/src/main/kotlin/reflections-manifest.gradle.kts b/build-logic/src/main/kotlin/reflections-manifest.gradle.kts index 4048ad6fc6..4696090dbb 100644 --- a/build-logic/src/main/kotlin/reflections-manifest.gradle.kts +++ b/build-logic/src/main/kotlin/reflections-manifest.gradle.kts @@ -1,6 +1,11 @@ // Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 +import org.reflections.Reflections +import org.reflections.scanners.SubTypesScanner +import org.reflections.scanners.TypeAnnotationsScanner +import org.reflections.serializers.JsonSerializer +import org.reflections.util.ConfigurationBuilder import java.net.URLClassLoader tasks.register("cacheReflections") { @@ -21,16 +26,17 @@ tasks.register("cacheReflections") { doLast { val classPaths = mainSourceSet.compileClasspath.map { it.toURI().toURL() } val classLoader = URLClassLoader(classPaths.toTypedArray()) -// try { -// val reflections = Reflections(ConfigurationBuilder() -// .setSerializer(JsonSerializer()) -// .addClassLoader(classLoader) -// // .filterInputsBy(FilterBuilder.parsePackages("+org")) -// .addUrls(inputs.files.map { it.toURI().toURL() }) -// .setScanners(TypeAnnotationsScanner(), SubTypesScanner(false))) -// reflections.save(manifestFile.toString()) -// } catch (e: java.net.MalformedURLException) { -// logger.error("Cannot parse input to url", e) -// } + try { + val reflections = Reflections( + ConfigurationBuilder() + .setSerializer(JsonSerializer()) + .addClassLoader(classLoader) + // .filterInputsBy(FilterBuilder.parsePackages("+org")) + .addUrls(inputs.files.map { it.toURI().toURL() }) + .setScanners(TypeAnnotationsScanner(), SubTypesScanner(false))) + reflections.save(manifestFile.toString()) + } catch (e: java.net.MalformedURLException) { + logger.error("Cannot parse input to url", e) + } } } diff --git a/build-logic/src/main/kotlin/terasology-module.gradle.kts b/build-logic/src/main/kotlin/terasology-module.gradle.kts index c67eaaefa8..4134be4685 100644 --- a/build-logic/src/main/kotlin/terasology-module.gradle.kts +++ b/build-logic/src/main/kotlin/terasology-module.gradle.kts @@ -9,7 +9,7 @@ import org.terasology.gradology.ModuleMetadataForGradle plugins { `java-library` - id("reflections-manifest") +// id("reflections-manifest") idea eclipse } @@ -133,14 +133,14 @@ tasks.register("syncDeltas") { into("${mainSourceSet.output.classesDirs.first()}/deltas") } -tasks.named("compileJava") { - finalizedBy("cacheReflections") -} +//tasks.named("compileJava") { +// finalizedBy("cacheReflections") +//} // Instructions for packaging a jar file - is a manifest even needed for modules? tasks.named("jar") { // Make sure the assets directory is included - dependsOn("cacheReflections") +// dependsOn("cacheReflections") dependsOn("syncAssets") dependsOn("syncOverrides") dependsOn("syncDeltas") diff --git a/engine/build.gradle b/engine/build.gradle index 332405c7e0..989aa4eb45 100644 --- a/engine/build.gradle +++ b/engine/build.gradle @@ -6,7 +6,7 @@ plugins { id "java-library" id "org.jetbrains.gradle.plugin.idea-ext" - id("reflections-manifest") +// id("reflections-manifest") } // Grab all the common stuff like plugins to use, artifact repositories, code analysis config, etc @@ -135,7 +135,7 @@ jar { // Unlike the content modules Gradle grabs the assets as they're in a resources directory. Need to avoid dupes tho duplicatesStrategy = "EXCLUDE" - dependsOn(tasks.named("cacheReflections")) +// dependsOn(tasks.named("cacheReflections")) doFirst { manifest { diff --git a/facades/PC/build.gradle.kts b/facades/PC/build.gradle.kts index 279d916aba..6249d280a4 100644 --- a/facades/PC/build.gradle.kts +++ b/facades/PC/build.gradle.kts @@ -61,7 +61,6 @@ group = "org.terasology.facades" dependencies { implementation(project(":engine")) - implementation("org.terasology:reflections:0.9.12-MB") implementation(project(":subsystems:DiscordRPC")) // TODO: Consider whether we can move the CR dependency back here from the engine, where it is referenced from the main menu diff --git a/subsystems/build.gradle b/subsystems/build.gradle index 8011f64f2c..55c7ef79ac 100644 --- a/subsystems/build.gradle +++ b/subsystems/build.gradle @@ -1,15 +1,15 @@ // Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 -plugins { - id("reflections-manifest").apply(false) -} +//plugins { +// id("reflections-manifest").apply(false) +//} subprojects { // Hack for getting sourcesSets.main.output there. plugins.apply('java') plugins.apply('idea') - plugins.apply("reflections-manifest") +// plugins.apply("reflections-manifest") def sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).sourceSets @@ -25,7 +25,7 @@ subprojects { } } - tasks.named("jar") { - dependsOn('cacheReflections') - } +// tasks.named("jar") { +// dependsOn('cacheReflections') +// } }