Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 34 additions & 10 deletions factory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ A source code generator for JSR-330-compatible factories.
AutoWhat‽
-------------

[Java][java] is full of [factories](http://en.wikipedia.org/wiki/Factory_method_pattern). They're mechanical, repetitive, typically untested and sometimes the source of subtle bugs. _Sounds like a job for robots!_
[Java][java] is full of [factories](https://en.wikipedia.org/wiki/Factory_method_pattern). They're mechanical, repetitive, typically untested and sometimes the source of subtle bugs. _Sounds like a job for robots!_

AutoFactory generates factories that can be used on their own or with [JSR-330](http://jcp.org/en/jsr/detail?id=330)-compatible [dependency injectors](http://en.wikipedia.org/wiki/Dependency_injection) from a simple annotation. Any combination of parameters can either be passed through factory methods or provided to the factory at construction time. They can implement interfaces or extend abstract classes. They're what you would have written, but without the bugs.
AutoFactory generates factories that can be used on their own or with [JSR-330](https://jcp.org/en/jsr/detail?id=330)-compatible [dependency injectors](https://en.wikipedia.org/wiki/Dependency_injection) from a simple annotation. Any combination of parameters can either be passed through factory methods or provided to the factory at construction time. They can implement interfaces or extend abstract classes. They're what you would have written, but without the bugs.

[Dagger](https://dagger.dev/) users: Dagger's own
[assisted injection](https://dagger.dev/dev-guide/assisted-injection.html) is
[assisted injection](https://dagger.dev/dev-guide/assisted-injection) is
now usually preferred to AutoFactory.

Example
Expand Down Expand Up @@ -77,24 +77,48 @@ final class SomeClass {
Download
--------

In order to activate code generation you will need to
include `auto-factory-${version}.jar` in your build at
compile time.
In order to activate code generation, you will need to include
`auto-factory-${version}.jar` in both your classpath and your
annotation-processor path at compile time.

In a Maven project, one would include the `auto-factory`
artifact as an "optional" dependency:
In a Maven project, one would include the `auto-factory` artifact as an
"optional" dependency and then include it again in `annotationProcessorPaths`:

```xml
<dependencies>
<dependency>
<groupId>com.google.auto.factory</groupId>
<artifactId>auto-factory</artifactId>
<version>${version}</version>
<version>${auto-factory.version}</version>
<optional>true</optional>
</dependency>
</dependencies>

...

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>com.google.auto.factory</groupId>
<artifactId>auto-factory</artifactId>
<version>${auto-factory.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
```

Previous versions of these instructions suggested an alternative configuration
without the `annotationProcessorPaths` entry. We no longer recommend that
configuration. (It may produce [warnings or errors][JDK-8321319] under recent
versions of Java.)


License
-------
Expand All @@ -113,5 +137,5 @@ License
See the License for the specific language governing permissions and
limitations under the License.

[JDK-8321319]: https://bugs.openjdk.org/browse/JDK-8321319
[java]: https://en.wikipedia.org/wiki/Java_(programming_language)

23 changes: 17 additions & 6 deletions factory/src/it/functional/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
<artifactId>auto-factory</artifactId>
<version>@project.version@</version>
</dependency>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value-annotations</artifactId>
<version>1.11.0</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
Expand All @@ -50,12 +55,6 @@
<artifactId>dagger</artifactId>
<version>2.42</version>
</dependency>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.42</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down Expand Up @@ -87,6 +86,18 @@
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<annotationProcessorPaths>
<path>
<groupId>com.google.auto.factory</groupId>
<artifactId>auto-factory</artifactId>
<version>@project.version@</version>
</path>
<path>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.42</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
Expand Down
Loading