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

set the jakartaPackages flag via a gradle property #1250

Open
wants to merge 1 commit into
base: blaub/jakartaPackagesTest-v2
Choose a base branch
from

Conversation

bjlaub
Copy link
Contributor

@bjlaub bjlaub commented Jul 11, 2023

Before this PR

This flag was previously set thusly in a build script:

conjure {
    java {
        jakartaPackages = true
    }
}

While that's still possible, it potentially causes problems when configuring subprojects due to evaluation order; the flag's value is not populated within the extension object until some time after the plugin application finishes, which results in incorrect dependencies getting added to some subprojects when they are set up in ConjurePlugin and similar plugin applications.

After this PR

==COMMIT_MSG==
Adding a gradle property conjure.java.jakartaPackages=true will cause the value to be set eagerly on the extension object such that it will always exist at the time the ConjurePlugin's application logic runs, and so should have the value set correctly at the time subproject dependencies are added.
==COMMIT_MSG==

Possible downsides?

It's an extra level of annoyance to have to set this e.g. via a gradle.properties file.

@bjlaub bjlaub requested a review from carterkozak July 11, 2023 19:49
@changelog-app
Copy link

changelog-app bot commented Jul 11, 2023

Generate changelog in changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Adding a gradle property conjure.java.jakartaPackages=true will cause the value to be set eagerly on the extension object such that it will always exist at the time the ConjurePlugin's application logic runs, and so should have the value set correctly at the time subproject dependencies are added.

Check the box to generate changelog(s)

  • Generate changelog entry

@bjlaub bjlaub changed the base branch from develop to blaub/jakartaPackagesTest-v2 July 11, 2023 19:49
@bjlaub bjlaub changed the title Blaub/jakarta packages flag via gradle property set the jakartaPackages flag via a gradle property Jul 11, 2023
If the gradle property `conjure.java.jakartaPackages` is set to `true`,
then the corresponding flag will be set within the `java` options
container in `ConjureExtension` at the time the extension object is
created. This ensures that we can eagerly read the property value and
configure the extension early in the gradle lifecycle, before any
subprojects are configured, and the value will propagate correctly.

This change removes previously-added `afterEvaluate` calls in some
places.
@bjlaub bjlaub force-pushed the blaub/jakartaPackages-flag-via-gradle-property branch from 6a53321 to 3d5a6d9 Compare July 11, 2023 19:52
@@ -31,12 +32,16 @@ public class ConjureExtension {
private final GeneratorOptions pythonOptions = new GeneratorOptions();
private final Map<String, GeneratorOptions> genericOptions = new HashMap<>();

public ConjureExtension() {
public ConjureExtension(Project project) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we could potentially change this to be String jakartaPackagesProperty and just make the caller use project.findProperty - i'm not really sure which is preferred.

'''.stripIndent()
createFile('gradle.properties') << """
conjure.java.jakartaPackages=true
""".stripIndent()
Copy link
Contributor

Choose a reason for hiding this comment

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

might as well test both

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants