Skip to content

Add an ImagesLifecycleTask to pass options along to source set tasks - #75

Merged
theisenp merged 1 commit into
mainfrom
aggregate-task
Aug 12, 2026
Merged

Add an ImagesLifecycleTask to pass options along to source set tasks#75
theisenp merged 1 commit into
mainfrom
aggregate-task

Conversation

@theisenp

@theisenp theisenp commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Context

Right now you can't filter any of the Microfilm tasks. So if you want to compress/verify a specific image, you have to compress/verify the whole module. I think it would be helpful to be able to run tasks on a subset of images, similar to how you can filter tests with the --tests option.

This PR

The new --image option is attached to the source set specific tasks, so this works:

./gradlew compressMicrofilmMain --images="**/my_image.png"

But if you try to pass a filter to the parent task it fails:

./gradlew compressMicrofilm --images="**/my_image.png"

I think this is relatively common for Gradle tasks, but it doesn't feel like a great user experience. I'm proposing that we add an ImagesLifecycleTask that does nothing except pass these options along to the source set tasks. I'm not that familiar with Gradle task options, so if there's a good reason not to do this, let me know!

@theisenp
theisenp marked this pull request as ready for review August 9, 2026 20:43
@eric-labelle

Copy link
Copy Markdown
Collaborator

I'm not that familiar with Gradle task options, so if there's a good reason not to do this, let me know!

also not really familiar with this.
@joshfriend probably has an opinion here :)

@theisenp
theisenp requested a review from joshfriend August 10, 2026 18:17
Base automatically changed from verify-images-option to main August 10, 2026 20:29
@theisenp
theisenp changed the base branch from main to decompress-images-option August 10, 2026 22:48

@eric-labelle eric-labelle left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

approving to unblock the stack, we can revise after if Josh has suggestions/concerns.

@theisenp

Copy link
Copy Markdown
Collaborator Author

I see that Tony Robalik actually published a blog post yesterday that addresses something similar! It's implemented somewhat differently because, it modifies the existing test task to add this support instead of modifying a custom task owned by a plugin, but conceptually it's similar.

The other takeaway is that "Aggregate" is probably not the right term here (not surprising, I don't know the terminology so I made something up). Tony describes these as "lifecycle" tasks, so I think it makes sense to call this something like ImagesLifecycleTask instead of AggregateTask.

@theisenp
theisenp force-pushed the aggregate-task branch 2 times, most recently from c2ea8bf to e045497 Compare August 11, 2026 19:08
@theisenp theisenp changed the title Add an AggregateTask to pass options along to source set tasks Add an LifecycleImagesTask to pass options along to source set tasks Aug 11, 2026
@theisenp theisenp changed the title Add an LifecycleImagesTask to pass options along to source set tasks Add an ImagesLifecycleTask to pass options along to source set tasks Aug 11, 2026
Base automatically changed from decompress-images-option to main August 11, 2026 19:31

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

One thing that we could also do to take this a step further is have CompressTask, DecompressTask, and VerifyTask all extend this base class instead of DefaultTask, so they're all guaranteed to share the same --images option.

Or instead of extending ImagesLifecycleTask directly, we could make something like a HasImagesOption interface that the lifecycle and source set tasks all implement.

@theisenp
theisenp merged commit a13ff69 into main Aug 12, 2026
8 checks passed
@theisenp
theisenp deleted the aggregate-task branch August 12, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants