Skip to content

Migrate to ArtifactView API#1297

Merged
mikepenz merged 9 commits intodevelopfrom
feature/enhance_performance
Feb 1, 2026
Merged

Migrate to ArtifactView API#1297
mikepenz merged 9 commits intodevelopfrom
feature/enhance_performance

Conversation

@mikepenz
Copy link
Owner

@mikepenz mikepenz commented Jan 31, 2026

Summary

This PR optimizes the AboutLibraries Gradle plugin

Changes

Technical Fix

  • Replaced deprecated resolvedConfiguration.lenientConfiguration with modern ArtifactView API
  • Moved dependency resolution from configuration phase to execution phase
  • Used lazy artifact view with incoming.artifactView { config.lenient(true) }

Files Modified

  • plugin-build/plugin/src/main/kotlin/com/mikepenz/aboutlibraries/plugin/util/DependencyCollector.kt
  • plugin-build/plugin/src/main/kotlin/com/mikepenz/aboutlibraries/plugin/BaseAboutLibrariesTask.kt
  • plugin-build/plugin/build.gradle.kts (test dependencies)

Testing

  • Added comprehensive test suite: ConfigurationCacheTest, PerformanceTest, FunctionalTest
  • Verified configuration cache compatibility (no warnings)
  • Confirmed output correctness maintained
  • All existing functionality preserved

Baseline: commit 7157c76 (develop)
Optimized: commit 6186515 (this branch)

- Move dependency resolution from configuration to execution phase using providers
- Replace lenientConfiguration with ArtifactView API for lazy resolution
- Store configuration names during configuration, resolve during execution
- Add debug logging to track resolution timing
- Add test dependencies (JUnit 5, Gradle TestKit)
- Configure test task with JUnit Platform
- Add comprehensive unit tests for core functionality
Copilot AI review requested due to automatic review settings January 31, 2026 19:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes the AboutLibraries Gradle plugin by deferring dependency resolution from the configuration phase to the execution phase, achieving 46-51% faster configuration times. The changes replace deprecated lenientConfiguration API with modern ArtifactView API and use lazy providers for dependency resolution.

Changes:

  • Replaced lenientConfiguration with ArtifactView API for configuration-cache compatibility
  • Deferred dependency resolution using Gradle providers in task configuration
  • Added comprehensive test suite for configuration cache, performance, and functional correctness

Reviewed changes

Copilot reviewed 9 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
DependencyCollector.kt Switched from deprecated lenientConfiguration to ArtifactView API for lazy resolution
BaseAboutLibrariesTask.kt Deferred dependency collection using providers evaluated at execution time
ConfigurationCacheTest.kt Tests verifying configuration cache compatibility
ConfigurationTimeResolutionTest.kt Tests ensuring no resolution during configuration phase
FunctionalTest.kt Tests verifying functional behavior remains correct
PerformanceTest.kt Tests measuring configuration performance improvements
build.gradle.kts Added test dependencies for JUnit 5 and Gradle TestKit
.github/workflows/ci.yml Added test execution step to CI workflow
aboutlibraries.json (3 files) Updated sample output files from test runs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 15 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +52 to +55
// Should not see POM downloads during configuration
// The string "Download " indicates Gradle is downloading artifacts
val downloadCount = result.output.lines().count { it.contains("Download ") && it.contains("pom") }
assertEquals(0, downloadCount, "POM files should not be downloaded during configuration phase")
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test assertion on line 55 expects exactly 0 POM downloads, but this may be too strict. If Gradle has already cached the POMs from previous builds or other tests, the count will be 0. However, if the local cache is empty, Gradle might still download POMs even during the tasks command if it needs to resolve plugin classpaths or other metadata. Consider making this test more robust by either clearing the cache first or using a more lenient assertion that focuses on whether the AboutLibraries plugin itself triggers downloads, rather than all POM downloads in general.

Suggested change
// Should not see POM downloads during configuration
// The string "Download " indicates Gradle is downloading artifacts
val downloadCount = result.output.lines().count { it.contains("Download ") && it.contains("pom") }
assertEquals(0, downloadCount, "POM files should not be downloaded during configuration phase")
// Should not see POM downloads for the AboutLibraries plugin during configuration
// The string "Download " indicates Gradle is downloading artifacts
val downloadCount = result.output.lines()
.count { it.contains("Download ") && it.contains("pom") && it.contains("aboutlibraries", ignoreCase = true) }
assertEquals(0, downloadCount, "AboutLibraries POM files should not be downloaded during configuration phase")

Copilot uses AI. Check for mistakes.
Comment on lines +254 to +257
// Use ArtifactView API which is configuration-cache compatible and lazy
fun Configuration.artifactsViaView() = incoming.artifactView { config ->
config.lenient(true)
}.artifacts.map { it.file to it.id.componentIdentifier }
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call to artifactsViaView() on line 273 triggers artifact resolution immediately, which happens during the provider evaluation. While this is better than configuration-time resolution, the function name and comment suggest lazy resolution, but incoming.artifactView().artifacts is not completely lazy - it resolves when accessed.

The artifacts property returns a ArtifactCollection that resolves when iterated. This means the resolution still occurs, just at a different time (during task execution when the provider is evaluated, rather than during configuration). The improvement is real but the implementation could be clearer about when resolution actually happens.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

@mikepenz mikepenz changed the title perf: defer configuration resolution to execution phase Migrate to ArtifactView API Feb 1, 2026
@mikepenz mikepenz merged commit d005921 into develop Feb 1, 2026
4 checks passed
@mikepenz mikepenz deleted the feature/enhance_performance branch February 1, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants