Skip to content

Conversation

ZacSweers
Copy link

Not sure if this is maintained, but this at least updates the gradle version and fixes the project version injection

@google-cla google-cla bot added the cla: yes label Nov 16, 2020
it.inputs.property("gsonversion", version)
it.from(layout.projectDirectory.dir("src/main/java-gradle-templates/com/google/gson/internal"))
it.into(project.layout.buildDirectory.dir("generated/sources/version-templates/java/main/com/google/gson/internal"))
it.expand(["gsonversion": version])
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to change this to:

Suggested change
it.expand(["gsonversion": version])
it.expand(["{project.version}": version])

and then re-use the existing Maven template class? This is a little bit hacky, but might be less error-prone than having two separate source files for this.

Alternatively could you please modify https://github.com/google/gson/blob/master/gson/src/test/java/com/google/gson/internal/GsonBuildConfigTest.java to verify that the version is not $gsonversion either (or in general does not start with $; that would probably be most reliable)?


Note that I am not a member of this project.

Copy link
Author

Choose a reason for hiding this comment

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

No templates in gradle copies have a different template mechanism. I tried some basic escaping of the dot but without much luck

Copy link
Contributor

@Marcono1234 Marcono1234 Nov 18, 2020

Choose a reason for hiding this comment

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

Do you think it would make sense to use Copy.filter(Closure) instead? And then manually replace ${project.version} in the lines?

And regardless of whether you decide to do this, could you please adjust the GsonBuildConfigTest.java to check for a leading $ (instead of "${project.version}"), maybe also with a comment to explain the rationale, so the test becomes more robust?

@ZacSweers ZacSweers closed this Jun 20, 2021
@ZacSweers ZacSweers deleted the z/gradleWorks branch June 20, 2021 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants