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

Add support to update root gradle.properties #41

Merged
merged 1 commit into from
May 28, 2020

Conversation

asodja
Copy link
Contributor

@asodja asodja commented May 16, 2020

This fixes: #28.

Basic idea:

  • everyuseLatestVersions task writes variables to build/useLatestVersions/version-variables.json
  • we have one "aggregation" task internalRootAggregate that at the end reads all version-variables.json, merges them if possible (there is check that versions match) and writes to gradle.properties
  • at the end internalRootAggregate also deletes all version-variables.json files
  • all useLatestVersions tasks are finalized by internalRootAggregate task and internalRootAggregate task must run after all useLatestVersions tasks

By default this behavior is disabled, but can be enabled with --updateRootProperties or as:

useLatestVersions {
   updateRootProperties=true  
}

Note: when updateRootProperties=false, subprojects won't make version-variables.json file, but internalRootAggregate task will be run anyway, it just won't be able to read variables of subprojects.

I also included one small change, now variables that are defined multiple times in *.gradle file are also matched (change in Common.getVariablesFromMatches). Previously if you had two same version variables in *.gradle file it was not updated (also no problem was printed).

@patrikerdes
Copy link
Owner

Hi! Thank you very much for this PR!
The integration tests were not passing on the master branch, I have fixed that now. So if you could rebase on master and push your branch, travis-ci will run your branch and we can see that it is passing the tests.
(Travis builds of PRs: https://travis-ci.org/github/patrikerdes/gradle-use-latest-versions-plugin/pull_requests)

Also, I couldn't see any new tests being added in this PR. I would be really grateful if you could also add tests that verify that the new functionality is working.

@asodja
Copy link
Contributor Author

asodja commented May 23, 2020

Hej @patrikerdes,

sure, I can do that. Oh I see, I updated com.github.ben-manes.versions version in tests due to plugin test failure and this version does not support Gradle < 5.0, sorry for that.

Regarding tests, I can also write some. So probably I should add it to VariableUpdatesFunctionalTest right? Is there any helper code for multiproject tests?

@patrikerdes
Copy link
Owner

VariableUpdatesFunctionalTest sounds good to me.
I'm not aware of any such helper code, I think you will have to just create a number of different files in the correct folders. testProjectDir is the base directory where you can create files and folders using testProjectDir.newFolder or testProjectDir.newFile, you can find examples of those being used in other tests where more than one file is needed for the test.

@asodja
Copy link
Contributor Author

asodja commented May 23, 2020

Ok, I think I can see how I can handle tests. :)

I will rebase and also add tests, probably not today but in next few days.

Also thanks for a plugin! It comes really handy.

@asodja asodja force-pushed the master branch 2 times, most recently from a13cae6 to 10c87e9 Compare May 24, 2020 18:55
@asodja
Copy link
Contributor Author

asodja commented May 24, 2020

I added tests. I also had to do a workaround for some other tests since Versions plugin from 0.28 supports only Gradle >= 5.0. Mostly tests for useLatestVersionsCheck failed. Simple workaround was to run problematic tests with blacklisted Versions plugin. Maybe on a long run it would be better to just run tests with Gradle >= 5.0.

I also added a few lines in README.md how to apply plugin in case of Multi-projects build.

@patrikerdes
Copy link
Owner

I upgraded the gradle wrapper to 6.4.1 as part of fixing the broken tests, so the workaround you did for the failing tests should no longer be necessary. (I checked and you have that commit in your branch now after you rebased.)
Could you revert the change to use $CurrentVersions.SUPPORTED_VERSIONS_PLUGIN in tests, and go back to using $CurrentVersions.VERSIONS again?

@asodja
Copy link
Contributor Author

asodja commented May 26, 2020

My bad, added version change before rebase.

Anyway fixed now. Also diff is smaller and easier to review now.

@patrikerdes
Copy link
Owner

LGTM

@patrikerdes patrikerdes merged commit 4201c6f into patrikerdes:master May 28, 2020
@patrikerdes
Copy link
Owner

Now available in 0.2.14

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.

useLatestVersions isn't upgrading versions in properties file of a multi-project build as of release 0.2.9
2 participants