Skip to content

Commit 16f7047

Browse files
committed
chore: Fix Maven dependency resolving mechanism in Citrus JBang
- ClassLoader helper utils need to clear cache after test loader lookup, otherwise the dynamically loaded components get ignored
1 parent 5e9b0bb commit 16f7047

2 files changed

Lines changed: 10 additions & 16 deletions

File tree

tools/jbang/src/main/java/org/citrusframework/jbang/commands/Run.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import org.citrusframework.CitrusInstanceManager;
4545
import org.citrusframework.CitrusSettings;
4646
import org.citrusframework.agent.CitrusAgentConfiguration;
47-
import org.citrusframework.common.TestLoader;
4847
import org.citrusframework.common.TestSourceHelper;
4948
import org.citrusframework.exceptions.CitrusRuntimeException;
5049
import org.citrusframework.jbang.CitrusJBangMain;
@@ -172,15 +171,15 @@ private int run() {
172171
workDir = basePath;
173172
}
174173

174+
final List<TestRunConfiguration> configurations = getRunConfigurations(tests);
175+
175176
final ExitStatusTestReporter exitStatus = new ExitStatusTestReporter();
176177
CitrusInstanceManager.addInstanceProcessor(instance -> instance.addTestReporter(exitStatus));
177178

178179
if (!offline) {
179180
resolveArtifacts(tests);
180181
}
181182

182-
final List<TestRunConfiguration> configurations = getRunConfigurations(tests);
183-
184183
int exitCode = 0;
185184
for (TestRunConfiguration configuration : configurations) {
186185
// Set properties as System properties
@@ -215,17 +214,12 @@ private void resolveArtifacts(List<String> tests) {
215214
// Handle DSL test loaders according to file extensions
216215
tests.stream().map(FileUtils::getFileExtension).distinct().forEach(ext -> {
217216
if (StringUtils.hasText(ext)) {
218-
219-
220-
Optional<TestLoader> existing = TestLoader.lookup(ext, true);
221-
if (existing.isEmpty()) {
222-
if ("feature".equals(ext)) {
223-
// Add Cucumber DSL support modules and a set of default Citrus steps
224-
allModules.add("citrus-cucumber");
225-
allModules.add("citrus-cucumber-core");
226-
} else {
227-
allModules.add("citrus-" + ext);
228-
}
217+
if ("feature".equals(ext)) {
218+
// Add Cucumber DSL support modules and a set of default Citrus steps
219+
allModules.add("citrus-cucumber");
220+
allModules.add("citrus-cucumber-core");
221+
} else {
222+
allModules.add("citrus-" + ext);
229223
}
230224
}
231225
});
@@ -297,7 +291,7 @@ private void resolveArtifacts(List<String> tests) {
297291
});
298292

299293
// Adapt and set class loader in main thread
300-
ClassLoaderHelper.updateContextClassloader();
294+
ClassLoaderHelper.updateContextClassloader(true);
301295
}
302296
}
303297

tools/jbang/src/main/java/org/citrusframework/jbang/maven/MavenDependencyResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public List<MavenArtifact> resolveModule(String module) {
9696
}
9797

9898
return resolve("org.citrusframework:%s:%s".formatted(moduleName, version),
99-
CitrusVersion.version().contains("-SNAPSHOT"), true);
99+
version.contains("-SNAPSHOT"), true);
100100
}
101101

102102
public MavenDependencyResolver withRepository(String key, String value) {

0 commit comments

Comments
 (0)