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.)
This commit is contained in:
Kevin Turner 2021-04-26 11:14:33 -07:00
parent 077f28843b
commit 2b54db578a
5 changed files with 31 additions and 26 deletions

View file

@ -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)
}
}
}

View file

@ -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<Sync>("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")

View file

@ -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 {

View file

@ -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

View file

@ -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')
// }
}