-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional snapshot root directory gradle property #517
base: master
Are you sure you want to change the base?
Optional snapshot root directory gradle property #517
Conversation
paparazzi-gradle-plugin/src/main/java/app/cash/paparazzi/gradle/PaparazziPlugin.kt
Outdated
Show resolved
Hide resolved
8d6c2b9
to
8a8d5ae
Compare
val snapshotOutputDir = | ||
extension.snapshotRootDirectory.orNull | ||
?: project.layout.projectDirectory.dir("src/test/snapshots").asFile | ||
snapshotOutputDir.mkdirs() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like in PrepareResourcesTask to add this as an InputDirectory
the directory has to exist, so in that case I have to add this to create the snapshot directory here instead of waiting until the task to take/verify the snapshots. Thoughts on if this is fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you went from a Provider to a Provider that's resolved in configuration phase. This is happening too early here I think. I think this would be something like:
val snapshotOutputDir = extension.snapshotRootDirectory.orElse(project.layout.projectDirectory.dir("src/test/snapshots"))
and maybe that solves your need to create the dir too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it might be even better if the default was set up with snapshotRootDirectory.convention
when the extension is registered:
val extension = project.extensions.create("paparazzi", PaparazziPluginExtension::class.java)
extension.snapshotRootDirectory.convention(project.layout.projectDirectory.dir("src/test/snapshots"))
e099fe2
to
b4877c8
Compare
b4877c8
to
8452de1
Compare
8452de1
to
ecee598
Compare
Is there any blocker for this PR? |
import java.io.File | ||
|
||
interface PaparazziPluginExtension { | ||
val snapshotRootDirectory: Property<File?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try to use DirectoryProperty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Sqldelight I moved to ConfigurableFileCollection
as a recommendation from @hfhbd to emulate how srcDirs
works on Java and Kotlin Gradle plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is a single output directory, srcDirs
are multiple inputs, feels very different.
@brenpearson do you still have interest in this? I can fork your implementation if you lack of time to continue working on this. |
@JavierSegoviaCordoba I'm not going to be able to update this within the next couple of weeks. If you have time then by all means, otherwise I'll come back and take a look in probably 2 weeks time 🙏 |
Can I push on this branch or should I create a new PR? @brenpearson commits are preserved in both cases. EDIT: As there are conflicts, I am going to create a different PR and I will share the link here. |
Updated PR with @TWiStErRob suggestion: #736 |
Allows the consumer of the Paparazzi library to specify where they want the snapshots to be saved. This includes creating a gradle plugin extension for Paparazzi with this property in it, we can add other configurable properties to this extension in future.
This can be set as shown in the consumer's gradle file