Skip to content
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

Upgrade AGP to 7.3.0, Gradle to 7.6 #1075

Merged
merged 11 commits into from
Feb 1, 2023

Conversation

scana
Copy link
Contributor

@scana scana commented Jan 24, 2023

Fixes #1068

  • Update Gradle to 7.6
  • Update AGP to 7.3.0

There is one test failing - GenerateResourcesIntegrationTest#'play' file name is not allowed.
The thing is that it used to pass due to empty catalogues being passed into GenerateResources task - with the upgrade it's not valid anymore - only actual files are provided.

Parameters before:

/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/default-language.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/de-DE
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/de-DE/full-description.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/en-US
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/en-US/full-description.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/en-US/graphics
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/en-US/graphics/phone-screenshots
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/en-US/graphics/phone-screenshots/foo.jpg
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/en-US/graphics/tablet-screenshots
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/en-US/graphics/tablet-screenshots/baz.jpg
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/en-US/short-description.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/en-US/title.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/fr-FR
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/fr-FR/full-description.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/fr-FR/graphics
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/fr-FR/graphics/phone-screenshots
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/fr-FR/graphics/phone-screenshots/bar.jpg
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/fr-FR/short-description.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/listings/fr-FR/title.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/products
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/products/sku.json
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/release-notes
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/release-notes/en-US
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/release-notes/en-US/default.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/release-notes/fr-FR
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/main/play/release-notes/fr-FR/default.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/illegalPlay/play
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/illegalPlay/play/listings
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/illegalPlay/play/listings/en-US
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit9788581965445626013/app/src/illegalPlay/play/listings/en-US/play

Parameters after:

/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit14987822343578711797/app/src/main/play/default-language.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit14987822343578711797/app/src/main/play/listings/de-DE/full-description.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit14987822343578711797/app/src/main/play/listings/en-US/full-description.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit14987822343578711797/app/src/main/play/listings/en-US/graphics/phone-screenshots/foo.jpg
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit14987822343578711797/app/src/main/play/listings/en-US/graphics/tablet-screenshots/baz.jpg
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit14987822343578711797/app/src/main/play/listings/en-US/short-description.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit14987822343578711797/app/src/main/play/listings/en-US/title.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit14987822343578711797/app/src/main/play/listings/fr-FR/full-description.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit14987822343578711797/app/src/main/play/listings/fr-FR/graphics/phone-screenshots/bar.jpg
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit14987822343578711797/app/src/main/play/listings/fr-FR/short-description.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit14987822343578711797/app/src/main/play/listings/fr-FR/title.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit14987822343578711797/app/src/main/play/products/sku.json
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit14987822343578711797/app/src/main/play/release-notes/en-US/default.txt
/private/var/folders/51/vwgxq3gx39g1g4nk2z7wn9c00000gp/T/junit14987822343578711797/app/src/main/play/release-notes/fr-FR/default.txt

@SUPERCILEX I am aware that you do not maintain this project anymore, however could you please tell if the idea behind this test was to verify if no flavor containing the word "play" exists in the project? If so, I'd rather rewrite this check to work differently.

@scana scana requested a review from SUPERCILEX as a code owner January 24, 2023 17:34
@@ -380,6 +381,7 @@ class GenerateResourcesIntegrationTest : IntegrationTestBase(), SharedIntegratio
}

@Test
@Ignore("Previously this test worked because empty catalogs were generated and passed into the task")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be verified if this test/implementation for it should be rewritten

Copy link
Collaborator

Choose a reason for hiding this comment

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

The check for this is here:

val isPlayKeywordReserved = name != PLAY_PATH || parameters.inputDirs.get().any {
it.asFile == this
}
check(isPlayKeywordReserved) {
"The file name 'play' is illegal: $this"
}

This test absolutely has to pass because we rely on it for correctness. The way we pick which resource to use for a particular flavor is dependent on the parent of the play directory being a valid flavor name:

val flavor = checkNotNull(f.climbUpTo(PLAY_PATH)?.parentFile?.name) {

Anyway, off the top of my head I think you can fix name != PLAY_PATH by combining two climbUpTos and if both of them are non-null then you have two play directories. There might be a cleaner way though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SUPERCILEX could you please elaborate more on what this test is supposed to verify? 🙏

Looking at those two it seems like those test are identical except for different flavor name - it says "play file name is not allowed", but I can't grasp my head around it - it sounds like only "play" flavor is allowed and others are not (which is unexpected I guess)?

    @Test
    fun `Flavor named 'play' is allowed`() {
        // language=gradle
        val config = """
            flavorDimensions 'pricing'
            productFlavors {
                play { dimension 'pricing' }
            }
        """.withAndroidBlock()

        val result = execute(config, "generatePlayReleasePlayResources")

        result.requireTask(taskName("PlayRelease"), outcome = SUCCESS)
    }

    @Test
    @Ignore("Previously this test worked because empty catalogs were generated and passed into the task")
    fun `'play' file name is not allowed`() {
        // language=gradle
        val config = """
            flavorDimensions 'pricing'
            productFlavors {
                illegalPlay { dimension 'pricing' }
            }
        """.withAndroidBlock()

        val result = executeExpectingFailure(
                config, "generateIllegalPlayReleasePlayResources")

        result.requireTask(taskName("IllegalPlayRelease"), outcome = FAILED)
    }

Please read my PR's description on how now parameters provided to

abstract class Validator : WorkAction<Validator.Params> {
        override fun execute() {
            for (file in parameters.files.get()) {
                file.validate()
            }
        }

have changed with the recent version.

I'm happy to improve it but would really appreciate your explanation in here 😄

Copy link
Collaborator

Choose a reason for hiding this comment

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

Shoot, forgot about that, makes life more complicated. For understanding the tests, it's easiest to look at the fixtures: https://github.com/Triple-T/gradle-play-publisher/tree/master/play/plugin/src/test/fixtures/GenerateResourcesIntegrationTest/src. Every directory in there is a flavor, so you'll find the play and illegalPlay dirs in there.

I've looked at this some more and I think we might be able to fix this by replacing it.asFile == this with it.asFile == climbUpTo(PLAY_PATH). That check is looking for file names that are play, but not part of the root input dirs. So if we look through every input file and find its parent play dir, it should always be a root play dir (I think).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SUPERCILEX please take a look at dbcd5a2.

My confusion came from this test's name being a little bit misleading I think.

From what I understand now is that those two cases are illegal:

  • One is not allowed to have any files named "play"
    project/my-project/src/flavorName/play/**/play.txt

  • One is not allowed to have any child directories named play - only root directory can have "play" name:
    project/my-project/src/flavorName/play/**/play/*.*

Even if the flavor is named play, this would be the root directory: src/play/play - my changes made it look only at the child directories of the subdirectory.
So src/play/play/default-listing.txt is ok, src/play/play/**/play/file.txt is not.

I tested this change with both old Gradle version and new one and in both cases it now passes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

One is not allowed to have any files named "play"
project/my-project/src/flavorName/play/**/play.txt

Yes to the sentence, no to the example. /play.txt should be fine, /play isn't. On that note, can you add two test cases for this: one allowing play.foo and one disallowing plain play files? Then check that the tests pass pre-PR and we'll be in the clear for behavior changes.


I like the simplicity of your approach, but I'm a little bothered by the performance implications. Previously, we only did validation on changed files (since the input files are incremental). Now, we always run a full directory expansion. I think just because of that'd I'd still prefer the "climb up every file's path and see if its root play dir is contained in the input dir set" approach.

Copy link
Contributor Author

@scana scana Jan 26, 2023

Choose a reason for hiding this comment

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

Thank you - I was so focused on 'file' that I forgot that you could actually have a file play without an extension.

Got actually a little bit misled because GenerateResourcesIntegrationTest fixture does not contain a file named play but only a directory named play (listings/en-US/play/.keep).
This is the reason why the test would start to fail, as there was no file play in the input anymore with newer Gradle version (previously there was a a list of files and also directories, which were then treated asFile). .keep got ignored.

src/main/play/default-language.txt
src/main/play/listings/de-DE/full-description.txt
src/main/play/listings/en-US/full-description.txt
src/main/play/listings/en-US/graphics/phone-screenshots/foo.jpg
src/main/play/listings/en-US/graphics/tablet-screenshots/baz.jpg
src/main/play/listings/en-US/short-description.txt
src/main/play/listings/en-US/title.txt
src/main/play/listings/fr-FR/full-description.txt
src/main/play/listings/fr-FR/graphics/phone-screenshots/bar.jpg
src/main/play/listings/fr-FR/short-description.txt
src/main/play/listings/fr-FR/title.txt
src/main/play/products/sku.json
src/main/play/release-notes/en-US/default.txt
src/main/play/release-notes/fr-FR/default.txt

One is not allowed to have any child directories named play - only root directory can have "play" name:

Is this also valid?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this also valid?

Sorry, which part? Or do you mean in general? If so, then yeah your understanding is correct.

gradle/wrapper/gradle-wrapper.properties Show resolved Hide resolved
settings.gradle.kts Show resolved Hide resolved
@@ -380,6 +381,7 @@ class GenerateResourcesIntegrationTest : IntegrationTestBase(), SharedIntegratio
}

@Test
@Ignore("Previously this test worked because empty catalogs were generated and passed into the task")
Copy link
Collaborator

Choose a reason for hiding this comment

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

The check for this is here:

val isPlayKeywordReserved = name != PLAY_PATH || parameters.inputDirs.get().any {
it.asFile == this
}
check(isPlayKeywordReserved) {
"The file name 'play' is illegal: $this"
}

This test absolutely has to pass because we rely on it for correctness. The way we pick which resource to use for a particular flavor is dependent on the parent of the play directory being a valid flavor name:

val flavor = checkNotNull(f.climbUpTo(PLAY_PATH)?.parentFile?.name) {

Anyway, off the top of my head I think you can fix name != PLAY_PATH by combining two climbUpTos and if both of them are non-null then you have two play directories. There might be a cleaner way though.

@SUPERCILEX SUPERCILEX merged commit ccb8bde into Triple-T:master Feb 1, 2023
@scana scana deleted the maintenance/upgrade-agp-and-gradle branch February 1, 2023 16:37
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.

Update Android Gradle Plugin to 7.30
2 participants