From 8df63033e4fe4695f48e89bcdf80cd6354391285 Mon Sep 17 00:00:00 2001 From: Jendrik Johannes Date: Wed, 3 Jan 2024 11:48:55 +0100 Subject: [PATCH] Improve error messages --- .../dependencies/JavaModuleDependenciesExtension.java | 5 ++++- .../gradlex/javamodule/dependencies/test/WarningsTest.groovy | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gradlex/javamodule/dependencies/JavaModuleDependenciesExtension.java b/src/main/java/org/gradlex/javamodule/dependencies/JavaModuleDependenciesExtension.java index 12b2fda..d25eca4 100644 --- a/src/main/java/org/gradlex/javamodule/dependencies/JavaModuleDependenciesExtension.java +++ b/src/main/java/org/gradlex/javamodule/dependencies/JavaModuleDependenciesExtension.java @@ -264,7 +264,7 @@ public Provider create(String moduleName, SourceSet sourceSetWithMod return dependency; } else { getProject().getLogger().lifecycle( - "[WARN] [Java Module Dependencies] javaModuleDependencies.moduleNameToGA.put(\"" + moduleName + "\", \"group:artifact\") mapping is missing."); + "[WARN] [Java Module Dependencies] " + moduleName + "=group:artifact missing in " + getModulesProperties().get().getAsFile()); return null; } }); @@ -325,6 +325,9 @@ private Map findGav(String ga, String moduleName) { Optional version = catalog == null ? empty() : catalog.findVersion(moduleName.replace('_', '.')); Map gav = new HashMap<>(); String[] gaSplit = ga.split(":"); + if (gaSplit.length < 2) { + throw new RuntimeException("Invalid mapping: " + moduleName + "="+ ga); + } gav.put(GAV.GROUP, gaSplit[0]); gav.put(GAV.ARTIFACT, gaSplit[1]); version.ifPresent(versionConstraint -> gav.put(GAV.VERSION, versionConstraint)); diff --git a/src/test/groovy/org/gradlex/javamodule/dependencies/test/WarningsTest.groovy b/src/test/groovy/org/gradlex/javamodule/dependencies/test/WarningsTest.groovy index 88214e5..67086ba 100644 --- a/src/test/groovy/org/gradlex/javamodule/dependencies/test/WarningsTest.groovy +++ b/src/test/groovy/org/gradlex/javamodule/dependencies/test/WarningsTest.groovy @@ -47,6 +47,6 @@ class WarningsTest extends Specification { when: def result = fail() then: - result.output.contains('[WARN] [Java Module Dependencies] javaModuleDependencies.moduleNameToGA.put("commons.math3", "group:artifact") mapping is missing.\n') + result.output.contains('[WARN] [Java Module Dependencies] commons.math3=group:artifact missing in') } }