Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 724997a

Browse files
committed
Merge pull request #44 from google/configuration-docs
Add a section on configuration, covering javac, Maven, Gradle, Eclipse and IntelliJ
2 parents 4dc9acc + cabf972 commit 724997a

File tree

1 file changed

+81
-26
lines changed

1 file changed

+81
-26
lines changed

README.md

+81-26
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,16 @@ _Automatic generation of the Builder pattern for Java 1.6+_
2222
- [Nested buildable types](#nested-buildable-types)
2323
- [Builder construction](#builder-construction)
2424
- [Partials](#partials)
25-
- [IDEs](#ides)
2625
- [GWT](#gwt)
27-
- [Troubleshooting](#troubleshooting)
28-
- [Javac](#javac)
26+
- [Build tools and IDEs](#build-tools-and-ides)
27+
- [javac](#javac)
28+
- [Maven](#maven)
29+
- [Gradle](#gradle)
2930
- [Eclipse](#eclipse)
31+
- [IntelliJ](#intellij)
32+
- [Troubleshooting](#troubleshooting)
33+
- [Troubleshooting javac](#troubleshooting-javac)
34+
- [Troubleshooting Eclipse](#troubleshooting-eclipse)
3035
- [Online resouces](#online-resouces)
3136
- [Alternatives](#alternatives)
3237
- [AutoValue vs `@FreeBuilder`](#autovalue-vs-freebuilder)
@@ -71,18 +76,8 @@ How to use `@FreeBuilder`
7176

7277
### Quick start
7378

74-
Add the `@FreeBuilder` artifact as an optional dependency to your Maven POM:
75-
76-
```xml
77-
<dependencies>
78-
<dependency>
79-
<groupId>org.inferred</groupId>
80-
<artifactId>freebuilder</artifactId>
81-
<version>1.0-rc5</version>
82-
<optional>true</optional>
83-
</dependency>
84-
</dependencies>
85-
```
79+
_See [Build tools and IDEs](#build-tools-and-ides) for how to add `@FreeBuilder`
80+
to your project's build and/or IDE._
8681

8782
Create your value type (e.g. `Person`) as an interface or abstract class,
8883
containing an abstract accessor method for each desired field. This accessor
@@ -319,15 +314,6 @@ suite, allowing you to add new required fields or other constraints to an
319314
existing value type without breaking swathes of test code.
320315

321316

322-
### IDEs
323-
324-
Follow your IDE's annotation processing instructions [[Eclipse instructions][];
325-
[IntelliJ instructions][]].
326-
327-
[Eclipse instructions]: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Fguide%2Fjdt_apt_getting_started.htm
328-
[IntelliJ instructions]: http://www.jetbrains.com/idea/webhelp/configuring-annotation-processing.html
329-
330-
331317
### GWT
332318

333319
To enable [GWT][] serialization of the generated Value subclass, just add
@@ -339,11 +325,80 @@ and ensure all necessary types are whitelisted.
339325
[CustomFieldSerializer]: http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/client/rpc/CustomFieldSerializer.html
340326

341327

328+
Build tools and IDEs
329+
--------------------
330+
331+
### javac
332+
333+
Download [freebuilder-1.0-rc5.jar][] and add it to the classpath (or
334+
processorpath, if you supply one) on the command line.
335+
336+
[freebuilder-1.0-rc5.jar]: http://repo1.maven.org/maven2/org/inferred/freebuilder/1.0-rc5/freebuilder-1.0-rc5.jar
337+
338+
### Maven
339+
340+
Add the `@FreeBuilder` artifact as an optional dependency to your Maven POM:
341+
342+
```xml
343+
<dependencies>
344+
<dependency>
345+
<groupId>org.inferred</groupId>
346+
<artifactId>freebuilder</artifactId>
347+
<version>1.0-rc5</version>
348+
<optional>true</optional>
349+
</dependency>
350+
</dependencies>
351+
```
352+
353+
### Gradle
354+
355+
Add the following line to your dependencies:
356+
357+
```
358+
compile 'org.inferred:freebuilder:1.0-rc5'
359+
```
360+
361+
### Eclipse
362+
363+
_Condensed from [Eclipse Indigo's documentation][]._
364+
365+
Download [freebuilder-1.0-rc5.jar][] and add it to your project. Right-click it
366+
and select **Build path > Add to Build path**.
367+
368+
In your projects properties dialog, go to **Java Compiler > Annotation
369+
Processing** and ensure **Enable annotation processing** is checked.
370+
Next, go to **Java Compiler > Annotation Processing > Factory Path**, select
371+
**Add JARs**, and select `freebuilder-1.0-rc5.jar`.
372+
373+
[Eclipse Indigo's documentation]: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Fguide%2Fjdt_apt_getting_started.htm
374+
375+
### IntelliJ
376+
377+
_Condensed from the [IntelliJ 14.0.3 documentation][] and [Auto Issue #106][]._
378+
379+
Download [freebuilder-1.0-rc5.jar][], add it to your project, right-click it and
380+
select **Use as Project Library**.
381+
382+
In your Settings, go to **Build, Execution, Deployment > Compiler > Annotation
383+
Processors** and ensure **Enable annotation processing** is selected, and
384+
**Store generated sources relative to** is set to *Module content root*.
385+
(If you have specified a processor path, ensure you add the new JAR to it.
386+
Similarly, if you choose to specify processors explicitly, add
387+
`org.inferred.freebuilder.processor.Processor` to the list.)
388+
389+
Run **Build > Rebuild Project**, then right-click the new `generated` folder
390+
(this may have a different name if you have changed the **Production sources
391+
directory** setting) and select **Mark Directory As > Generated Sources Root**.
392+
393+
[IntelliJ 14.0.3 documentation]: http://www.jetbrains.com/idea/webhelp/configuring-annotation-processing.html
394+
[Auto Issue #106]: https://github.com/google/auto/issues/106
395+
396+
342397
Troubleshooting
343398
---------------
344399

345400

346-
### Javac
401+
### Troubleshooting javac
347402

348403
If you make a mistake in your code (e.g. giving your value type a private
349404
constructor), `@FreeBuilder` is designed to output a Builder superclass anyway,
@@ -362,7 +417,7 @@ string "@FreeBuilder type"; nearly all errors include this in their text.
362417

363418
[issue 3]: https://github.com/google/FreeBuilder/issues/3
364419

365-
### Eclipse
420+
### Troubleshooting Eclipse
366421

367422
Eclipse manages, somehow, to be worse than `javac` here. It will never output
368423
annotation processor errors unless there is another error of some kind; and,

0 commit comments

Comments
 (0)