Repository: square/dagger
Branch: master
Commit: 0fa73e0ee070
Files: 202
Total size: 601.2 KB
Directory structure:
gitextract_cz8_4_6g/
├── .buildscript/
│ ├── deploy_snapshot.sh
│ └── settings.xml
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE.txt
├── README.md
├── checkstyle.xml
├── compiler/
│ ├── pom.xml
│ └── src/
│ ├── it/
│ │ ├── default-package-injected-type/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── TestApp.java
│ │ ├── extension-graph/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── test/
│ │ │ └── TestApp.java
│ │ ├── extension-graph-setvalues/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── test/
│ │ │ └── TestApp.java
│ │ ├── final-field-inject/
│ │ │ ├── invoker.properties
│ │ │ ├── pom.xml
│ │ │ ├── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── test/
│ │ │ │ └── TestApp.java
│ │ │ └── verify.bsh
│ │ ├── include-non-module/
│ │ │ ├── invoker.properties
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── test/
│ │ │ └── TestApp.java
│ │ ├── inject-on-class/
│ │ │ ├── invoker.properties
│ │ │ ├── pom.xml
│ │ │ ├── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── test/
│ │ │ │ └── TestApp.java
│ │ │ └── verify.bsh
│ │ ├── inject-parameterized-type/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── test/
│ │ │ └── TestApp.java
│ │ ├── inner-classes-complaint-injection/
│ │ │ ├── invoker.properties
│ │ │ ├── pom.xml
│ │ │ ├── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── test/
│ │ │ │ └── TestApp.java
│ │ │ └── verify.bsh
│ │ ├── method-injection/
│ │ │ ├── invoker.properties
│ │ │ ├── pom.xml
│ │ │ ├── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── test/
│ │ │ │ └── TestApp.java
│ │ │ └── verify.bsh
│ │ ├── missing-at-inject-constructor/
│ │ │ ├── invoker.properties
│ │ │ ├── pom.xml
│ │ │ ├── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── test/
│ │ │ │ └── TestApp.java
│ │ │ └── verify.bsh
│ │ ├── module-type-validation/
│ │ │ ├── invoker.properties
│ │ │ ├── pom.xml
│ │ │ ├── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── test/
│ │ │ │ └── TestModule.java
│ │ │ └── verify.bsh
│ │ ├── multiple-modules-setvalues/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── test/
│ │ │ └── TestApp.java
│ │ ├── multiple-provides-methods/
│ │ │ ├── pom.xml
│ │ │ ├── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── test/
│ │ │ │ └── TestApp.java
│ │ │ └── verify.bsh
│ │ ├── multiple-qualifiers/
│ │ │ ├── invoker.properties
│ │ │ ├── pom.xml
│ │ │ ├── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── test/
│ │ │ │ └── TestApp.java
│ │ │ └── verify.bsh
│ │ ├── private-inject/
│ │ │ ├── invoker.properties
│ │ │ ├── pom.xml
│ │ │ ├── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── test/
│ │ │ │ ├── TestApp.java
│ │ │ │ └── TestFoo.java
│ │ │ └── verify.bsh
│ │ ├── provide-provider-or-lazy/
│ │ │ ├── invoker.properties
│ │ │ ├── pom.xml
│ │ │ ├── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── test/
│ │ │ │ └── TestModule.java
│ │ │ └── verify.bsh
│ │ ├── provides-method-not-in-module/
│ │ │ ├── invoker.properties
│ │ │ ├── pom.xml
│ │ │ ├── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── test/
│ │ │ │ └── TestApp.java
│ │ │ └── verify.bsh
│ │ ├── provides-method-with-throws-clause/
│ │ │ ├── invoker.properties
│ │ │ ├── pom.xml
│ │ │ ├── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── test/
│ │ │ │ └── TestApp.java
│ │ │ └── verify.bsh
│ │ ├── qualifiers-on-invalid-elements-errors/
│ │ │ ├── invoker.properties
│ │ │ ├── pom.xml
│ │ │ ├── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── test/
│ │ │ │ └── TestApp.java
│ │ │ └── verify.bsh
│ │ ├── qualifiers-on-invalid-elements-warnings/
│ │ │ ├── pom.xml
│ │ │ ├── src/
│ │ │ │ └── main/
│ │ │ │ └── java/
│ │ │ │ └── test/
│ │ │ │ └── TestApp.java
│ │ │ └── verify.bsh
│ │ ├── same-provides-method-name/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── test/
│ │ │ └── TestApp.java
│ │ ├── static-injected-binding-doesnt-fail-providers/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── test/
│ │ │ └── Test.java
│ │ ├── uninjectable-supertype/
│ │ │ ├── pom.xml
│ │ │ └── src/
│ │ │ └── main/
│ │ │ └── java/
│ │ │ └── test/
│ │ │ └── TestApp.java
│ │ └── valid-use-of-qualifiers/
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ └── java/
│ │ └── test/
│ │ └── TestApp.java
│ ├── main/
│ │ ├── java/
│ │ │ └── dagger/
│ │ │ └── internal/
│ │ │ └── codegen/
│ │ │ ├── AdapterJavadocs.java
│ │ │ ├── GeneratorKeys.java
│ │ │ ├── GraphAnalysisErrorHandler.java
│ │ │ ├── GraphAnalysisInjectBinding.java
│ │ │ ├── GraphAnalysisLoader.java
│ │ │ ├── GraphAnalysisProcessor.java
│ │ │ ├── GraphAnalysisStaticInjection.java
│ │ │ ├── GraphVisualizer.java
│ │ │ ├── GraphVizWriter.java
│ │ │ ├── InjectAdapterProcessor.java
│ │ │ ├── ModuleAdapterProcessor.java
│ │ │ ├── Util.java
│ │ │ └── ValidationProcessor.java
│ │ └── resources/
│ │ └── META-INF/
│ │ └── services/
│ │ └── javax.annotation.processing.Processor
│ └── test/
│ └── java/
│ └── dagger/
│ ├── internal/
│ │ └── codegen/
│ │ ├── DotWriterTest.java
│ │ ├── GraphAnalysisLoaderTest.java
│ │ └── GraphVisualizerTest.java
│ ├── testing/
│ │ └── it/
│ │ └── BuildLogValidator.java
│ └── tests/
│ └── integration/
│ ├── ProcessorTestUtils.java
│ ├── codegen/
│ │ ├── GenericInjectAdapterGenerationTest.java
│ │ ├── InjectAdapterGenerationTest.java
│ │ └── ModuleAdapterGenerationTest.java
│ ├── operation/
│ │ ├── FailureModeErrorsTest.java
│ │ ├── PrimitiveInjectionTest.java
│ │ └── SimpleInjectionTest.java
│ └── validation/
│ ├── CyclicDependencyTest.java
│ ├── CyclicModuleIncludesTest.java
│ ├── GeneratedTypesNotReadyTest.java
│ ├── LibraryModuleTest.java
│ ├── ScopeAnnotationUseTest.java
│ └── SimpleMissingDependencyTest.java
├── core/
│ ├── pom.xml
│ └── src/
│ ├── main/
│ │ └── java/
│ │ └── dagger/
│ │ ├── Lazy.java
│ │ ├── MembersInjector.java
│ │ ├── Module.java
│ │ ├── ObjectGraph.java
│ │ ├── Provides.java
│ │ └── internal/
│ │ ├── ArrayQueue.java
│ │ ├── Binding.java
│ │ ├── BindingsGroup.java
│ │ ├── BuiltInBinding.java
│ │ ├── FailoverLoader.java
│ │ ├── Keys.java
│ │ ├── LazyBinding.java
│ │ ├── Linker.java
│ │ ├── Loader.java
│ │ ├── Memoizer.java
│ │ ├── ModuleAdapter.java
│ │ ├── Modules.java
│ │ ├── ProblemDetector.java
│ │ ├── ProvidesBinding.java
│ │ ├── SetBinding.java
│ │ ├── StaticInjection.java
│ │ ├── ThrowingErrorHandler.java
│ │ └── loaders/
│ │ ├── GeneratedAdapters.java
│ │ ├── ReflectiveAtInjectBinding.java
│ │ └── ReflectiveStaticInjection.java
│ └── test/
│ └── java/
│ └── dagger/
│ ├── ExtensionTest.java
│ ├── ExtensionWithSetBindingsTest.java
│ ├── ExtensionWithStateTest.java
│ ├── InjectStaticsTest.java
│ ├── InjectionOfLazyTest.java
│ ├── InjectionTest.java
│ ├── LazyInjectionTest.java
│ ├── MembersInjectorTest.java
│ ├── ModuleTest.java
│ ├── ProblemDetectorTest.java
│ ├── SetBindingTest.java
│ ├── ThreadSafetyTest.java
│ ├── UnusedProviderTest.java
│ └── internal/
│ ├── FailoverLoaderTest.java
│ ├── KeysTest.java
│ ├── SingletonBindingTest.java
│ ├── TestingLoader.java
│ └── TestingModuleAdapter.java
├── deploy_website.sh
├── examples/
│ ├── android-activity-graphs/
│ │ ├── README.md
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── example/
│ │ │ └── dagger/
│ │ │ └── activitygraphs/
│ │ │ ├── ActivityModule.java
│ │ │ ├── AndroidModule.java
│ │ │ ├── DemoApplication.java
│ │ │ ├── DemoBaseActivity.java
│ │ │ ├── DemoBaseFragment.java
│ │ │ ├── ForActivity.java
│ │ │ ├── ForApplication.java
│ │ │ └── ui/
│ │ │ ├── ActivityTitleController.java
│ │ │ ├── HomeActivity.java
│ │ │ └── HomeFragment.java
│ │ └── res/
│ │ └── values/
│ │ └── strings.xml
│ ├── android-simple/
│ │ ├── README.md
│ │ ├── pom.xml
│ │ └── src/
│ │ └── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── example/
│ │ │ └── dagger/
│ │ │ └── simple/
│ │ │ ├── AndroidModule.java
│ │ │ ├── DemoApplication.java
│ │ │ ├── DemoBaseActivity.java
│ │ │ ├── DemoModule.java
│ │ │ ├── ForApplication.java
│ │ │ └── ui/
│ │ │ └── HomeActivity.java
│ │ └── res/
│ │ └── values/
│ │ └── strings.xml
│ ├── pom.xml
│ └── simple/
│ ├── pom.xml
│ └── src/
│ ├── main/
│ │ └── java/
│ │ └── coffee/
│ │ ├── CoffeeApp.java
│ │ ├── CoffeeMaker.java
│ │ ├── DripCoffeeModule.java
│ │ ├── ElectricHeater.java
│ │ ├── Heater.java
│ │ ├── Pump.java
│ │ ├── PumpModule.java
│ │ └── Thermosiphon.java
│ └── test/
│ └── java/
│ └── coffee/
│ └── CoffeeMakerTest.java
├── pom.xml
└── website/
├── index.html
└── static/
├── app-theme.css
├── app.css
└── prettify.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .buildscript/deploy_snapshot.sh
================================================
#!/bin/bash
#
# Deploy a jar, source jar, and javadoc jar to Sonatype's snapshot repo.
#
# Adapted from https://coderwall.com/p/9b_lfq and
# http://benlimmer.com/2013/12/26/automatically-publish-javadoc-to-gh-pages-with-travis-ci/
SLUG="square/dagger"
JDK="oraclejdk7" # Dagger integration tests fail on JDK 8 :(
BRANCH="master"
set -e
if [ "$TRAVIS_REPO_SLUG" != "$SLUG" ]; then
echo "Skipping snapshot deployment: wrong repository. Expected '$SLUG' but was '$TRAVIS_REPO_SLUG'."
elif [ "$TRAVIS_JDK_VERSION" != "$JDK" ]; then
echo "Skipping snapshot deployment: wrong JDK. Expected '$JDK' but was '$TRAVIS_JDK_VERSION'."
elif [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "Skipping snapshot deployment: was pull request."
elif [ "$TRAVIS_BRANCH" != "$BRANCH" ]; then
echo "Skipping snapshot deployment: wrong branch. Expected '$BRANCH' but was '$TRAVIS_BRANCH'."
else
echo "Deploying snapshot..."
mvn clean source:jar javadoc:jar deploy --settings=".buildscript/settings.xml" -Dmaven.test.skip=true -Dinvoker.skip=true
echo "Snapshot deployed!"
fi
================================================
FILE: .buildscript/settings.xml
================================================
sonatype-nexus-snapshots${env.CI_DEPLOY_USERNAME}${env.CI_DEPLOY_PASSWORD}
================================================
FILE: .gitignore
================================================
.classpath
.factorypath
.project
.settings
eclipsebin
bin
gen
build
out
lib
target
pom.xml.*
release.properties
.idea
*.iml
classes
obj
.DS_Store
================================================
FILE: .travis.yml
================================================
language: android
android:
components:
- build-tools-20.0.0
- android-16
licenses:
- android-sdk-license-5be876d5
jdk:
- oraclejdk7
# - oraclejdk8 Dagger integration tests fail with JDK 8 :(
install: mvn install clean --fail-never --quiet -DskipTests=true -Dinvoker.skip=true
script: mvn verify
after_success:
- .buildscript/deploy_snapshot.sh
env:
global:
- secure: "MhR0Wr+bSbdyO6a6CM2MVHLwmFZoi8ZWWncMCNSi8/xdRoykpC1HkwJjQK+HJv7j3VNbVTPNJ/yTpzJsL4JV9aTF/S28mka8GmHSmQSeQzTuNMqnE30GDbhS3S73azGHvC9/wjh1mAA0Gz/zUX/rzCYvDVZ/DmK1HppomN+P32A="
- secure: "fnHK/ei7tdcUDlQZcXWVPRgXoIFv6h0TWSzz4spgNtFlYqa47Qr4HQOLyEpWRqZHjgfR5eXD+CCI049Z73cg5oVOp1krV0aGX/wHc5lDMJuCrBZ/YoWZnDygiPzM4CvrpxRE7DjqzC0InVdbEbuECiFsI2WotLdQ6efgaxjpZCk="
branches:
except:
- gh-pages
notifications:
email: false
sudo: false
cache:
directories:
- $HOME/.m2
================================================
FILE: CHANGELOG.md
================================================
Change Log
==========
Version 1.2.5 *(2016-05-09)*
----------------------------
* Fix: Correctly emit generated code for binding parameterized types.
Version 1.2.4 *(2016-05-03)*
----------------------------
* Fix: Restore static injection support to work correctly.
Version 1.2.3 *(2016-05-02)*
----------------------------
* Fix: Correct detection of module base classes. This previously erroneously failed compilation
on modules which extended from `Object` but were not detected as such.
* Fix: Allow the use of dollar signs in processed class names.
* Fix: Remove the need for `javac` to generate synthetic accessor methods for internal classes.
* Fix: Error when duplicate classes are listed in `injects=` or `includes=` lists.
Version 1.2.2 *(2014-07-21)*
----------------------------
* Update JavaWriter to 2.5.0. This fixes incorrectly compressing fully-qualified class names
in child packages of `java.lang` (e.g., `java.lang.ref.WeakReference`).
Version 1.2.1 *(2014-02-16)*
----------------------------
* Restore Java 5 compatibility.
* New: Improve performance of `.plus()` with large volumes of set bindings.
* Fix: Do not mask underlying exception message from binding problems when constructing a graph.
Version 1.2.0 *(2013-12-13)*
----------------------------
* Numerous performance improvements in both the compiler and runtime.
* Use more efficient `String` concatenation.
* Module adapters are now stateless.
* Use read/write locks over global locks.
* Reflective constructor invocation is now cached with `Class.newInstance`.
* Avoid re-linking all bindings when calling `.plus()`.
* Set bindings are now unioned when calling `.plus()`.
* Fix: Tolerate missing type information during compilation by deferring writing
module adapters.
Version 1.1.0 *(2013-08-05)*
----------------------------
* Module loading now requires code generation via the 'dagger-compiler' artifact.
* Allow multiple contributions to Set binding via `Provides.Type.SET_VALUES`.
* Request classloading from the classloader of the requesting object, not the current thread's
context classloader.
* Cache class loading at the root injector to reduce costs of loading adapters.
* Fix: Primitive array types are no longer incorrectly changed to their boxed type.
* Update JavaWriter to 2.1.1.
Version 1.0.1 *(2013-06-03)*
----------------------------
* Explicitly forbid declaring `@Inject` on a class type (e.g., `@Inject class Foo {}`).
* Update JavaWriter to 1.0.5.
Version 1.0.0 *(2013-05-07)*
----------------------------
Initial release.
================================================
FILE: CONTRIBUTING.md
================================================
Contributing
============
If you would like to contribute code to Dagger you can do so through GitHub by
forking the repository and sending a pull request.
When submitting code, please make every effort to follow existing conventions
and style in order to keep the code as readable as possible.
Where appropriate, please provide unit tests or integration tests. Unit tests
should be JUnit based tests and can use either standard JUnit assertions or
FEST assertions and be added to `/src/test/java`. Changes to build-time
behaviour (such as changes to code generation or graph validation) should go into
small maven projects using the `maven-invoker-plugin`. Examples of this are in
`core/src/it` and can include bean-shell verification scripts and other
facilities provided by `maven-invoker-plugin`.
Please make sure your code compiles by running `mvn clean verify` which will
execute both unit and integration test phases. Additionally, consider using
http://travis-ci.org to validate your branches before you even put them into
pull requests. All pull requests will be validated by Travis-ci in any case
and must pass before being merged.
If you are adding or modifying files you may add your own copyright line, but
please ensure that the form is consistent with the existing files, and please
note that a Square, Inc. copyright line must appear in every copyright notice.
All files are released with the Apache 2.0 license.
Checkstyle failures during compilation indicate errors in your style and will
be displayed in the console output of the build (including in Travis-CI output),
or can be viewed in the `checkstyle-result.xml` file.
Before your code can be accepted into the project you must sign the
[Individual Contributor License Agreement (CLA)][1].
[1]: https://spreadsheets.google.com/spreadsheet/viewform?formkey=dDViT2xzUHAwRkI3X3k5Z0lQM091OGc6MQ&ndplr=1
================================================
FILE: LICENSE.txt
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
Dagger 1
========
A fast dependency injector for Android and Java.
Deprecated – Please upgrade to Dagger 2
---------------------------------------
Square's Dagger 1.x is deprecated in favor of [Google's Dagger 2](https://github.com/google/dagger).
Please see [the migration guide](https://google.github.io/dagger/dagger-1-migration.html) for help
with the upgrade.
Download Dagger 1
-----------------
You will need to include the `dagger-${dagger.version}.jar` in your
application's runtime. In order to activate code generation you will need to
include `dagger-compiler-${dagger.version}.jar` in your build at compile time.
In a Maven project, one would include the runtime in the dependencies section
of your `pom.xml` (replacing `${dagger.version}` with the appropriate current
release), and the `dagger-compiler` artifact as an "optional" or "provided"
dependency:
```xml
com.squareup.daggerdagger${dagger.version}com.squareup.daggerdagger-compiler${dagger.version}true
```
You can also find downloadable .jars on Maven Central. You'll need
[Dagger][dl-dagger], [JavaPoet][dl-javapoet], and [javax.inject][dl-inject].
Snapshots of the development version are available in [Sonatype's `snapshots` repository][snap].
License
-------
Copyright 2012 Square, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
[1]: http://square.github.com/dagger/
[dl-dagger]: http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.squareup.dagger%22%20a%3A%22dagger%22
[dl-javapoet]: http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.squareup%22%20a%3A%22javapoet%22
[dl-inject]: http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22javax.inject%22%20a%3A%22javax.inject%22
[snap]: https://oss.sonatype.org/content/repositories/snapshots/
================================================
FILE: checkstyle.xml
================================================
================================================
FILE: compiler/pom.xml
================================================
4.0.0com.squareup.daggerdagger-parent1.2.6-SNAPSHOT../pom.xmldagger-compilerDagger Compiler
Tools to generate Dagger injection and module adapters from annotated code and validate them.
${project.groupId}dagger${project.version}com.squareupjavapoetcom.google.guavaguavajunitjunittestorg.mockitomockito-coretest${project.groupId}dagger${project.version}testtestscom.google.testing.compilecompile-testingtestcom.google.truthtruthtestorg.apache.maven.pluginsmaven-compiler-plugindefault-compilecompile-proc:nonedefault-test-compiletestCompiledagger.internal.codegen.ValidationProcessordagger.internal.codegen.InjectAdapterProcessordagger.internal.codegen.ModuleAdapterProcessordagger.internal.codegen.GraphAnalysisProcessororg.apache.maven.pluginsmaven-invoker-plugintrue${project.build.directory}/it*/pom.xml${project.build.directory}/local-repoverify${project.version}${project.groupId}integration-testinstallrunorg.apache.maven.pluginsmaven-assembly-pluginjar-with-dependenciespackagesingle
================================================
FILE: compiler/src/it/default-package-injected-type/pom.xml
================================================
4.0.0com.example.dagger.testsdefault-package-injected-typeHEAD-SNAPSHOTDefault Package Injected Type@dagger.groupId@dagger@dagger.version@@dagger.groupId@dagger-compiler@dagger.version@truemaven-compiler-plugin3.11.51.5
================================================
FILE: compiler/src/it/default-package-injected-type/src/main/java/TestApp.java
================================================
/*
* Copyright (C) 2012 Google, Inc.
* Copyright (C) 2012 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import dagger.ObjectGraph;
import dagger.Module;
import javax.inject.Inject;
import javax.inject.Singleton;
class TestApp implements Runnable {
@Inject A a;
@Override public void run() {
a.doit();
}
public static void main(String[] args) {
ObjectGraph.create(new TestModule()).get(TestApp.class).run();
}
@Module(injects = { TestApp.class })
static class TestModule {}
@Singleton
static class A {
@Inject A() {}
public void doit() {};
}
}
================================================
FILE: compiler/src/it/extension-graph/pom.xml
================================================
4.0.0com.example.dagger.testsextension-graphHEAD-SNAPSHOTDagger Integration Test Basic@dagger.groupId@dagger@dagger.version@@dagger.groupId@dagger-compiler@dagger.version@truemaven-compiler-plugin3.11.51.5
================================================
FILE: compiler/src/it/extension-graph/src/main/java/test/TestApp.java
================================================
/*
* Copyright (C) 2012 Google, Inc.
* Copyright (C) 2012 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import dagger.ObjectGraph;
import dagger.Module;
import javax.inject.Inject;
import javax.inject.Singleton;
class TestApp implements Runnable {
@Inject C c;
@Override public void run() {
c.doit();
}
public static void main(String[] args) {
ObjectGraph root = ObjectGraph.create(new RootModule());
ObjectGraph extension = root.plus(new ExtensionModule());
extension.get(TestApp.class).run();
}
@Module(injects = { A.class, B.class })
static class RootModule { }
@Module(addsTo=RootModule.class, injects = { C.class, TestApp.class })
static class ExtensionModule { }
@Singleton
static class A {
@Inject A() {}
}
static class B {
@Inject A a;
@Inject B() {}
}
static class C {
@Inject A a;
@Inject B b;
@Inject C() {}
public void doit() {};
}
}
================================================
FILE: compiler/src/it/extension-graph-setvalues/pom.xml
================================================
4.0.0com.example.dagger.testsextension-graph-setvaluesHEAD-SNAPSHOTDagger Integration Test Basic@dagger.groupId@dagger@dagger.version@@dagger.groupId@dagger-compiler@dagger.version@truemaven-compiler-plugin3.11.51.5
================================================
FILE: compiler/src/it/extension-graph-setvalues/src/main/java/test/TestApp.java
================================================
/*
* Copyright (C) 2013 Google, Inc.
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import dagger.ObjectGraph;
import dagger.Module;
import dagger.Provides;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import static dagger.Provides.Type.SET;
import static dagger.Provides.Type.SET_VALUES;
/**
* Contributions to {@code SET_VALUES} binding do not affect Set of providers.
*/
class TestApp implements Runnable {
@Inject Set> providers;
@Inject Set strings;
@Override public void run() {
System.out.println(strings);
}
public static void main(String[] args) {
ObjectGraph root = ObjectGraph.create(new RootModule());
ObjectGraph extension = root.plus(new ExtensionModule());
extension.get(TestApp.class).run();
}
@Module(injects = TestApp.class)
static class RootModule {
@Provides Set> providers() {
return new HashSet>();
}
@Provides(type = SET_VALUES) Set strings() {
return new HashSet();
}
}
@Module(addsTo = RootModule.class, injects = TestApp.class)
static class ExtensionModule {
@Provides(type = SET) String addToSet() {
return "contributed";
}
}
}
================================================
FILE: compiler/src/it/final-field-inject/invoker.properties
================================================
invoker.buildResult=failure
================================================
FILE: compiler/src/it/final-field-inject/pom.xml
================================================
4.0.0com.example.dagger.testsfinal-field-injectHEAD-SNAPSHOT@dagger.groupId@dagger@dagger.version@@dagger.groupId@dagger-compiler@dagger.version@truemaven-compiler-plugin3.11.51.5
================================================
FILE: compiler/src/it/final-field-inject/src/main/java/test/TestApp.java
================================================
/*
* Copyright (C) 2013 Google, Inc.
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import javax.inject.Inject;
class TestApp {
@Inject final Object nope;
}
================================================
FILE: compiler/src/it/final-field-inject/verify.bsh
================================================
import dagger.testing.it.BuildLogValidator;
import java.io.File;
File buildLog = new File(basedir, "build.log");
new BuildLogValidator().assertHasText(buildLog, new String[]{
"Can't inject a final field: test.TestApp.nope"});
================================================
FILE: compiler/src/it/include-non-module/invoker.properties
================================================
invoker.buildResult=failure
================================================
FILE: compiler/src/it/include-non-module/pom.xml
================================================
4.0.0com.example.dagger.testsinclude-non-moduleHEAD-SNAPSHOTDagger Integration Test Basic@dagger.groupId@dagger@dagger.version@@dagger.groupId@dagger-compiler@dagger.version@truemaven-compiler-plugin3.11.51.5
================================================
FILE: compiler/src/it/include-non-module/src/main/java/test/TestApp.java
================================================
/*
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import dagger.Module;
import dagger.ObjectGraph;
import dagger.Provides;
import javax.inject.Inject;
import java.lang.String;
class TestApp {
public static void main(String[] args) {
TestApp app = ObjectGraph.create(new TestModule()).get(TestApp.class);
}
@Inject String s;
@Module(
injects = TestApp.class,
includes = TestApp.class)
static class TestModule {
@Provides String provideString() {
return "a";
}
}
}
================================================
FILE: compiler/src/it/inject-on-class/invoker.properties
================================================
invoker.buildResult=failure
================================================
FILE: compiler/src/it/inject-on-class/pom.xml
================================================
4.0.0com.example.dagger.testsmethod-injectionHEAD-SNAPSHOT@dagger.groupId@dagger@dagger.version@@dagger.groupId@dagger-compiler@dagger.version@truemaven-compiler-plugin3.11.51.5
================================================
FILE: compiler/src/it/inject-on-class/src/main/java/test/TestApp.java
================================================
/*
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import javax.inject.Inject;
@Inject
class TestApp {
}
================================================
FILE: compiler/src/it/inject-on-class/verify.bsh
================================================
import dagger.testing.it.BuildLogValidator;
import java.io.File;
File buildLog = new File(basedir, "build.log");
new BuildLogValidator().assertHasText(buildLog, new String[]{
"@Inject is not valid on a class: test.TestApp"});
================================================
FILE: compiler/src/it/inject-parameterized-type/pom.xml
================================================
4.0.0com.example.dagger.testsinject-parameterized-typeHEAD-SNAPSHOTDagger Integration Test Basic@dagger.groupId@dagger@dagger.version@@dagger.groupId@dagger-compiler@dagger.version@truemaven-compiler-plugin3.11.51.5
================================================
FILE: compiler/src/it/inject-parameterized-type/src/main/java/test/TestApp.java
================================================
/*
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import dagger.Module;
import dagger.ObjectGraph;
import dagger.Provides;
import javax.inject.Inject;
class TestApp {
public static void main(String[] args) {
Subtype subtype = ObjectGraph.create(new TestModule()).get(Subtype.class);
}
static class Supertype {
@Inject String s;
}
static class Subtype extends Supertype {
}
@Module(injects = Subtype.class)
static class TestModule {
@Provides String provideString() {
return "a";
}
}
}
================================================
FILE: compiler/src/it/inner-classes-complaint-injection/invoker.properties
================================================
invoker.buildResult=failure
================================================
FILE: compiler/src/it/inner-classes-complaint-injection/pom.xml
================================================
4.0.0com.example.dagger.testsinner-classes-complaint-injectionHEAD-SNAPSHOTDagger Integration Test Basic@dagger.groupId@dagger@dagger.version@@dagger.groupId@dagger-compiler@dagger.version@truemaven-compiler-plugin3.11.51.5
================================================
FILE: compiler/src/it/inner-classes-complaint-injection/src/main/java/test/TestApp.java
================================================
/*
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import dagger.Module;
import dagger.ObjectGraph;
import dagger.Provides;
import javax.inject.Inject;
import java.lang.Override;
class TestApp {
class Foo {
@Inject public Foo() {}
}
}
================================================
FILE: compiler/src/it/inner-classes-complaint-injection/verify.bsh
================================================
import dagger.testing.it.BuildLogValidator;
import java.io.File;
File buildLog = new File(basedir, "build.log");
new BuildLogValidator().assertHasText(buildLog, new String[]{
"Can't inject a non-static inner class: test.TestApp.Foo"});
================================================
FILE: compiler/src/it/method-injection/invoker.properties
================================================
invoker.buildResult=failure
================================================
FILE: compiler/src/it/method-injection/pom.xml
================================================
4.0.0com.example.dagger.testsmethod-injectionHEAD-SNAPSHOT@dagger.groupId@dagger@dagger.version@@dagger.groupId@dagger-compiler@dagger.version@truemaven-compiler-plugin3.11.51.5
================================================
FILE: compiler/src/it/method-injection/src/main/java/test/TestApp.java
================================================
/*
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import javax.inject.Inject;
class TestApp {
@Inject public void doThings(Object things) {
}
}
================================================
FILE: compiler/src/it/method-injection/verify.bsh
================================================
import dagger.testing.it.BuildLogValidator;
import java.io.File;
File buildLog = new File(basedir, "build.log");
new BuildLogValidator().assertHasText(buildLog, new String[]{
"Method injection is not supported: test.TestApp.doThings"});
================================================
FILE: compiler/src/it/missing-at-inject-constructor/invoker.properties
================================================
invoker.buildResult=failure
================================================
FILE: compiler/src/it/missing-at-inject-constructor/pom.xml
================================================
4.0.0com.example.dagger.testsmissing-at-inject-constructorHEAD-SNAPSHOTDagger Integration Test Basic@dagger.groupId@dagger@dagger.version@@dagger.groupId@dagger-compiler@dagger.version@truemaven-compiler-plugin3.11.51.5
================================================
FILE: compiler/src/it/missing-at-inject-constructor/src/main/java/test/TestApp.java
================================================
/*
* Copyright (C) 2012 Google, Inc.
* Copyright (C) 2012 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import dagger.Module;
import dagger.ObjectGraph;
import javax.inject.Inject;
class TestApp implements Runnable {
@Inject Dependency dep;
@Override public void run() {
dep.doit();
}
public static void main(String[] args) {
ObjectGraph.create(new TestModule()).get(TestApp.class).run();
}
static class Dependency {
// missing @Inject Dependency() {}
public void doit() { throw AssertionError(); };
}
@Module(injects = TestApp.class)
static class TestModule {
/* missing */ // @Provides Dependency a() { return new Dependency(); }
}
}
================================================
FILE: compiler/src/it/missing-at-inject-constructor/verify.bsh
================================================
import dagger.testing.it.BuildLogValidator;
import java.io.File;
File buildLog = new File(basedir, "build.log");
new BuildLogValidator().assertHasText(buildLog, new String[]{
"No injectable members on test.TestApp.Dependency.",
"required by test.TestApp for test.TestApp.TestModule"});
================================================
FILE: compiler/src/it/module-type-validation/invoker.properties
================================================
invoker.buildResult=failure
================================================
FILE: compiler/src/it/module-type-validation/pom.xml
================================================
4.0.0com.example.dagger.testsmodule-type-validationHEAD-SNAPSHOT@dagger.groupId@dagger@dagger.version@@dagger.groupId@dagger-compiler@dagger.version@truemaven-compiler-plugin3.11.51.5
================================================
FILE: compiler/src/it/module-type-validation/src/main/java/test/TestModule.java
================================================
/*
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import dagger.Module;
@Module
class ThreadModule extends Thread {
}
@Module
enum EnumModule {
}
@Module
interface InterfaceModule {
}
================================================
FILE: compiler/src/it/module-type-validation/verify.bsh
================================================
import dagger.testing.it.BuildLogValidator;
import java.io.File;
File buildLog = new File(basedir, "build.log");
new BuildLogValidator().assertHasText(buildLog, new String[]{
"Modules must not extend from other classes: test.ThreadModule"});
new BuildLogValidator().assertHasText(buildLog, new String[]{
"Modules must be classes: test.EnumModule"});
new BuildLogValidator().assertHasText(buildLog, new String[]{
"Modules must be classes: test.InterfaceModule"});
================================================
FILE: compiler/src/it/multiple-modules-setvalues/pom.xml
================================================
4.0.0com.example.dagger.testsmultiple-modules-setvaluesHEAD-SNAPSHOTDagger Integration Test Basic@dagger.groupId@dagger@dagger.version@@dagger.groupId@dagger-compiler@dagger.version@truemaven-compiler-plugin3.11.51.5
================================================
FILE: compiler/src/it/multiple-modules-setvalues/src/main/java/test/TestApp.java
================================================
/*
* Copyright (C) 2013 Google, Inc.
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import dagger.ObjectGraph;
import dagger.Module;
import dagger.Provides;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import static dagger.Provides.Type.SET;
import static dagger.Provides.Type.SET_VALUES;
/**
* Contributions to {@code SET_VALUES} binding do not affect Set of providers.
*/
class TestApp implements Runnable {
@Inject Set> providers;
@Inject Set strings;
@Override public void run() {
System.out.println(strings);
}
public static void main(String[] args) {
ObjectGraph root = ObjectGraph.create(new RootModule(), new ContributingModule());
root.get(TestApp.class).run();
}
@Module(injects = TestApp.class)
static class RootModule {
@Provides Set> providers() {
return new HashSet>();
}
@Provides(type = SET_VALUES) Set strings() {
return new HashSet();
}
}
@Module(injects = TestApp.class, complete = false)
static class ContributingModule {
@Provides(type = SET) String addToSet() {
return "contributed";
}
}
}
================================================
FILE: compiler/src/it/multiple-provides-methods/pom.xml
================================================
4.0.0com.example.dagger.testsmultiple-provides-methodsHEAD-SNAPSHOTDagger Integration Test Basic@dagger.groupId@dagger@dagger.version@@dagger.groupId@dagger-compiler@dagger.version@truemaven-compiler-plugin3.11.51.5
================================================
FILE: compiler/src/it/multiple-provides-methods/src/main/java/test/TestApp.java
================================================
/*
* Copyright (C) 2013 Square, Inc.
* Copyright (C) 2013 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import dagger.Module;
import dagger.Provides;
import javax.inject.Inject;
class TestApp {
static class NotInjectable {
}
static class InjectableSubclass extends NotInjectable {
@Inject String string;
@Inject Integer integer;
}
@Module(injects = InjectableSubclass.class)
static class TestModule {
@Provides String string() {
return "string";
}
@Provides Integer integer() {
return 5;
}
}
}
================================================
FILE: compiler/src/it/multiple-provides-methods/verify.bsh
================================================
import java.io.File;
File classes = new File(basedir, "target/classes/test/");
File moduleAdapter = new File(classes, "TestApp$TestModule$$ModuleAdapter.class");
if (!moduleAdapter.exists()) throw new Exception("No binding generated for module");
File integerBinding = new File(classes, "TestApp$TestModule$$ModuleAdapter$IntegerProvidesAdapter.class");
if (!integerBinding.exists()) throw new Exception("No binding generated for integer()");
File stringBinding = new File(classes, "TestApp$TestModule$$ModuleAdapter$StringProvidesAdapter.class");
if (!stringBinding.exists()) throw new Exception("No binding generated for string()");
================================================
FILE: compiler/src/it/multiple-qualifiers/invoker.properties
================================================
invoker.buildResult=failure
================================================
FILE: compiler/src/it/multiple-qualifiers/pom.xml
================================================
4.0.0com.example.dagger.testsmultiple-qualifiersHEAD-SNAPSHOT@dagger.groupId@dagger@dagger.version@@dagger.groupId@dagger-compiler@dagger.version@truemaven-compiler-plugin3.11.51.5
================================================
FILE: compiler/src/it/multiple-qualifiers/src/main/java/test/TestApp.java
================================================
/*
* Copyright (C) 2013 Google, Inc.
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import dagger.Module;
import dagger.Provides;
import java.lang.annotation.Retention;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.inject.Qualifier;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
class TestApp {
static class TestClass1 {
@Inject
@MyQualifier1
@MyQualifier2
String field;
}
static class TestClass2 {
String string;
public TestClass2(@MyQualifier1 @MyQualifier2 String constructorParam) {
this.string = string;
}
}
@Module(injects = TestClass1.class)
static class TestModule {
@MyQualifier1
@MyQualifier2
@Provides
String providesString() {
return "string";
}
}
@Qualifier
@Retention(value = RUNTIME)
@interface MyQualifier1 {}
@Qualifier
@Retention(value = RUNTIME)
@interface MyQualifier2 {}
}
================================================
FILE: compiler/src/it/multiple-qualifiers/verify.bsh
================================================
import dagger.testing.it.BuildLogValidator;
import java.io.File;
File buildLog = new File(basedir, "build.log");
new BuildLogValidator().assertHasText(buildLog, new String[]{
"Only one qualifier annotation is allowed per element: test.TestApp.TestClass1.field"});
new BuildLogValidator().assertHasText(buildLog, new String[]{
"Only one qualifier annotation is allowed per element: constructorParam"});
new BuildLogValidator().assertHasText(buildLog, new String[]{
"Only one qualifier annotation is allowed per element: test.TestApp.TestModule.providesString()"});
================================================
FILE: compiler/src/it/private-inject/invoker.properties
================================================
invoker.buildResult=failure
================================================
FILE: compiler/src/it/private-inject/pom.xml
================================================
4.0.0com.example.dagger.testsprivate-injectHEAD-SNAPSHOT@dagger.groupId@dagger@dagger.version@@dagger.groupId@dagger-compiler@dagger.version@truemaven-compiler-plugin3.11.51.5
================================================
FILE: compiler/src/it/private-inject/src/main/java/test/TestApp.java
================================================
/*
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import javax.inject.Inject;
class TestApp {
@Inject private Object nope;
}
================================================
FILE: compiler/src/it/private-inject/src/main/java/test/TestFoo.java
================================================
/*
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import javax.inject.Inject;
class TestFoo {
@Inject private TestFoo() {
}
}
================================================
FILE: compiler/src/it/private-inject/verify.bsh
================================================
import dagger.testing.it.BuildLogValidator;
import java.io.File;
File buildLog = new File(basedir, "build.log");
new BuildLogValidator().assertHasText(buildLog, new String[]{
"Can't inject a private field: test.TestApp.nope"});
new BuildLogValidator().assertHasText(buildLog, new String[]{
"Can't inject a private constructor: test.TestFoo.TestFoo()"});
================================================
FILE: compiler/src/it/provide-provider-or-lazy/invoker.properties
================================================
invoker.buildResult=failure
================================================
FILE: compiler/src/it/provide-provider-or-lazy/pom.xml
================================================
4.0.0com.example.dagger.testsprovide-provider-or-lazyHEAD-SNAPSHOT@dagger.groupId@dagger@dagger.version@@dagger.groupId@dagger-compiler@dagger.version@truemaven-compiler-plugin3.11.51.5
================================================
FILE: compiler/src/it/provide-provider-or-lazy/src/main/java/test/TestModule.java
================================================
/*
* Copyright (C) 2013 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test;
import dagger.Lazy;
import dagger.Module;
import dagger.Provides;
import javax.inject.Provider;
@Module class TestModule {
@Provides Provider