christophd commented on code in PR #29857:
URL: https://github.com/apache/camel/pull/29857#discussion_r4575110139
##########
dsl/camel-jbang/camel-jbang-plugin-test/src/main/java/org/apache/camel/dsl/jbang/core/commands/test/TestPluginExporter.java:
##########
@@ -194,6 +193,50 @@ public void addSourceFiles(Path buildDir, String
packageName, Printer printer) t
}
+ /**
+ * Scans Citrus test files in the given directory using the Citrus code
analyzer to detect required modules and
+ * dependencies. Supports YAML, XML and Groovy test sources.
+ */
+ private Set<String> detectDependenciesFromTestSources(Path testDir) {
+ Set<String> deps = new HashSet<>();
+ DelegatingCodeAnalyzer analyzer = new DelegatingCodeAnalyzer();
+ try (Stream<Path> paths = Files.list(testDir)) {
+ paths.filter(this::isTestSource)
+ .filter(this::isAnalyzerSupported)
+ .forEach(path -> {
+ try {
+ CodeAnalyzer.ScanResult result =
analyzer.scan(path);
+ for (String module : result.modules()) {
+ deps.add(asCitrusDependency(module));
+ }
+ for (String dependency : result.dependencies()) {
+ deps.add(asScannedDependency(dependency));
+ }
+ } catch (IOException e) {
+ // ignore scan errors for missing catalog
Review Comment:
Applied — added `LOG.debug()` with path and error message. Also added a
`Logger` field to the class. Fixed in b542a96dd710.
_Claude Code on behalf of christophd_
##########
dsl/camel-jbang/camel-jbang-plugin-test/src/main/java/org/apache/camel/dsl/jbang/core/commands/test/TestPluginExporter.java:
##########
@@ -194,6 +193,50 @@ public void addSourceFiles(Path buildDir, String
packageName, Printer printer) t
}
+ /**
+ * Scans Citrus test files in the given directory using the Citrus code
analyzer to detect required modules and
+ * dependencies. Supports YAML, XML and Groovy test sources.
+ */
+ private Set<String> detectDependenciesFromTestSources(Path testDir) {
+ Set<String> deps = new HashSet<>();
+ DelegatingCodeAnalyzer analyzer = new DelegatingCodeAnalyzer();
+ try (Stream<Path> paths = Files.list(testDir)) {
+ paths.filter(this::isTestSource)
+ .filter(this::isAnalyzerSupported)
+ .forEach(path -> {
+ try {
+ CodeAnalyzer.ScanResult result =
analyzer.scan(path);
+ for (String module : result.modules()) {
+ deps.add(asCitrusDependency(module));
+ }
+ for (String dependency : result.dependencies()) {
+ deps.add(asScannedDependency(dependency));
+ }
+ } catch (IOException e) {
+ // ignore scan errors for missing catalog
+ }
+ });
+ } catch (IOException e) {
+ // ignore if test directory cannot be listed
+ }
+
+ return deps;
+ }
+
+ private String asScannedDependency(String dependency) {
+ String[] parts = dependency.split(":");
+ if (parts[0].equals("org.citrusframework")) {
+ return asCitrusDependency(parts[1]);
+ } else if (parts[0].startsWith("org.apache.camel")) {
+ if (parts.length > 2 && parts[1].startsWith("camel-test-infra-")) {
+ return asDependency(parts[0], parts[1], parts[2]);
+ }
+ return asDependency(parts[0], parts[1]);
+ } else {
+ return asDependency(dependency);
+ }
+ }
Review Comment:
Applied — added `parts.length < 2` guard that falls back to
`asDependency(dependency)` for malformed strings. Fixed in b542a96dd710.
_Claude Code on behalf of christophd_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]