Git Product home page Git Product logo

dagger's Introduction

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. Please see the migration guide 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:

<dependencies>
  <dependency>
    <groupId>com.squareup.dagger</groupId>
    <artifactId>dagger</artifactId>
    <version>${dagger.version}</version>
  </dependency>
  <dependency>
    <groupId>com.squareup.dagger</groupId>
    <artifactId>dagger-compiler</artifactId>
    <version>${dagger.version}</version>
    <optional>true</optional>
  </dependency>
</dependencies>

You can also find downloadable .jars on Maven Central. You'll need Dagger, JavaPoet, and javax.inject.

Snapshots of the development version are available in Sonatype's snapshots repository.

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.

dagger's People

Contributors

adennie avatar brettcannon avatar cgruber avatar chiuki avatar crazybob avatar dependabot[bot] avatar edenman avatar gk5885 avatar holmes avatar hugecannon avatar jakewharton avatar jaynewstrom avatar jhump avatar johnjohndoe avatar kryali avatar mescortes avatar nilhcem avatar niqo01 avatar patrickbaumann avatar pforhan avatar pyricau avatar qxo avatar rafaeltoledo avatar rjrjr avatar rtack avatar saisi avatar sgoldfed avatar sheng168 avatar swankjesse avatar tbroyer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dagger's Issues

No injectable members on com.actionbarsherlock.app.SherlockFragmentActivity

I'm trying to use Dagger with ActionBarSherlock 4.2.0.

I'm getting this error:

Caused by: java.lang.IllegalStateException: Errors creating object graph:
No injectable members on com.actionbarsherlock.app.SherlockFragmentActivity. Do you want to add an injectable constructor?
at dagger.internal.RuntimeLinker.reportErrors(RuntimeLinker.java:55)
at dagger.internal.Linker.linkRequested(Linker.java:114)
at dagger.ObjectGraph.getEntryPointBinding(ObjectGraph.java:247)
at dagger.ObjectGraph.inject(ObjectGraph.java:229)
at com.luisdelarosa.MyApplication.inject(MyApplication.java:38)

This worked fine with a regular FragmentActivity. How can I fix this?
Thanks!

'Fast' dependency injection?

Are there any plans to benchmark or put numbers behind the 'fast' claim? I'm curious how it compares to Guice specifically.

When nested overriding modules provide the same binding, outermost override should "win"

A module can't override an included module's provider for a particular type if the included module also overrides a third module. For example:

public static class Thing {
}

@Module
public static class Module1 {
}

@Module(overrides= true, includes = Module1.class)
public static class Module2 {
   @Provides
    public Thing provideThing() {
        return new Thing();
    }
}

@Module(overrides= true, includes = Module2.class)
public static class Module3 {
   @Provides
    public Thing provideThing() {
        return new Thing();
    }
}

This results in "Duplicate bindings for Thing: Module3.provideThing(), Module2.provideThing()." This is because FullGraphProcessor.processCompleteModule detects "clobbering" within the map of override bindings and records it as an error.

It seems like it should be possible to keep track of the hierarchy of the modules, and have the most-overriding module "win".

Explain how to add dagger to Eclipse project

I tried adding dagger to an android eclipse project. dagger-0.9.jar library was added to java build path. Under java compiler annotation processor was enabled, and dagger-compiler-0.9.jar was added as factory path. Consistently get
Internal compiler error: java.lang.NoClassDefFoundError: Could not initialize class dagger.internal.codegen.ProvidesProcessor at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) BuildConfig.java

How about a simple "how-to" on adding dagger support to eclipse - not everyone is using Marven. You guys did a good job explaining how to use the framework but installation instructions suck.

Runtime parent bindings are requested for some compile time bound @Inject annotated classes

I have found a few cases in which start up will take longer than necessary due to dagger reflectively analyze the dependencies of a class.

Two of the cases:

  1. Abstract classes - I have a few abstract classes that have no injected fields. I can't annotate the constructors for these classes with @Inject (dagger won't compile the class if I do) and so I don't know of a way that I can get the annotation process to create an $InjectAdapter class for the abstract base class. So, instead, at runtime I have to reflectively evaluate the inheritance chain when I try to inject an instance of the impl.

  2. Classes that were not compiled using the annotation processor - A few times I use a framework for FrameworkClass and want to inject an instance of MyFrameworkClass (which extends FrameworkClass). FrameworkClass was not written with a DI framework in need and thus I know that there is no need to inject into that class. However, the same issue as above applies - the compile time binding for MyFrameworkClass requests a binding for the supertype.


In general it would be nice if there was a way to opt out classes from needing bindings. For example:

@Module {
  entryPoints = {}...
  noBindingsNeeded = {FrameworkClass.class}
}

Alternatively we could also annotate the class (but I would prefer the above, since to me this is analagous to requesting static injection and belongs on the Module)

@NoSuperInject
class MyFrameworkClass extends FrameworkClass {

}

Don't explode on wildcard types

Given this input:

    @Provides Class<? extends MyInterface> provideClassImpl() {
        return InterfaceImpl.class;
    }

Dagger fails like this:

java.lang.UnsupportedOperationException: Uninjectable type ? extends com.sample.app.di.MyInterface
E/AndroidRuntime( 6701):        at dagger.internal.Keys.typeToString(Keys.java:169)
E/AndroidRuntime( 6701):        at dagger.internal.Keys.typeToString(Keys.java:161)
E/AndroidRuntime( 6701):        at dagger.internal.Keys.get(Keys.java:79)
E/AndroidRuntime( 6701):        at dagger.internal.Keys.get(Keys.java:111)

We should handle wildcard types!

Object Graph validation within Eclipse?

I took the CoffeeModule example and added a random :

@Inject 
String someString;

The FullGraphProcessor reported an error when started from Maven. However, it didn't report any error when started from Eclipse. It actually runs but no error so far.

I'll try to put some breakpoints in it when I have time.

Maybe more descriptive messages and hints in warnings?

For the last days I have been struggling with these kind of warnings below. I probably did something wrong as I couldn't find any similar question on the internet.
I refactored several times but they don't go away.

Where can I find what 'capture#128 of ?' means or why is there an unchecked cast and what should I do?
The line numbers refer to the attach method in the generated files but I cannot see anything peculiar.

I have at this moment 5 of them but I show here a constructor, field and provider

The GraphVizualizer draws something

digraph G1 {
concentrate = true;
DbAdapter -> Context;
}

so something I do right.

Some hints are appreciated.

DbAdapterModule$ModuleAdapter.java:33: warning: [unchecked] unchecked cast
[warn] found : dagger.internal.Binding<capture#128 of ?>
[warn] required: dagger.internal.Binding<android.content.Context>
[warn] p0 = (dagger.internal.Binding<android.content.Context>) linker.requestBinding("android.content.Context", .db.DbAdapterModule.class);
[warn]
^
OptionLoaderDelegate$InjectAdapter.java:14: warning: [unchecked] unchecked cast
[warn] found : dagger.internal.Binding<capture#106 of ?>
[warn] required: dagger.internal.Binding<android.content.Context>
[warn] c0 = (dagger.internal.Binding<android.content.Context>) linker.reques
tBinding("android.content.Context", .loaders.OptionLoaderDelegate.class);
[warn]
^
OptionLoaderDelegate$InjectAdapter.java:15: warning: [unchecked] unchecked cast
[warn] found : dagger.internal.Binding<capture#836 of ?>
[warn] required: dagger.internal.Binding<db.DbAdapter>
[warn] f0 = (dagger.internal.Binding<db.DbAdapter>) linker.requestBinding("db.DbAdapter", loaders.OptionLoaderDelegate.class);
[warn]

Invalid code generated when annotating private fields with @Inject

When annotating a private field with visibility with @Inject, the annotation processor still generates code which directly accesses that field and thus can't be compiled. I think the annotation processor should better create an error clearly indicating the issue. On the other hand injecting private field works when using the reflective plug-in, so maybe the processor could also generate code which accesses the field reflectively in such cases.

Concurrency risk of singleton binding.

Hi, I found TODO in comments:

  @Override public T get() {
      // TODO (cgruber): Fix concurrency risk.
      if (onlyInstance == UNINITIALIZED) {
        onlyInstance = binding.get();
      }
      return (T) onlyInstance;
    }

Then, I tried to fix this problem by double-checking locking pattern. But codestyle checker not allows me to do this. Why not? Alternatives?

TypeNotPresentException when Android component enable set to false

I am using Dagger on Anrdoid and I am having a TypeNotPresentException when one of my Android component is set to false.
Please find below the detailed of what I am doing:
I have two declared components in my AnrdoidManifest:

  • One which is only enable prior to Honeycomb,
  • One enable only on Honeycomb and after.

below an extract of my AndroidManifest.xml

<activity
 android:name=".ui.search.SearchHoneycombActivity"
 android:enabled="@bool/hasHoneycomb">
 <intent-filter>
  <action android:name="android.intent.action.SEARCH" />
 </intent-filter>

 <meta-data
   android:name="android.app.searchable"
   android:resource="@xml/searchable" />
 </activity>
 <activity
  android:name=".ui.search.SearchEclairActivity"
  android:enabled="@bool/priorHoneycomb">
  <intent-filter>
    <action android:name="android.intent.action.SEARCH" />
  </intent-filter>

 <meta-data
   android:name="android.app.searchable"
   android:resource="@xml/searchable" />
</activity>

Here the extract of my only module

@Module(
 entryPoints = {
    SearchHoneycombActivity.class,
    SearchEclairActivity.class,
    ...}})
  public class ProdModule {
 ...

Apparently declaring the entryPoints are mandatory. I was wondering how to deal with this tricky use case?

Spin off a new project to replace Roboguice

I don't know if you guys are already doing this, or have plans to but I'd be really interested in either participating in this, or starting this myself. It would be useful to write a replacement for Roboguice using Dagger instead of Guice.

Exception on provided class

I am trying to implement a provider for the XmlPullParser class, which unfortunately still follows kind of a singleton pattern:

@Provides XmlPullParser provideXmlPullParser() throws XmlPullParserException {
      XmlPullParserFactory xppf = XmlPullParserFactory.newInstance();
      XmlPullParser pullParser = xppf.newPullParser();
      return pullParser;
}

I know that this can be easily solved with a try/catch, but let's say that I want a blowing destruction of my app if the factory cannot provide the parser. Adding the throws produces an Unhandled exception here.

/**
 * Returns the fully provisioned instance satisfying the contract for
 * {@code Provider<org.xmlpull.v1.XmlPullParser>}.
 */
@Override
public org.xmlpull.v1.XmlPullParser get() {
    return module.provideXmlPullParser();
}

The question that arises here is, wouldn't be better to rethrow whatever Exception here?
(note: if you've already talked about this, just never mind...).

Checking the null safety of dagger statically

I've started to annotate dagger/core with nullness annotations of the checker framework. See my changes at https://github.com/reprogrammer/dagger/compare/nullness.

While adding the annotations I ran into cases where the type checker wasn't able to prove the null safety of the program. I've marked these places with @SuppressWarnings("nullness") or assert var != null : "@SuppressWarnings(nullness)";.

At this point, my goal is not necessarily to add the nullness annotations to the upstream dagger. Instead, I'd like to see if annotating the program will find any real problems in dagger.

I'd like to point you to my changes so that you can verify if any of the places that I've marked with @SuppressWarnings("nullness") or assert var != null : "@SuppressWarnings(nullness)"; may trigger a run time exception because of the null unsafety of the program.

Doubled up errors at codegen time

@JakeWharton found this:

[ERROR] error: Classes declaring @Provides methods must not be private or abstract: com.squareup.tape.sample.SampleApplication.SampleModule
[ERROR] error: Classes declaring @Provides methods must not be private or abstract: com.squareup.tape.sample.SampleApplication.SampleModule
[INFO] 2 errors

Annotating method parameters with @Inject results in ClassCastException

When putting the @Inject annotation to a method parameter a ClassCastException is thrown in InjectProcessor#getInjectedClasses():

java.lang.ClassCastException: com.sun.tools.javac.code.Symbol$MethodSymbol cannot be cast to javax.lang.model.element.TypeElement
at dagger.internal.codegen.InjectProcessor.getInjectedClasses(InjectProcessor.java:76)
at dagger.internal.codegen.InjectProcessor.process(InjectProcessor.java:58)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:793)

That exception hides the error which would be thrown by the compiler due to the annotation being given at an unsupported element type ("annotation type not applicable to this kind of declaration").

Dagger doesn't play nice with other code generating annotation processors.

If source generated by another processor is depended upon by code that dagger processes, dagger's annotation processors will throw uncaught IllegalStateExceptions and fail on the first code generation pass.

For example:

Take this constructor that exists upon entering annotation processing:

@Inject
public SomeHandWrittenClass(final GeneratedClass dependency)
{/* ... */}

Where GeneratedClass and the module that provides it are generated on the first code generation pass. The following stack trace is produced (in an ant build):

[javac] An annotation processor threw an uncaught exception.
[javac] Consult the following stack trace for details.
[javac] java.lang.UnsupportedOperationException: Unexpected TypeKind ERROR for GeneratedClass
[javac]     at dagger.internal.codegen.CodeGen$1.defaultAction(CodeGen.java:147)
[javac]     at dagger.internal.codegen.CodeGen$1.defaultAction(CodeGen.java:117)
[javac]     at javax.lang.model.util.SimpleTypeVisitor6.visitError(SimpleTypeVisitor6.java:146)
[javac]     at com.sun.tools.javac.code.Type$ErrorType.accept(Type.java:1201)
[javac]     at dagger.internal.codegen.CodeGen.typeToString(CodeGen.java:117)
[javac]     at dagger.internal.codegen.CodeGen.typeToString(CodeGen.java:91)
[javac]     at dagger.internal.codegen.InjectProcessor.writeInjectAdapter(InjectProcessor.java:185)
[javac]     at dagger.internal.codegen.InjectProcessor.process(InjectProcessor.java:60)
[javac]     at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:627)
[javac]     at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:556)
[javac]     at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:701)
[javac]     at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:987)
[javac]     at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
[javac]     at com.sun.tools.javac.main.Main.compile(Main.java:353)
[javac]     at com.sun.tools.javac.main.Main.compile(Main.java:279)
[javac]     at com.sun.tools.javac.main.Main.compile(Main.java:270)
[javac]     at com.sun.tools.javac.Main.compile(Main.java:69)
[javac]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[javac]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[javac]     at java.lang.reflect.Method.invoke(Method.java:597)
[javac]     at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:56)
[javac]     at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1134)
[javac]     at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:912)
[javac]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[javac]     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
[javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[javac]     at java.lang.reflect.Method.invoke(Method.java:597)
[javac]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[javac]     at org.apache.tools.ant.Task.perform(Task.java:348)
[javac]     at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
[javac]     at com.android.ant.IfElseTask.execute(IfElseTask.java:120)
[javac]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[javac]     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
[javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[javac]     at java.lang.reflect.Method.invoke(Method.java:597)
[javac]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[javac]     at org.apache.tools.ant.Task.perform(Task.java:348)
[javac]     at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
[javac]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[javac]     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
[javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[javac]     at java.lang.reflect.Method.invoke(Method.java:597)
[javac]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[javac]     at org.apache.tools.ant.Task.perform(Task.java:348)
[javac]     at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:398)
[javac]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[javac]     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
[javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[javac]     at java.lang.reflect.Method.invoke(Method.java:597)
[javac]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[javac]     at org.apache.tools.ant.Task.perform(Task.java:348)
[javac]     at org.apache.tools.ant.Target.execute(Target.java:390)
[javac]     at org.apache.tools.ant.Target.performTasks(Target.java:411)
[javac]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
[javac]     at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
[javac]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[javac]     at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
[javac]     at org.apache.tools.ant.Main.runBuild(Main.java:809)
[javac]     at org.apache.tools.ant.Main.startAnt(Main.java:217)
[javac]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
[javac]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

dagger-androidmanifest-plugin fully working as a Maven plugin ?

#42 changes the dagger-androidmanifest-plugin packaging to be a real maven plugin. With that, I saw the ActivitiesModule.java file being generated.

However, this newly generated file wasn't picked up by the annotation processors, so it's not really useful yet.

I read in #33 that you use the maven-exec-plugin internally to get it working and intend to directly use the plugin, as described in the corresponding Readme.md. Can't wait to see what I missed :) .

Another approach could be to parse the AndroidManifest.xml file when running the annotation processors, rather then at build time.

It kind of make sense, because the AndroidManifest.xml file is a config file for the processors.

It's not straightforward though, because the AndroidManifest.xml file is not a resource file. Theoretically, it can't be accessed from the annotation processors. In practice, it can be done through a dirty hack (that's what we do in AA). There may be better ways...

Errors during annotation processing should be created via the Messager API

In AtInjectBinding several types of error are reported by throwing an IllegalArgumentException. This causes theses errors not to show properly up when using the annotation processor in Eclipse. More specifically, these errors are only shown in the Error Log but not in the Markers view or within the concerned source files.

This problem can be addressed by using the Messager API of the processing environment for reporting errors/warnings. While this already is done in InjectProcessor#error(), the concerned element (and annotation) is not passed when invoking processingEnv.getMessager().printMessage(). This again causes these errors to only show up in Eclipse's error log. When invoking one of the overloaded printMessage() methods which accept the concerned element/annotation/annotation value, any reported problems will correctly show up as warning or error in the problem markers view and also will be marked with a red wavy line at the concerned element in the editor area.

Create a Google group

Hi Jesse,

Thanks for developing this. I'm glad I didn't work on the same thing simultaneously. Would you mind adding a Google Group for this?

I assume this is only usable via Maven as of now? I use Eclipse. I'm not sure how hard it would be to turn it into an Eclipse plugin, but it sure would be helpful.

Jeff

Why does package naming violate Maven groupId?

While the POM contains a common groupId "com.squareup" and artifactId "dagger", the package name is simply "dagger".
This is highly uncommon and adds risk of package name or dependency clashes you'd avoid, if the package was properly named.

ReflectivePlugin used after code generation in case when overrides class without dependencies.

If some class A, which have dependencies, extends class B, and class B have no dependencies and this class is not a platform type. In this case after code generation A$InjectAdapter will request inject adapter for class B, but it no generated, so it will be created by ReflectivePlugin.
I believe that is not expected behavior. I suggest to check class for the presence of dependencies while inject adapter generates.

Generated ModuleAdapter has wrong camelcase name for inner static binding classes

In the Coffee example, looking at the generated code :

DripCoffeeModule$ModuleAdapter:

 map.put("coffee.Heater", new provideHeaterBinding(module));

and :

private static class provideHeaterBinding
      extends Binding<Heater> {
//...
}

Not much of a problem, just thought that even generated code should follow the rules ;-) .

The problem comes from dagger.internal.codegen.ProvidesProcessor.writeModuleAdapter(TypeElement, List<ExecutableElement>) :

    for (ExecutableElement providerMethod : providerMethods) {
      if (providerMethod.getAnnotation(OneOf.class) != null) {
        String key = GeneratorKeys.getElementKey(providerMethod);
        writer.statement("SetBinding.add(map, %s, new %s(module))", JavaWriter.stringLiteral(key),
            providerMethod.getSimpleName().toString() + "Binding");
      } else {
        String key = GeneratorKeys.get(providerMethod);
        writer.statement("map.put(%s, new %s(module))", JavaWriter.stringLiteral(key),
            providerMethod.getSimpleName().toString() + "Binding");
      }
    }

and dagger.internal.codegen.ProvidesProcessor.writeBindingClass(JavaWriter, ExecutableElement) :

String className = providerMethod.getSimpleName() + "Binding";

Just need to capitalize the first letter.

Question: do you think it's possible to create a C++ version of Dagger?

The unique thing about Dagger (compared to all other dependency injection frameworks) is that it is completely static, i.e., works at compile time and not at runtime by inspecting the object's type.
Therefore, Dagger should be applicable to C++.
However, I'm not familiar with the internals of Dagger, therefore I wanted to ask the creators/owners if they think it is possible, and what would be the challenges. I would love to start a discussion, and if people are excited, then maybe create a branch :)

I've searched around and there isn't a single decent dependency injection framework for C++. (Mocking using googlemock for C++ is great.)
The biggest benefit of using Dagger over manual dependency injection (DI) would be the "Provider" template that would auto-generate all the factories (maintaining factories is the nightmare of manual DI).

Code generation crushes when injecting to generic classes

I have tried to reproduce following injections:
https://github.com/emmby/roboguice/blob/master/roboguice/src/main/java/roboguice/util/RoboAsyncTask.java

So there is generic SafeAsyncTask<T> and i'd like to make injectable child class.

During code generation process I get following error:

    [javac] An annotation processor threw an uncaught exception.
    [javac] Consult the following stack trace for details.
    [javac] java.lang.IllegalArgumentException: Unexpected key: me.lyft.android.tasks.SafeAsyncTask<>
    [javac]     at dagger.internal.codegen.GraphVisualizer.shortName(GraphVisualizer.java:99)
    [javac]     at dagger.internal.codegen.GraphVisualizer.buildNamesIndex(GraphVisualizer.java:69)
    [javac]     at dagger.internal.codegen.GraphVisualizer.write(GraphVisualizer.java:46)
    [javac]     at dagger.internal.codegen.FullGraphProcessor.writeDotFile(FullGraphProcessor.java:204)
    [javac]     at dagger.internal.codegen.FullGraphProcessor.process(FullGraphProcessor.java:67)
    [javac]     at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:627)
    [javac]     at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:556)
    [javac]     at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:701)
    [javac]     at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:987)
    [javac]     at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
    [javac]     at com.sun.tools.javac.main.Main.compile(Main.java:353)
    [javac]     at com.sun.tools.javac.main.Main.compile(Main.java:279)
    [javac]     at com.sun.tools.javac.main.Main.compile(Main.java:270)
    [javac]     at com.sun.tools.javac.Main.compile(Main.java:69)
    [javac]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [javac]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [javac]     at java.lang.reflect.Method.invoke(Method.java:597)
    [javac]     at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:56)
    [javac]     at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1134)
    [javac]     at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:912)
    [javac]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    [javac]     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [javac]     at java.lang.reflect.Method.invoke(Method.java:597)
    [javac]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [javac]     at org.apache.tools.ant.Task.perform(Task.java:348)
    [javac]     at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    [javac]     at com.android.ant.IfElseTask.execute(IfElseTask.java:120)
    [javac]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    [javac]     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [javac]     at java.lang.reflect.Method.invoke(Method.java:597)
    [javac]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [javac]     at org.apache.tools.ant.Task.perform(Task.java:348)
    [javac]     at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    [javac]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    [javac]     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [javac]     at java.lang.reflect.Method.invoke(Method.java:597)
    [javac]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [javac]     at org.apache.tools.ant.Task.perform(Task.java:348)
    [javac]     at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:398)
    [javac]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    [javac]     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [javac]     at java.lang.reflect.Method.invoke(Method.java:597)
    [javac]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [javac]     at org.apache.tools.ant.Task.perform(Task.java:348)
    [javac]     at org.apache.tools.ant.Target.execute(Target.java:390)
    [javac]     at org.apache.tools.ant.Target.performTasks(Target.java:411)
    [javac]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    [javac]     at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    [javac]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    [javac]     at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    [javac]     at org.apache.tools.ant.Main.runBuild(Main.java:809)
    [javac]     at org.apache.tools.ant.Main.startAnt(Main.java:217)
    [javac]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    [javac]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

NoSuchElementException in Linker

No idea how to reproduce, but we've seen this stacktrace a few times in the wild:

java.util.NoSuchElementException
java.util.LinkedList:LinkedList.java:690:in `removeFirstImpl'
java.util.LinkedList:LinkedList.java:677:in `removeFirst'
java.util.LinkedList:LinkedList.java:896:in `poll'
dagger.internal.Linker:Linker.java:79:in `linkRequested'
dagger.ObjectGraph:ObjectGraph.java:224:in `inject'
com.squareup.SquareApplication:SquareApplication.java:55:in `inject'
com.squareup.cardcase.broadcasters.NetworkStateChangeBroadcaster:NetworkStateChangeBroadcaster.java:26:in `onReceive'
android.app.ActivityThread:ActivityThread.java:2103:in `handleReceiver'
---- caused: java.lang.RuntimeException: Unable to start receiver com.squareup.cardcase.broadcasters.NetworkStateChangeBroadcaster: java.util.NoSuchElementException:in `----'
android.app.ActivityThread:ActivityThread.java:2144:in `handleReceiver'
android.app.ActivityThread:ActivityThread.java:135:in `access$2400'
android.app.ActivityThread$H:ActivityThread.java:1114:in `handleMessage'
android.os.Handler:Handler.java:99:in `dispatchMessage'
android.os.Looper:Looper.java:150:in `loop'
android.app.ActivityThread:ActivityThread.java:4385:in `main'
java.lang.reflect.Method:Method.java:-2:in `invokeNative'
java.lang.reflect.Method:Method.java:507:in `invoke'
com.android.internal.os.ZygoteInit$MethodAndArgsCaller:ZygoteInit.java:849:in `run'
com.android.internal.os.ZygoteInit:ZygoteInit.java:607:in `main'
dalvik.system.NativeStart:NativeStart.java:-2:in `main'

Entry points cannot be interfaces

If a module lists an interface (as opposed to a concrete class) as an entry point, then that graph will always fail validation. It is also impossible to invoke plus on such a graph. This is a problem for any project that expects to be able to invoke objectGraph.get(Heater.class) and get an ElectricHeater instance back.

The validation tries to find a binding for each entry point, but with the "members/" prefix. When that is not found, it tries to create a JIT binding. If the entry point is an interface, then the ReflectivePlugin refuses to create the binding, (see ReflectivePlugin.java:42). If the entry point is not an interface, then a ReflectiveAtInjectBinding is created, even if the type does not have an injectable constructor. This JIT binding appears to be spurious, because the provider method is always the one invoked when an instance needs to be provided.

In the following minimal test case, the testValidateAbstractClassEntryPoint() succeeds as it should, but testValidateInterfaceEntryPoint() throws an IllegalStateException.

public class DaggerTest {

  public static abstract class AbstractClass { }
  public static class Extension extends AbstractClass { }

  @Module(entryPoints = AbstractClass.class)
  public static class AbstractClassModule {
    @Provides public AbstractClass provideAbstractClass() {
      return new Extension();
    }
  }

  @Test
  public void testValidateAbstractClassEntryPoint() {
    ObjectGraph objectGraph = ObjectGraph.create(AbstractClassModule.class);
    objectGraph.validate();
  }

  public interface Interface { }
  public static class Implementation implements Interface { }

  @Module(entryPoints = Interface.class)
  public static class InterfaceModule {
    @Provides public Interface provideInterface() {
      return new Implementation();
    }
  }

  @Test//(expected = IllegalStateException.class)
  public void testValidateInterfaceEntryPoint() {
    ObjectGraph objectGraph = ObjectGraph.create(InterfaceModule.class);
    objectGraph.validate();
  }

}

NPE in dot writing

java.lang.NullPointerException
at dagger.internal.codegen.DotWriter.nodeName(DotWriter.java:120)
at dagger.internal.codegen.DotWriter.edge(DotWriter.java:69)
at dagger.internal.codegen.GraphVisualizer.write(GraphVisualizer.java:56)
at dagger.internal.codegen.FullGraphProcessor.writeDotFile(FullGraphProcessor.java:204)
at dagger.internal.codegen.FullGraphProcessor.process(FullGraphProcessor.java:67)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:627)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:556)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:701)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:987)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:279)
at com.sun.tools.javac.main.Main.compile(Main.java:270)
at com.sun.tools.javac.Main.compile(Main.java:87)

abstract provides methods

This is probably more a usage question than an issue.

I've got something goofy in denominator wrt dagger. Basically a Provider (like route53) is a dagger module. I want to make it easy to implement and inject provider metadata without having to know too many details. For example, our DNSApiManager uses Provider (a dagger module) directly.

    @Inject
    DNSApiManager(Provider provider, DNSApi api, Closeable closer) {
        this.provider = provider;
        this.api = api;
        this.closer = closer;
    }

Provider defines some things like its name and the type of credentials it can accept as abstract methods. I'd prefer this to be an interface actually.

Anyway, these are needed pre-dagger, as that metadata is used to determine what other dagger modules are needed (chicken-egg problem).

ex. the module list for the graph includes the provider module, and conditionally other modules.
if (provider.defaultCredentialSupplier().isPresent()) { modulesForGraph.add(credentials(provider.defaultCredentialSupplier().get()));

I can't put @provides on on Provider as it is an abstract class, so I ask users to do something in their subclass which is smelly.

@Provides
Provider provideThis() {
   return this;
}

I'd like to eliminate the provideThis() and could if @Provides` abstract methods were somehow possible. Another way would be to refactor denominator to unwind this in some way I'm not aware of.

Thoughts?

Plugins for sbt?

Hi,
I see that the plugins are for maven. Do you plan supporting sbt too?

Example use of the visualized DAG output

Jesse's talk at QCon talk touched on a really great feature that visualizes the DAG. Maybe it's just me, but I didn't know I was looking for a dot file nor did I know where the mythical file was saved. After looking through the code I was able to track it down. It would be helpful to showcase this neat feature on the website.

By default, the dot file is saved as:

target/classes/com/yourapp/YourappModule.dot

You can view this file with GraphViz here http://www.graphviz.org/Download..php.

Plugin architecture ?

Hi guys,

A bit of context first... this is a long issue, I had rather sent it on a mailing list, but there's none yet.

I just discovered Dagger : http://www.infoq.com/news/2012/10/dagger .

As you may be aware of, I am the creator of http://androidannotations.org. AA started as a framework providing some of the RoboGuice goodness (@ViewById, etc), at compile time, using annotation processing and code generation. It then added more goodness (@click, @background / @UiThread), and we finally went down the road of dependency injection.

The JSR 330 states :

An injector could rely on reflection or code generation. An injector that uses compile-time code generation may not even have its own run time representation.

Until now, I hadn't seen any implementation doing that. That's one of the ideas we had with AA, but we didn't go in that direction yet.

I know that Dagger is quite likely to be successful, because of its intrinsic qualities and also because there's @JakeWharton and Square behind it :) .

Although you are taking a different path, which means different features and advantages / disadvantages, I also realize that some of the things we do are quite common.

Aside from the implementation details, the main difference in AA is that it generates subclasses to override some methods and add specific behavior. We also do field injection that way, but that's just because the subclass is already there, we could have used package trojans.

I'm certainly not going to stop working on AA, but I also realize that maybe we could leverage some of your work. One way could be to steal some architecture ideas / code pieces that are really good. But an even more interesting way could be to see if there's room to build AA behavior on top of Dagger.

Hence the question : is there any room for such a plugin architecture on top of Dagger ? Basically the ability to extend the processor / add another processor, that would generate subclasses.

Cross dependency injection

First, thanks for this library!

I am learning Dagger and Dependency Injection design pattern in general.
I was wondering how would you solve cross dependency injections with Dagger? Maybe this question show a misunderstanding of the dependency injection design pattern or an architecture design issue in my code.
The code below represent what I am trying to do but obviously crashing in StackOverflow

public class SessionController {
    private final SyncController mSyncController;
    @Inject
    public SessionController(final Context context, SyncController syncController {
        mSyncController = syncController;
    }
}
public class SyncController {
    private final SessionController mSessionController;
    @Inject
    public SyncController(final Context context, SessionController sessionController {
        mSessionController = sessionController;
    }
}

public class ProdModule {
    private final Context appContext;

    public ProdModule(final Context appContext) {
        this.appContext = appContext;
    }

    @Provides
    @Singleton
    Bus provideBus() {
        return new Bus();
    }

    @Provides
    @Singleton
    Controller provideSyncController(Bus bus, SessionController sessionController) {
        return new SyncController(bus, sessionController);
    }

    @Provides
    @Singleton
    SessionController provideSessionController(Controller controller, SyncController syncController) {
        return new SessionController(appContext, syncController);
    }
}

Annotation processor should raise an error if there is a injectable constructor and a provider method

I have a type with an injectable constructor:

public class Foo {
    @Inject public Foo() {}
}

And also a provider method for that type:

@Module
public class FooModule {
    @Provides Foo provideFoo() {
       return new Foo();
    }
}

In this case the object returned from the provider method is used for injection, but I think an error should be raised (as is the case when there are several provider methods returning the same type) since it's not obvious which of the both is used for injection.

Generated ModuleAdapter bindings missing when multiple Provides methods are defined.

Generated ModuleAdapter currently only has one binding in getBindingsMethod()

The error is in ProvidesProcessor.java:132 in providerMethodsByClass(),
the code should be :
List methods = result.get(type.toString());
if (methods == null) {
methods = new ArrayList();
result.put(type.toString(), methods);
}

instead of:
List methods = result.get(type);
if (methods == null) {
methods = new ArrayList();
result.put(type.toString(), methods);
}

@Module(entrypoints=) either needs a rename or better documentation.

I've had to explain entryPoints several times, and it seems to confuse some people, as they keep thinking entry-points as being not graph entry points (roots) but application entry points.

We can better document it (i have some thoughts) but renaming entryPoints to graphRoots was suggested to me. Thoughts? Agree? Disagree? Alternative?

mvn validate and test fails

Hi,
I downloaded dagger and wanted to build it with mavan, but it fails both to validate and test.
I also couldn't build the example directory.

[ERROR] Failed to execute goal on project dagger-androidmanifest-plugin: Could n
ot resolve dependencies for project com.squareup:dagger-androidmanifest-plugin:m
aven-plugin:1.0-SNAPSHOT: Could not find artifact com.squareup:dagger-compiler:j
ar:1.0-SNAPSHOT in sonatype-nexus-snapshots (https://oss.sonatype.org/content/re
positories/snapshots) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyReso
lutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command

[ERROR] mvn -rf :dagger-androidmanifest-plugin
C:\Users\yzibin\workspace\dagger-master>mvn validate

The example directory:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.861s
[INFO] Finished at: Sat Nov 10 15:14:00 EST 2012
[INFO] Final Memory: 5M/73M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.
5:compile (default-compile) on project dagger-example: Execution default-compile
of goal org.apache.maven.plugins:maven-compiler-plugin:2.5:compile failed: Plug
in org.apache.maven.plugins:maven-compiler-plugin:2.5 or one of its dependencies
could not be resolved: Could not find artifact com.squareup:dagger-compiler:jar
:1.0-SNAPSHOT in apache.snapshots (http://repository.apache.org/snapshots) -> [H
elp 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResoluti
onException
C:\Users\yzibin\workspace\dagger-master\example>

Here is all I had on my console:
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-mo
dule-fml/1.0/doxia-module-fml-1.0.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-dec
oration-model/1.0/doxia-decoration-model-1.0.jar (48 KB at 253.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-mo
dule-xdoc/1.0/doxia-module-xdoc-1.0.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-sit
e-renderer/1.0/doxia-site-renderer-1.0.jar (46 KB at 229.4 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-mo
dule-xhtml/1.0/doxia-module-xhtml-1.0.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-cor
e/1.0/doxia-core-1.0.jar (54 KB at 256.8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/m
aven-plugin-tools-api/2.8/maven-plugin-tools-api-2.8.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-mod
ule-fml/1.0/doxia-module-fml-1.0.jar (19 KB at 148.4 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/net/sf/jtidy/jtidy/r938/jtidy-r
938.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-mod
ule-xdoc/1.0/doxia-module-xdoc-1.0.jar (28 KB at 271.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/reporting/mave
n-reporting-impl/2.0.5/maven-reporting-impl-2.0.5.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-mod
ule-apt/1.0/doxia-module-apt-1.0.jar (46 KB at 129.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-d
oxia-tools/1.0.2/maven-doxia-tools-1.0.2.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-mod
ule-xhtml/1.0/doxia-module-xhtml-1.0.jar (22 KB at 122.4 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/commons-logging/commons-logging
/1.0.4/commons-logging-1.0.4.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/reporting/maven
-reporting-impl/2.0.5/maven-reporting-impl-2.0.5.jar (21 KB at 156.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/m
aven-plugin-tools-java/2.8/maven-plugin-tools-java-2.8.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/ma
ven-plugin-tools-api/2.8/maven-plugin-tools-api-2.8.jar (55 KB at 213.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/com/thoughtworks/qdox/qdox/1.11
/qdox-1.11.jar
Downloaded: http://repo.maven.apache.org/maven2/net/sf/jtidy/jtidy/r938/jtidy-r9
38.jar (245 KB at 1029.8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/m
aven-plugin-tools-beanshell/2.8/maven-plugin-tools-beanshell-2.8.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-do
xia-tools/1.0.2/maven-doxia-tools-1.0.2.jar (41 KB at 286.6 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/commons-logging/commons-logging/
1.0.4/commons-logging-1.0.4.jar (38 KB at 297.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/bsh/bsh/1.3.0/bsh-1.3.0.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/ma
ven-plugin-tools-java/2.8/maven-plugin-tools-java-2.8.jar (17 KB at 67.6 KB/sec)

Downloaded: http://repo.maven.apache.org/maven2/bsh/bsh/1.3.0/bsh-1.3.0.jar (237
KB at 997.8 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/com/thoughtworks/qdox/qdox/1.11/
qdox-1.11.jar (172 KB at 622.1 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/ma
ven-plugin-tools-beanshell/2.8/maven-plugin-tools-beanshell-2.8.jar (14 KB at 25
.8 KB/sec)
[WARNING]

Goal prefix is specified as: 'dagger'. Maven currently expects it to be 'dagger-
androidmanifest'.

[INFO] Using 'UTF-8' encoding to read mojo metadata.
[INFO] Applying mojo extractor for language: java
[INFO] Mojo extractor for language: java found 1 mojo descriptors.
[INFO] Applying mojo extractor for language: bsh
[INFO] Mojo extractor for language: bsh found 0 mojo descriptors.
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ dagger-and
roidmanifest-plugin ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\yzibin\workspace\dagger-mast
er\androidmanifest\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5:compile (default-compile) @ dagger-androidm
anifest-plugin ---
[INFO] Compiling 3 source files to C:\Users\yzibin\workspace\dagger-master\andro
idmanifest\target\classes
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Dagger Example 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]

[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ dagger-example --

[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ dagger-exa
mple ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\yzibin\workspace\dagger-mast
er\example\src\main\resources
[INFO]

[INFO] --- maven-compiler-plugin:2.5:compile (default-compile) @ dagger-example

[INFO] Compiling 8 source files to C:\Users\yzibin\workspace\dagger-master\examp
le\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Dagger (Parent) ................................... SUCCESS [0.740s]
[INFO] Dagger ............................................ SUCCESS [4.155s]
[INFO] Dagger Compiler ................................... SUCCESS [0.639s]
[INFO] Dagger AndroidManifest.xml Module Generator ....... SUCCESS [7.273s]
[INFO] Dagger Example .................................... SUCCESS [0.947s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.960s
[INFO] Finished at: Sat Nov 10 15:11:27 EST 2012
[INFO] Final Memory: 13M/68M
[INFO] ------------------------------------------------------------------------
C:\Users\yzibin\workspace\dagger-master>mvn validate
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Dagger (Parent)
[INFO] Dagger
[INFO] Dagger Compiler
[INFO] Dagger AndroidManifest.xml Module Generator
[INFO] Dagger Example
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Dagger (Parent) 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ dagger-parent ---

[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Dagger 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ dagger ---
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Dagger Compiler 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]

[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ dagger-compiler -

[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Dagger AndroidManifest.xml Module Generator 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Dagger (Parent) ................................... SUCCESS [0.703s]
[INFO] Dagger ............................................ SUCCESS [0.037s]
[INFO] Dagger Compiler ................................... SUCCESS [0.070s]
[INFO] Dagger AndroidManifest.xml Module Generator ....... FAILURE [0.296s]
[INFO] Dagger Example .................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.306s
[INFO] Finished at: Sat Nov 10 15:11:33 EST 2012
[INFO] Final Memory: 4M/75M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project dagger-androidmanifest-plugin: Could n
ot resolve dependencies for project com.squareup:dagger-androidmanifest-plugin:m
aven-plugin:1.0-SNAPSHOT: Failure to find com.squareup:dagger-compiler:jar:1.0-S
NAPSHOT in https://oss.sonatype.org/content/repositories/snapshots was cached in
the local repository, resolution will not be reattempted until the update inter
val of sonatype-nexus-snapshots has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyReso
lutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command

[ERROR] mvn -rf :dagger-androidmanifest-plugin
C:\Users\yzibin\workspace\dagger-master>mvn test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Dagger (Parent)
[INFO] Dagger
[INFO] Dagger Compiler
[INFO] Dagger AndroidManifest.xml Module Generator
[INFO] Dagger Example
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Dagger (Parent) 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ dagger-parent ---

[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Dagger 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ dagger ---
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ dagger ---

[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\yzibin\workspace\dagger-mast
er\core\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5:compile (default-compile) @ dagger ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ da
gger ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\yzibin\workspace\dagger-mast
er\core\src\test\resources
[INFO]

[INFO] --- maven-compiler-plugin:2.5:testCompile (default-testCompile) @ dagger

[INFO] Compiling 10 source files to C:\Users\yzibin\workspace\dagger-master\core
\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ dagger ---
[INFO] Surefire report directory: C:\Users\yzibin\workspace\dagger-master\core\t
arget\surefire-reports


T E S T S

Running dagger.ExtensionTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.112 sec
Running dagger.InjectionOfLazyTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.017 sec
Running dagger.InjectionTest
Tests run: 31, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.113 sec <<< F
AILURE!
Running dagger.InjectStaticsTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.009 sec
Running dagger.internal.KeysTest
Tests run: 18, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.013 sec
Running dagger.LazyInjectionTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.01 sec
Running dagger.MembersInjectorTest
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.037 sec
Running dagger.ModuleIncludesTest
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.029 sec
Running dagger.ProblemDetectorTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.009 sec
Running dagger.SetBindingTest
Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.026 sec

Results :

Tests in error:
noConstructorInjectionsForClassesWithTypeParameters(dagger.InjectionTest): dag
ger.InjectionTest and dagger.InjectionTest$1Parameterized disagree on InnerClass
es attribute

Tests run: 89, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Dagger (Parent) ................................... SUCCESS [0.703s]
[INFO] Dagger ............................................ FAILURE [3.255s]
[INFO] Dagger Compiler ................................... SKIPPED
[INFO] Dagger AndroidManifest.xml Module Generator ....... SKIPPED
[INFO] Dagger Example .................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.167s
[INFO] Finished at: Sat Nov 10 15:11:48 EST 2012
[INFO] Final Memory: 9M/103M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
10:test (default-test) on project dagger: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\yzibin\workspace\dagger-master\core\target\sure
fire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
eption
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command

[ERROR] mvn -rf :dagger
C:\Users\yzibin\workspace\dagger-master>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.