Skip to content

Conversation

asodja
Copy link
Member

@asodja asodja commented Apr 4, 2023

Cherry picks property upgrades instrumentation from #24005.

It adds an option to use:

@UpgradedProperty

in our code, that can be upgraded to a Property<T>.

Currently it supports creating automatic interceptors, that means, that you can use:

@UpgradedProperty
abstract Property<String> getProperty()

and it will automatically generate interceptors for

String getProperty();
void setProperty(String value);

Optionally, you can also set originalType, that can be useful especially for primitive types:

@UpgradedProperty(originalType = int.class)
abstract Property<Integer> getProperty()

will generate interceptors for:

int getProperty();
void setProperty(int value);

Is base for: #24710.

@asodja asodja requested a review from a team April 4, 2023 12:42
@asodja asodja self-assigned this Apr 4, 2023
@asodja asodja force-pushed the asodja/property-upgrades-cherry branch 5 times, most recently from bf8f6cb to 94a9df3 Compare April 6, 2023 09:41
@asodja asodja force-pushed the asodja/property-upgrades-cherry branch 6 times, most recently from 5bbb2a6 to fc297cb Compare April 11, 2023 09:59
@h0tk3y
Copy link
Member

h0tk3y commented Apr 12, 2023

I have reviewed the current set of changes. My only concern is non-deterministic ordering in the processor. FYI, some tests for ordering have been added in e716082, but those might not be enough. Other than that, LGTM!

@asodja asodja force-pushed the asodja/property-upgrades-cherry branch from f442a95 to 21dab8b Compare April 18, 2023 11:28
@asodja asodja requested review from h0tk3y and lptr April 18, 2023 12:45
Class<?> generatedClass = Class.forName(className);
Method callInterceptorsGetter = generatedClass.getDeclaredMethod("getCallInterceptors");
// Generated classes are not public and in the org.gradle.internal.classpath.generated package
callInterceptorsGetter.setAccessible(true);
Copy link
Member

Choose a reason for hiding this comment

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

Would making the generated classes public turn out cleaner? Also, I would like to reference them from tests at some point.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that will make it cleaner. So I can just make them public. And if we need to forbid package access in the future, we can move that method to some org.gradle.internal.classpath.generated.InterceptorFactory class

Copy link
Member Author

Choose a reason for hiding this comment

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

Classes are now public

Copy link
Member

@h0tk3y h0tk3y left a comment

Choose a reason for hiding this comment

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

👍 I don't think any changes are strictly necessary, but please take a look at the suggestions.


tasks.named<JavaCompile>("compileJava") {
// Without this, javac will complain about unclaimed annotations
options.compilerArgs.add("-Xlint:-processing")
Copy link
Member

Choose a reason for hiding this comment

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

❔ Which annotations does it complain about and why?

Copy link
Member Author

Choose a reason for hiding this comment

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

Annotation

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like the org.gradle.api.NonNullApi. You get this kind of warning, that breaks the build since we have -Werror:

warning: No processor claimed any of these annotations: org.gradle.api.NonNullApi
error: warnings found and -Werror specified
1 error
1 warning

I guess we would need to try fix that at one point

Copy link
Member Author

Choose a reason for hiding this comment

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

Added annotation info to the comment

Copy link
Member

Choose a reason for hiding this comment

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

If @alllex changed the default for non-nullable APIs, we could lose the annotation from our packages, and then this problem would go away.

@gradle gradle deleted a comment from asodja Apr 20, 2023
Copy link
Member

@lptr lptr left a comment

Choose a reason for hiding this comment

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

LGTM.

@gradle gradle deleted a comment from asodja Apr 21, 2023
@asodja
Copy link
Member Author

asodja commented Apr 25, 2023

@bot-gradle test this

@gradle gradle deleted a comment from asodja Apr 25, 2023
@bot-gradle
Copy link
Collaborator

I've triggered the following builds for you:

@asodja
Copy link
Member Author

asodja commented Apr 25, 2023

@bot-gradle test and merge

@gradle gradle deleted a comment from asodja Apr 25, 2023
@bot-gradle
Copy link
Collaborator

Your PR is queued. See the queue page for details.