From d80dd665888b0379348ca8a2221ee15ac9e259f6 Mon Sep 17 00:00:00 2001 From: piexel Date: Tue, 6 Oct 2026 14:17:54 +0200 Subject: [PATCH] Compile core against IrisApi from the sibling checkout gradle/irisapi-resolution.settings.gradle includes the IrisApi checkout as a composite build, like VolmLib, and fails clearly when there is none. Core uses it compileOnly and in tests: how the API reaches a server is undecided, so it is not shaded and a built jar cannot load packs yet. --- core/build.gradle | 6 ++ gradle/irisapi-resolution.settings.gradle | 84 +++++++++++++++++++++++ settings.gradle | 1 + 3 files changed, 91 insertions(+) create mode 100644 gradle/irisapi-resolution.settings.gradle diff --git a/core/build.gradle b/core/build.gradle index c2abe31ff..a2610d8e3 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -53,6 +53,11 @@ String volmLibCoordinate = providers.gradleProperty('volmLibCoordinate') dependencies { api(project(':spi')) + // IrisApi, from the sibling checkout (gradle/irisapi-resolution.settings.gradle). compileOnly on + // purpose: how the API reaches a server at runtime is undecided, so it is not shaded into the + // plugin or mod jars, and a built jar cannot load packs until that is decided. + compileOnly('com.volmit:IrisApi') + // Provided or Classpath compileOnly(libs.lombok) annotationProcessor(libs.lombok) @@ -107,6 +112,7 @@ dependencies { slim(libs.dom4j) slim(libs.jaxen) + testImplementation('com.volmit:IrisApi') testImplementation('junit:junit:4.13.2') testImplementation('org.mockito:mockito-core:5.23.0') testImplementation(libs.paper.api) diff --git a/gradle/irisapi-resolution.settings.gradle b/gradle/irisapi-resolution.settings.gradle new file mode 100644 index 000000000..8b5ac6710 --- /dev/null +++ b/gradle/irisapi-resolution.settings.gradle @@ -0,0 +1,84 @@ +/* + * Iris is a World Generator for Minecraft Servers + * Copyright (c) 2026 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* + * IrisApi source resolution, applied by the root settings file: + * + * apply from: new File(settingsDir, 'gradle/irisapi-resolution.settings.gradle') + * + * IrisApi is a separate project with no published artifact, so Iris always compiles against a sibling + * checkout as a composite build. Core declares `com.volmit:IrisApi`; this substitutes it with the + * checkout's root project. + * + * Behaviour: + * -PlocalIrisApiDirectory= explicit IrisApi checkout (relative paths resolve against the + * including build's settings directory). + * IRISAPI_DIR= same, via environment. + * otherwise walk up from settingsDir looking for an `IrisApi` directory + * that contains a settings script. + * + * When nothing is found the build fails here, naming where it looked, rather than later with an + * unresolvable dependency. + * + * The modded adapters do not apply this: they compile against core's jar and use no IrisApi type. + */ + +import java.io.File + +boolean irisHasIrisApiSettings(File directory) { + if (directory == null) { + return false + } + + new File(directory, 'settings.gradle.kts').exists() || new File(directory, 'settings.gradle').exists() +} + +File irisResolveLocalIrisApiDirectory() { + String configuredPath = providers.gradleProperty('localIrisApiDirectory') + .orElse(providers.environmentVariable('IRISAPI_DIR')) + .orNull + if (configuredPath != null && !configuredPath.isBlank()) { + File configuredDirectory = new File(configuredPath) + if (!configuredDirectory.isAbsolute()) { + configuredDirectory = new File(settingsDir, configuredPath) + } + if (irisHasIrisApiSettings(configuredDirectory)) { + return configuredDirectory + } + throw new GradleException("IrisApi checkout ${configuredDirectory} has no settings script") + } + + File currentDirectory = settingsDir + while (currentDirectory != null) { + File candidate = new File(currentDirectory, 'IrisApi') + if (irisHasIrisApiSettings(candidate)) { + return candidate + } + + currentDirectory = currentDirectory.parentFile + } + + throw new GradleException("No IrisApi checkout found in ${settingsDir} or its parent directories; " + + "clone IrisApi next to Iris, or pass -PlocalIrisApiDirectory= or IRISAPI_DIR") +} + +includeBuild(irisResolveLocalIrisApiDirectory()) { + dependencySubstitution { + substitute(module('com.volmit:IrisApi')).using(project(':')) + } +} diff --git a/settings.gradle b/settings.gradle index f3e4cca6b..dac2fd0de 100644 --- a/settings.gradle +++ b/settings.gradle @@ -23,6 +23,7 @@ plugins { rootProject.name = 'Iris' apply from: new File(settingsDir, 'gradle/volmlib-resolution.settings.gradle') +apply from: new File(settingsDir, 'gradle/irisapi-resolution.settings.gradle') include(':core', ':core:agent') include(':probe')