Skip to content

Conversation

asodja
Copy link
Member

@asodja asodja commented Apr 11, 2023

Adds support for "custom accessors" for property upgrades, e.g. you can define accessors like:

public class TaskCustomAccessors {
    @UpgradedSetter(forProperty = "maxErrors")
    public static void access_maxErrors(Task self, int value) {
    }
    @UpgradedSetter(forProperty = "maxErrors")
    public static Task access_setMaxErrors(Task self, Object value) {
        return self;
    }
    @UpgradedGetter(forProperty = "maxErrors")
    @UpgradedGroovyProperty(forProperty = "maxErrors")
    public static int access_getMaxErrors(Task self) {
        return self.getMaxErrors().get();
    }
}


class Checkstyle {
   @UpgradedProperty(accessors = TaskCustomAccessors.class)
   abstract Property<Integer> getMaxErrors()
}

Annotation processor then does some validations that property names match, types match etc and generates interceptors.

Based on #24632.

@asodja asodja self-assigned this Apr 11, 2023
@asodja asodja added @execution in:provider-api property lazy provider MapProperty ListProperty DirectoryProperty labels Apr 11, 2023
@asodja asodja force-pushed the asodja/property-upgrades-cherry-custom branch from 27678a2 to bcb1ddf Compare April 11, 2023 14:02
bot-gradle added a commit that referenced this pull request Apr 25, 2023
…tion support

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.

Co-authored-by: Anže Sodja <[email protected]>
Base automatically changed from asodja/property-upgrades-cherry to master April 25, 2023 11:19
@github-actions
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be closed if no further activity occurs. If you intend to work on this pull request, please ask the team to reopen the PR or push a new PR. Thank you for your contributions.

@github-actions github-actions bot added the stale label Jun 24, 2023
Copy link
Contributor

This pull request has been automatically closed due to inactivity.

@github-actions github-actions bot closed this Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:provider-api property lazy provider MapProperty ListProperty DirectoryProperty stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant