google / google/auto

Allow configuration of AutoFactory to use custom instantiator instead of new

Open
#872 3 comments 0 reactions 0 assignees View on GitHub
Component: factory P3 type=addition
Dominant language
Java
Stars
10.6k
Forks
1.2k
Avg merge
6h 32m
Merged PRs (30d)
13

Description

Gradle recommends using [`ObjectFactory#newInstance`](https://github.com/gradle/gradle/blob/048958212baea839816c621f60db1975578e525a/subprojects/core-api/src/main/java/org/gradle/api/model/ObjectFactory.java#L91) to create new instances of classes as it performs a runtime decoration on the classes. It takes the class to instantiate as the first argument and all of the `@Inject` annotated constructor arguments as the following arguments.

Unfortunately, AutoFactory is opinionated to use `new` (with good reason). I'm wondering if we could accommodate cases such as this one where a custom instantiator could be used instead of using `new`. I would rather not have to maintain a fork of this processor.

Is this something this project would accept as a contribution? If so, which design should we go for? It would be nice to `@Provided` the instantiator class so it can be used automatically.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.