-
Notifications
You must be signed in to change notification settings - Fork 513
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
Give VerifyMigration task its own output directory #1380 #1399
Conversation
@@ -36,7 +36,7 @@ open class VerifyMigrationTask : SourceTask() { | |||
@TaskAction | |||
fun verifyMigrations() { | |||
// Clear existing build directory. | |||
File("${project.buildDir}/sqldelight").deleteRecursively() | |||
File("${project.buildDir}/sqldelight-verifyMigration").deleteRecursively() |
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.
I'm not sure this is enough. The Android and/or Kotlin multiplatform support likely means there are multiple of these tasks per module.
We probably need to move responsibility of creating this directory to the person who is setting up this task.
Additionally, I would prefer if we put everything under the 'sqldelight' folder instead of having multiple.
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.
Good point. I'd be happy to try and change the plugin to use directories something like this:
- generateInterface tasks:
build/sqldelight/generated/{variant}
- verifyMigration tasks:
build/sqldelight/verifymigration/{variant}
Are there any compatibility concerns with changing the current build/sqldelight
output directory?
Also, feel free to suggest better names. I haven't done much with Gradle, so don't know the preferred conventions.
Note that variants aren't really working too well generally anyway, because the generateInterface tasks all delete and write to build/sqldelight
and clobber each other. So for example in an Android project generateDebugDatabaseInterface and generateReleaseInterface will race with each other.
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.
No concerns changing directory structure. No one should be relying on it, and if they are we need to expose API for it, not just having it be relied on implicitly. Your names seem fine, though.
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.
i think we can pretty safely make the change to have the current generate tasks output to build/sqldelight/generated
and then have verification tasks output to build/sqldelight/verifyMigration
we currently dont do output to any variant specific folders. It's not the most lovely setup if you peak under the hood but it works, I don't think we need to change that in this PR but can investigate further later.
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.
We also need to have the database name in the path.
I think we want to do something like build/generated/sqldelight/REASON/DATABASE_NAME/VARIANT/
where REASON
is "code" or "migration_verification", DATABASE_NAME
is the DB name (obviously), and VARIANT
is the android and/or kotlin MPP variant.
I haven't had time to work on this, but I'll outline my thought process and where I'm blocked. Two gradle tasks ( The tricky part is getting the plugin to correctly set up these tasks. I'm a bit uncertain about "variants" and how these work. I see there is some code in |
Working towards supporting parallel task execution cashapp#1380
So it is not shared with tasks that generate code. For supporting parallel task execution cashapp#1380
bd86054
to
e9256fd
Compare
I've force pushed new commits for the directory changes, basically as discussed but without any variant handling. Generated source code is now written to a subdirectory in VerifyMigrationsTask creates a subdirectory in This avoids the races for deleting the directories in #1380. |
dope - thanks |
Currently the Gradle task that generates the source code and the VerifyMigration task both share the
build/sqldelight
directory. One of the first things that the VerifyMigration task does is to delete this directory. If a generate interfaces task has run, then that deleted directory contained the generated source code needed to compile the project!This change avoids clobbering the generated source code generated by changing the VerifyMigration task to use a directory named
build/sqldelight-verifyMigration
instead.It was certainly unexpected for me to discover that a check task deletes source code generated by an earlier task, so I don't think this was by design. Changing them to use separate directories fixes the racy behavior where the build will succeed or fail determined by the relative ordering of VerifyMigration and compile tasks. See #1380 for an example of this.