Conversation
Signed-off-by: Juan Manuel Leflet Estrada <jleflete@redhat.com>
WalkthroughAdds a new Gradle script (build-v9.gradle) and wires it into the Docker image. Both the existing build.gradle and the new script implement a konveyorDownloadSources task that aggregates source artifacts across projects/configurations and copies them into a single build directory. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant Gradle as Gradle
participant Proj as All Projects
participant Cfg as Target Configs (compileClasspath/runtimeClasspath/implementation/api)
participant Repo as Repositories
participant Task as konveyorDownloadSources
Dev->>Gradle: run konveyorDownloadSources
Gradle->>Proj: iterate projects
Proj->>Cfg: collect resolvable configurations
loop For each module (group:name:version)
Cfg->>Gradle: create detached config (classifier=sources)
Gradle->>Repo: resolve sources (lenient, non-transitive)
Repo-->>Gradle: source jars/files (if available)
Gradle->>Task: add resolved files to aggregate list
end
alt any sources found
Task->>Task: copy to build/download(/downloaded-sources)
else none found
Task->>Task: log no sources available
end
sequenceDiagram
%% Variant: build-v9.gradle emphasizes config-time aggregation
participant Gradle as Gradle (Config Time)
participant Proj as All Projects
participant Repo as Repositories
participant Store as allProjectSourceFiles
participant Task as konveyorDownloadSources
Gradle->>Proj: scan target configs
Proj->>Repo: resolve module sources via detached configs
Repo-->>Store: append resolved source files (lenient)
Note over Store,Task: At execution time
Task->>Store: read aggregated files
Task->>Task: copy to build/downloaded-sources
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (6)
gradle/build-v9.gradle (4)
21-41: Avoid re-resolving identical modules across multiple configurations (reduce duplicate work).The same module can be present in multiple target configs (compileClasspath, runtimeClasspath, etc.). You dedupe within a config via unique(), but you still re-resolve across configs/projects. Maintain a global Set of seen module coordinates to prevent redundant detachedConfiguration resolutions.
Apply these diffs to introduce de-duplication:
@@ -// Collect all source files at configuration time -def allProjectSourceFiles = [] +// Collect all source files at configuration time +def allProjectSourceFiles = [] +// Track seen modules across all projects/configurations (group:name:version) +def seenModules = new LinkedHashSet<String>() @@ - // Extract module identifiers for source resolution + // Extract module identifiers for source resolution def moduleIds = artifactResults.collect { artifactResult -> def componentId = artifactResult.id.componentIdentifier if (componentId instanceof ModuleComponentIdentifier) { - return [ - group: componentId.group, - name: componentId.module, - version: componentId.version - ] + return [ + group: componentId.group, + name: componentId.module, + version: componentId.version + ] } return null }.findAll { it != null }.unique() @@ - if (!moduleIds.isEmpty()) { + if (!moduleIds.isEmpty()) { // Create source dependencies - def sourceDependencies = moduleIds.collect { moduleId -> - proj.dependencies.create( - "${moduleId.group}:${moduleId.name}:${moduleId.version}:sources" - ) - } + def sourceDependencies = moduleIds.collectMany { moduleId -> + def coord = "${moduleId.group}:${moduleId.name}:${moduleId.version}" + if (!seenModules.add(coord)) { + return [] // already processed elsewhere + } + return [proj.dependencies.create("${coord}:sources")] + }
79-100: Make the task configuration-cache and up-to-date friendly (use task registration and proper inputs/outputs).Currently, resolution and aggregation happen at configuration time, and the task captures a mutable list without declared inputs/outputs. Prefer tasks.register with typed task (Copy) and wire a Provider as input, with outputs to layout.buildDirectory. This improves configuration cache compatibility and up-to-date checks.
Consider refactoring the task as:
-task konveyorDownloadSources { - // Store the collected files as task input - def sourceFiles = allProjectSourceFiles - - doLast { - // Copy all found source files - if (!sourceFiles.isEmpty()) { - def downloadDir = new File(project.layout.buildDirectory.get().asFile, "downloaded-sources") - downloadDir.mkdirs() - - copy { - from sourceFiles - into downloadDir - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - } - - println "Downloaded ${sourceFiles.size()} source files to ${downloadDir}" - } else { - println "No source files found to download" - } - } -} +def collectedSources = project.layout.files({ allProjectSourceFiles }) +tasks.register('konveyorDownloadSources', Copy) { + from(collectedSources) + into(project.layout.buildDirectory.dir("downloaded-sources")) + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + // Optional: declare inputs/outputs explicitly for older Gradle + inputs.files(collectedSources) + outputs.dir(project.layout.buildDirectory.dir("downloaded-sources")) + doFirst { + if (collectedSources.asFileTree.isEmpty()) { + logger.lifecycle("No source files found to download") + // Copy does nothing when from is empty; keep behavior consistent. + } else { + logger.lifecycle("Downloading ${collectedSources.asFileTree.files.size()} source files ...") + } + } + doLast { + if (!collectedSources.asFileTree.isEmpty()) { + logger.lifecycle("Downloaded ${collectedSources.asFileTree.files.size()} source files to ${destinationDir ?: 'build/downloaded-sources'}") + } + } +}Note: This keeps collection at configuration time as you intended, but makes the copying task cacheable and incremental. If desired, the resolution itself can also be moved behind Providers to execute later.
64-70: Prefer Gradle logger over println for better build UX and CC safety.Switch to logger.lifecycle/info/warn across the script. This produces consistent structured output and plays nicer with tooling.
Example:
-println "Found ${sourceFiles.size()} source files for ${proj.name}:${configName}" +logger.lifecycle("Found ${sourceFiles.size()} source files for ${proj.name}:${configName}")Apply similarly to other println statements.
86-96: Output directory name differs from Gradle 4–8 script (may confuse downstream tooling).This script writes to build/downloaded-sources, while gradle/build.gradle writes to build/download. If any consumer expects a consistent path, this divergence can break flows.
Do we want both scripts to agree on the same target directory? If yes, align one to the other. For example, to match this script from the 4–8 script:
- def downloadDir = new File(buildDir, "download") + def downloadDir = new File(buildDir, "downloaded-sources")Or change this v9 script to “download” to match legacy behavior. Please confirm the expected path for downstream steps.
gradle/build.gradle (2)
71-76: Align output directory name with the v9 script (avoid divergent paths).This script writes to build/download, while gradle/build-v9.gradle writes to build/downloaded-sources. For consistency and simpler downstream handling, use the same name in both.
Apply this diff if you prefer the v9 naming:
- def downloadDir = new File(buildDir, "download") + def downloadDir = new File(buildDir, "downloaded-sources")Alternatively, change the v9 file to “download” and keep this as-is. Please confirm the expected path.
74-78: Use enum for duplicatesStrategy for parity with v9 and static typing.Small consistency/readability improvement.
- duplicatesStrategy = "exclude" + duplicatesStrategy = DuplicatesStrategy.EXCLUDENote: org.gradle.api.file.DuplicatesStrategy is implicitly imported in Gradle scripts.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
Dockerfile(1 hunks)gradle/build-v9.gradle(1 hunks)gradle/build.gradle(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: e2e / e2e-api-integration-tests
- GitHub Check: e2e / e2e-ui-integration-tests
🔇 Additional comments (3)
Dockerfile (1)
42-42: Ensure the correct Gradle init-script is selected at runtimeYou’re now copying both
•/usr/local/etc/task.gradle
•/usr/local/etc/task-v9.gradleinto the image, but there’s no code in this repo that ever references or chooses between them. Without version‐detection logic in your launcher (e.g.
jdtls.pyor another wrapper), projects running on Gradle 8.14+ will still pick up the oldtask.gradlescript.Please verify (or implement) in your startup wrapper that you:
• Detect the Gradle version (for example, by parsing
gradle --version)
• Conditionally invoke/usr/local/etc/task-v9.gradlewhen the version is ≥ 8.14, falling back to/usr/local/etc/task.gradleotherwiseThis will ensure the new build-v9 script is actually used for newer Gradle versions.
gradle/build.gradle (2)
27-35: Heads-up: resolvedConfiguration API is deprecated in Gradle 8 and removed in 9.This script is explicitly for Gradle 4–8, so usage is acceptable. Just ensure callers won’t apply this script on Gradle 9+, since it will fail there. The new v9 script covers 8.14+.
Confirm the runtime selects this script only for Gradle < 8.14 and uses build-v9.gradle for >= 8.14. If desired, I can provide a version-detection snippet to choose the correct script at runtime.
9-20: Nice narrowing to resolvable configurations.Filtering with canBeResolved avoids accidental resolution of configurations like implementation/api when not resolvable. Good defensive practice across multi-plugin projects.
| def moduleIds = artifactResults.collect { artifactResult -> | ||
| def componentId = artifactResult.id.componentIdentifier | ||
| if (componentId instanceof ModuleComponentIdentifier) { | ||
| return [ | ||
| group: componentId.group, | ||
| name: componentId.module, | ||
| version: componentId.version |
There was a problem hiding this comment.
Fix missing import for ModuleComponentIdentifier (will fail at configuration time).
Gradle scripts don’t implicitly import org.gradle.api.artifacts.component.*. Referencing ModuleComponentIdentifier without an import will trigger “unable to resolve class ModuleComponentIdentifier” during configuration.
Apply this diff to add the import:
@@
/**
* Configuration cache compatible sources download task - compatible with Gradle 8.14+
* All project iteration happens at configuration time
*/
+import org.gradle.api.artifacts.component.ModuleComponentIdentifier
+
// Collect all source files at configuration time
def allProjectSourceFiles = []🤖 Prompt for AI Agents
In gradle/build-v9.gradle around lines 30 to 36, the script references
ModuleComponentIdentifier but lacks the required import which causes a
configuration-time "unable to resolve class ModuleComponentIdentifier" error;
add the import statement for
org.gradle.api.artifacts.component.ModuleComponentIdentifier near the top of the
file (with other imports) so the ModuleComponentIdentifier type resolves, then
re-run configuration to verify the error is gone.
https://issues.redhat.com/browse/MTA-5907 Requires: - konveyor/java-analyzer-bundle#142 Fixes: - #878 Bundle PR: 142 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Gradle 9 support when resolving source JARs. - Automatic detection of the Gradle wrapper and Gradle version. - Automatic JAVA_HOME selection based on detected Gradle version and per-run resolution. - Bug Fixes - Exclude Gradle “constraint” entries from dependency results. - More robust Gradle dependency parsing and version extraction. - Context-aware Gradle execution with per-invocation environment and clearer errors when Java home or wrapper are unavailable. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Juan Manuel Leflet Estrada <jleflete@redhat.com>
https://issues.redhat.com/browse/MTA-5907
Summary by CodeRabbit