diff --git a/build.gradle b/build.gradle index 1cc820e4f25..c986c48c023 100644 --- a/build.gradle +++ b/build.gradle @@ -190,14 +190,10 @@ def terasologyModules() { } // Helpers that do magic things after having dependencies attached below -task moduleClasses task moduleJars // This magically makes everything work - without this the desired module projects returned have no tasks :-( gradle.projectsEvaluated { - // Note how "classes" may indirectly trigger "jar" for module dependencies of modules (module compile dependency) - moduleClasses.dependsOn(terasologyModules().classes) - // This makes it work for a full jar task moduleJars.dependsOn(terasologyModules().jar) } diff --git a/facades/PC/build.gradle.kts b/facades/PC/build.gradle.kts index 82cb15fe70f..29d6b33a659 100644 --- a/facades/PC/build.gradle.kts +++ b/facades/PC/build.gradle.kts @@ -1,4 +1,4 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 // The PC facade is responsible for the primary distribution - a plain Java application runnable on PCs @@ -92,6 +92,11 @@ dependencies { // TODO: Consider whether we can move the CR dependency back here from the engine, where it is referenced from the main menu implementation(group = "org.terasology.crashreporter", name = "cr-terasology", version = "4.1.0") + + // Make sure any local module builds are up-to-date and have their dependencies by declaring + // a runtime dependency on whatever the `:modules` subproject declares. + // This won't add anything if there are no modules checked out. + runtimeOnly(platform(project(":modules"))) } // Instructions for packaging a jar file for the PC facade @@ -113,11 +118,10 @@ configurations { } // Used for all game configs. -val commonConfigure : JavaExec.()-> Unit = { +fun JavaExec.commonConfigure() { group = "terasology run" dependsOn(":extractNatives") - dependsOn(":moduleClasses") dependsOn("classes") // Run arguments diff --git a/facades/TeraEd/build.gradle b/facades/TeraEd/build.gradle index 1e7cd56d860..be43aefd617 100644 --- a/facades/TeraEd/build.gradle +++ b/facades/TeraEd/build.gradle @@ -26,6 +26,8 @@ sourceSets { dependencies { implementation project(':engine') implementation group: 'org.reflections', name: 'reflections', version: '0.9.10' + + runtimeOnly(platform(project(":modules"))) } application { @@ -46,7 +48,6 @@ task editor(type:JavaExec) { // Dependencies: natives + all modules & the PC facade itself (which will trigger the engine) dependsOn rootProject.extractNatives - dependsOn rootProject.moduleClasses dependsOn classes // Run arguments diff --git a/modules/build.gradle.kts b/modules/build.gradle.kts new file mode 100644 index 00000000000..d51022963af --- /dev/null +++ b/modules/build.gradle.kts @@ -0,0 +1,25 @@ +// Copyright 2020 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 + +plugins { + `java-platform` +} + +javaPlatform { + allowDependencies() +} + +dependencies { + // This platform depends on each of its subprojects. + subprojects { + runtime(this) + } +} + +// Allows using :modules:clean as a shortcut for running clean in each module. +tasks.named("clean").configure { + val cleanPlatform = this + subprojects { + cleanPlatform.dependsOn(this.tasks.named("clean")) + } +} diff --git a/modules/subprojects.settings.gradle b/modules/subprojects.settings.gradle index bc3467d19c6..570d905ca86 100644 --- a/modules/subprojects.settings.gradle +++ b/modules/subprojects.settings.gradle @@ -1,18 +1,5 @@ -/* - * Copyright 2020 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2020 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 // This magically allows subdirs in this subproject to themselves become sub-subprojects in a proper tree structure new File(rootDir, 'modules').eachDir { possibleSubprojectDir ->