• Home
Name Date Size #Lines LOC

..--

android-annotation-stubs/03-May-2024-215120

examples/03-May-2024-247175

gwt/03-May-2024-9151

java/dagger/03-May-2024-53,15032,398

javatests/dagger/03-May-2024-64,01950,290

lib/03-May-2024-423357

resources/META-INF/services/03-May-2024-21

tools/03-May-2024-12492

util/03-May-2024-242186

.bazelrcD03-May-2024270 97

.gitignoreD03-May-2024239 3625

.travis.ymlD03-May-20242.3 KiB6650

AUTHORSD03-May-2024329 88

Android.bpD03-May-20245.3 KiB215176

BUILDD03-May-20245.3 KiB180162

CHANGELOG.mdD03-May-2024212 75

CONTRIBUTING.mdD03-May-20243.2 KiB7055

LICENSE.txtD03-May-202411.1 KiB203169

METADATAD03-May-2024342 1816

MODULE_LICENSE_APACHE2D03-May-20240

NOTICED03-May-202411.1 KiB203169

OWNERSD03-May-202433 21

README.mdD03-May-20247.3 KiB229183

WORKSPACED03-May-20241.3 KiB3529

build_defs.bzlD03-May-2024826 2722

jarjar-rules.txtD03-May-2024173 43

test_defs.bzlD03-May-20245.6 KiB196180

README.md

1# Dagger 2
2
3[![Maven Central][mavenbadge-svg]][mavencentral]
4
5A fast dependency injector for Android and Java.
6
7## About Google's Fork
8
9Dagger 2 is a compile-time evolution approach to dependency injection.
10Taking the approach started in Dagger 1.x to its ultimate conclusion,
11Dagger 2.x eliminates all reflection, and improves code clarity by
12removing the traditional ObjectGraph/Injector in favor of user-specified
13`@Component` interfaces.
14
15This github project represents the Dagger 2 development stream.  The earlier
16[project page][square] (Square, Inc's repository) represents the earlier 1.0
17development stream. Both versions have benefited from strong involvement from
18Square, Google, and other contributors.
19
20Dagger is currently in active development, primarily internally at Google,
21with regular pushes to the open-source community. Snapshot releases are
22auto-deployed to sonatype's central maven repository on every clean build with
23the version `HEAD-SNAPSHOT`.
24
25> [Dagger 2's main documentation website can be found here.][website]
26
27## Documentation
28
29You can [find the dagger documentation here][website] which has extended usage
30instructions and other useful information.  Substantial usage information can be
31found in the [API documentation][20api].
32
33You can also learn more from [the original proposal][proposal],
34[this talk by Greg Kick][gaktalk], and on the dagger-discuss@googlegroups.com
35mailing list.
36
37## Installation
38
39### Bazel
40
41If you build with `bazel`, follow the [`bazel` documentation for referencing
42external projects][bazel-external-deps] to include Dagger in your build.
43
44Given the following `WORKSPACE` definition, you can reference dagger via
45`@com_google_dagger//:dagger_with_compiler` in your deps.
46
47```python
48http_archive(
49    name = "com_google_dagger",
50    urls = ["https://github.com/google/dagger/archive/dagger-<version>.zip"],
51)
52```
53
54### Other build systems
55
56You will need to include the `dagger-2.x.jar` in your application's runtime.
57In order to activate code generation and generate implementations to manage
58your graph you will need to include `dagger-compiler-2.x.jar` in your build
59at compile time.
60
61#### Maven
62
63In a Maven project, include the `dagger` artifact in the dependencies section
64of your `pom.xml` and the `dagger-compiler` artifact as an
65`annotationProcessorPaths` value of the `maven-compiler-plugin`:
66
67```xml
68<dependencies>
69  <dependency>
70    <groupId>com.google.dagger</groupId>
71    <artifactId>dagger</artifactId>
72    <version>2.x</version>
73  </dependency>
74</dependencies>
75<build>
76  <plugins>
77    <plugin>
78      <groupId>org.apache.maven.plugins</groupId>
79      <artifactId>maven-compiler-plugin</artifactId>
80      <version>3.6.1</version>
81      <configuration>
82        <annotationProcessorPaths>
83          <path>
84            <groupId>com.google.dagger</groupId>
85            <artifactId>dagger-compiler</artifactId>
86            <version>2.x</version>
87          </path>
88        </annotationProcessorPaths>
89      </configuration>
90    </plugin>
91  </plugins>
92</build>
93```
94
95If you are using a version of the `maven-compiler-plugin` lower than `3.5`, add
96the `dagger-compiler` artifact with the `provided` scope:
97
98```xml
99<dependencies>
100  <dependency>
101    <groupId>com.google.dagger</groupId>
102    <artifactId>dagger</artifactId>
103    <version>2.x</version>
104  </dependency>
105  <dependency>
106    <groupId>com.google.dagger</groupId>
107    <artifactId>dagger-compiler</artifactId>
108    <version>2.x</version>
109    <scope>provided</scope>
110  </dependency>
111</dependencies>
112```
113
114If you use the beta `dagger-producers` extension (which supplies
115parallelizable execution graphs), then add this to your maven configuration:
116
117```xml
118<dependencies>
119  <dependency>
120    <groupId>com.google.dagger</groupId>
121    <artifactId>dagger-producers</artifactId>
122    <version>2.x</version>
123  </dependency>
124</dependencies>
125```
126
127#### Java Gradle
128```groovy
129// Add plugin https://plugins.gradle.org/plugin/net.ltgt.apt
130plugins {
131  id "net.ltgt.apt" version "0.10"
132}
133
134// Add Dagger dependencies
135dependencies {
136  compile 'com.google.dagger:dagger:2.x'
137  apt 'com.google.dagger:dagger-compiler:2.x'
138}
139```
140
141#### Android Gradle
142```groovy
143// Add Dagger dependencies
144dependencies {
145  compile 'com.google.dagger:dagger:2.x'
146  annotationProcessor 'com.google.dagger:dagger-compiler:2.x'
147}
148```
149
150If you're using classes in `dagger.android` you'll also want to include:
151
152```groovy
153compile 'com.google.dagger:dagger-android:2.x'
154compile 'com.google.dagger:dagger-android-support:2.x' // if you use the support libraries
155annotationProcessor 'com.google.dagger:dagger-android-processor:2.x'
156```
157
158If you're using a version of the Android gradle plugin below `2.2`, see
159https://bitbucket.org/hvisser/android-apt.
160
161If you're using the [Android Databinding library][databinding], you may want to
162increase the number of errors that `javac` will print. When Dagger prints an
163error, databinding compilation will halt and sometimes print more than 100
164errors, which is the default amount for `javac`. For more information, see
165[Issue 306](https://github.com/google/dagger/issues/306).
166
167```groovy
168gradle.projectsEvaluated {
169  tasks.withType(JavaCompile) {
170    options.compilerArgs << "-Xmaxerrs" << "500" // or whatever number you want
171  }
172}
173```
174
175### Download
176
177  * 2.x (google/dagger)
178    * [Dagger 2.0 Documentation][website]
179    * [Dagger 2.0 Javadocs][20api]
180    * [Dagger development Javadocs][latestapi] (from the `master` branch
181      on GitHub)
182    * [Google's Dagger project site on GitHub][project]
183  * 1.x (square/dagger)
184    * [Square's original Dagger project site on GitHub][square]
185
186
187If you do not use maven, gradle, ivy, or other build systems that consume
188maven-style binary artifacts, they can be downloaded directly via the
189[Maven Central Repository][mavencentral].
190
191Developer snapshots are available from Sonatype's
192[snapshot repository][dagger-snap], and are built on a clean build of
193the GitHub project's master branch.
194
195## Building Dagger
196
197See [the CONTRIBUTING.md docs][Building Dagger].
198
199## License
200
201    Copyright 2012 The Dagger Authors
202
203    Licensed under the Apache License, Version 2.0 (the "License");
204    you may not use this file except in compliance with the License.
205    You may obtain a copy of the License at
206
207       http://www.apache.org/licenses/LICENSE-2.0
208
209    Unless required by applicable law or agreed to in writing, software
210    distributed under the License is distributed on an "AS IS" BASIS,
211    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
212    See the License for the specific language governing permissions and
213    limitations under the License.
214
215[20api]: https://dagger.dev/api/2.0/
216[`bazel`]: https://bazel.build
217[bazel-external-deps]: https://docs.bazel.build/versions/master/external.html#depending-on-other-bazel-projects
218[Building Dagger]: CONTRIBUTING.md#building-dagger
219[dagger-snap]: https://oss.sonatype.org/content/repositories/snapshots/com/google/dagger/
220[databinding]: https://developer.android.com/topic/libraries/data-binding/
221[gaktalk]: https://www.youtube.com/watch?v=oK_XtfXPkqw
222[latestapi]: https://dagger.dev/api/latest/
223[mavenbadge-svg]: https://maven-badges.herokuapp.com/maven-central/com.google.dagger/dagger/badge.svg
224[mavencentral]: https://search.maven.org/artifact/com.google.dagger/dagger
225[project]: http://github.com/google/dagger/
226[proposal]: https://github.com/square/dagger/issues/366
227[square]: http://github.com/square/dagger/
228[website]: https://dagger.dev
229