P1.4 : version 0.5.0-p1, une seule source (gradle.properties)

- gradle.properties : mod_version=0.5.0-p1.
- neoforge.mods.toml : version="${mod_version}", rempli par processResources.
- Manifeste du jar : Implementation-Title / -Version / -Vendor.
- Version affichee au chargement, au demarrage (journal) et dans /garde status.
- Tests : VersionP1Test (toml traite == gradle.properties, pas de version en
  dur dans la source).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Cette révision appartient à :
gastineltetClaude Sonnet 5.5 a révisé 2026-10-24 00:24:49 +02:00
1 Parent d21eaa2e50
révision 3507f785a5
7 fichiers modifiés
+90 -4

Aucun fichier ne correspond à votre recherche

+23
Voir le fichier
@@ -44,6 +44,29 @@ test {
testLogging { events 'passed', 'failed'; exceptionFormat 'full' }
}
// 0.5 (P1.4) : une seule source de version (gradle.properties) : neoforge.mods.toml et le manifeste du jar.
processResources {
def props = [mod_version: project.mod_version]
inputs.properties props
filesMatching('META-INF/neoforge.mods.toml') { expand props }
}
jar {
manifest {
attributes(
'Implementation-Title': 'GastinelGarde',
'Implementation-Version': project.mod_version,
'Implementation-Vendor': 'Theo Gastinel'
)
}
}
test {
// Le test de version compare le neoforge.mods.toml traité à gradle.properties.
systemProperty 'gastinelgarde.version', project.mod_version
systemProperty 'gastinelgarde.projet', project.projectDir.absolutePath
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.release = 21
+1 -1
Voir le fichier
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true
mod_version=0.4.2
mod_version=0.5.0-p1
mod_group_id=com.gastinelgarde
mod_id=gastinelgarde
+1
Voir le fichier
@@ -145,6 +145,7 @@ public final class Garde {
journal = jeu.resolve("logs").resolve("gastinelgarde.log");
try {
Files.createDirectories(journal.getParent());
ecrireJournal("demarrage GastinelGarde " + GastinelGarde.version()); // 0.5 (P1.4) : version au journal
traces = new TraceFichier(jeu.resolve("gastinelgarde-traces"), GardeSpec.tracesJours(), GardeSpec.tracesTailleOctets());
tracesEnCours = GardeSpec.tracesActives();
// Historique de suspicion : même dossier de jeu que les traces et les journaux (voir HistoriqueSuspicion).
+1 -1
Voir le fichier
@@ -73,7 +73,7 @@ public final class GardeCommands {
private static int status(CommandContext<CommandSourceStack> ctx) {
GardeConfig c = Garde.config();
StringBuilder sb = new StringBuilder("GastinelGarde :");
StringBuilder sb = new StringBuilder("GastinelGarde " + GastinelGarde.version() + " :");
for (Controle k : Controle.values()) sb.append("\n ").append(k.id()).append(" = ").append(c.mode(k));
sb.append("\n sanction max = ").append(c.sanctionMax)
.append(" | traces = ").append(Garde.tracesEnCours() ? "on" : "off")
+9 -1
Voir le fichier
@@ -15,7 +15,15 @@ public class GastinelGarde {
public static final String MOD_ID = "gastinelgarde";
public static final Logger LOGGER = LoggerFactory.getLogger(GastinelGarde.class);
/** 0.5 (P1.4) : version du mod (neoforge.mods.toml, rempli depuis gradle.properties au build). */
private static String version = "?";
public static String version() {
return version;
}
public GastinelGarde(IEventBus modEventBus, ModContainer modContainer) {
version = modContainer.getModInfo().getVersion().toString();
// Config rechargeable : config/gastinelgarde-server.toml (décision D8), plus /garde reload.
modContainer.registerConfig(ModConfig.Type.COMMON, GardeSpec.SPEC, "gastinelgarde-server.toml");
modEventBus.addListener(ModConfigEvent.Loading.class, GardeSpec::onConfig);
@@ -25,6 +33,6 @@ public class GastinelGarde {
NeoForge.EVENT_BUS.register(GardeCommands.class);
NeoForge.EVENT_BUS.register(GardeAntiCrash.class); // anti-crash entités (16/10), toujours actif
LOGGER.info("[GastinelGarde] Anti-triche chargé (tous les contrôles démarrent en observe).");
LOGGER.info("[GastinelGarde] Anti-triche {} chargé (tous les contrôles démarrent en observe).", version);
}
}
+1 -1
Voir le fichier
@@ -4,7 +4,7 @@ license="MIT"
[[mods]]
modId="gastinelgarde"
version="0.4.2"
version="${mod_version}"
displayName="GastinelGarde"
authors="Théo Gastinel"
description='''Anti-triche maison : combat, cadence, rotation, timer (phase 1), no-fall, vitesse, vol et véhicules (phase 2), points d'infraction avec décroissance, setback puis expulsion, jamais de bannissement automatique. Mod côté serveur uniquement.'''
+54
Voir le fichier
@@ -0,0 +1,54 @@
package com.gastinelgarde;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.jupiter.api.Test;
/** 0.5, P1.4 : la version du neoforge.mods.toml traité est celle de gradle.properties (une seule source). */
class VersionP1Test {
/** Dossier du projet (le répertoire de travail des tests unitaires NeoForge n'est pas la racine). */
private static Path projet() {
return Path.of(System.getProperty("gastinelgarde.projet", "."));
}
private static String versionGradle() throws Exception {
Properties p = new Properties();
try (InputStream in = Files.newInputStream(projet().resolve("gradle.properties"))) {
p.load(in);
}
return p.getProperty("mod_version");
}
@Test
void modsTomlTraiteAVersionDeGradleProperties() throws Exception {
String attendu = versionGradle();
assertNotNull(attendu);
assertEquals(attendu, System.getProperty("gastinelgarde.version", attendu));
String toml;
try (InputStream in = VersionP1Test.class.getClassLoader().getResourceAsStream("META-INF/neoforge.mods.toml")) {
assertNotNull(in, "neoforge.mods.toml absent des ressources traitées");
toml = new String(in.readAllBytes(), StandardCharsets.UTF_8);
}
assertFalse(toml.contains("${"), "expansion non faite");
Matcher m = Pattern.compile("(?m)^version=\"([^\"]+)\"").matcher(toml);
assertTrue(m.find());
assertEquals(attendu, m.group(1));
}
@Test
void sourceDuTomlNEcritPasLaVersionEnDur() throws Exception {
String source = Files.readString(projet().resolve("src/main/resources/META-INF/neoforge.mods.toml"), StandardCharsets.UTF_8);
assertTrue(source.contains("version=\"${mod_version}\""), "double source de vérité");
}
}