Hi Cristiano, Sounds like the dependency doesn’t have an index of its components (META-INF/sisu/javax.inject.Named) which is needed when using indexed scanning in Sisu.
Maven uses indexed scanning to avoid the cost of repeatedly doing full class path scanning which, while not slow, is not suited for short-lived cases where you want to rapidly setup and tear down the container. If you control the dependency you can add an index by adding the sisu-maven-plugin to its pom.xml: <plugin> <groupId>org.eclipse.sisu</groupId> <artifactId>sisu-maven-plugin</artifactId> <version>0.3.0</version> <executions> <execution> <id>index-project</id> <goals> <goal>main-index</goal> <goal>test-index</goal> <!— only necessary if you have test components to index —> </goals> </execution> </executions> </plugin> If you don’t own the dependency you can instead generate an aggregated index in your plugin's pom.xml: <plugin> <groupId>org.eclipse.sisu</groupId> <artifactId>sisu-maven-plugin</artifactId> <version>0.3.0</version> <executions> <execution> <id>index-dependencies</id> <phase>package</phase> <goals> <goal>index</goal> </goals> <configuration> <!-- same include/exclude settings as maven-dependency-plugin --> </configuration> </execution> </executions> </plugin> which would then index all components found in the plugin and its dependencies (see http://eclipse.org/sisu/docs/api/org.eclipse.sisu.mojos/ for the generated plugin docs) There’s also an annotation processor in “org.eclipse.sisu.inject” which can generate and maintain indexes: http://eclipse.org/sisu/docs/api/org.eclipse.sisu.inject/reference/org/eclipse/sisu/space/SisuIndexAPT6.html Finally you can also build the index yourself, as it’s just a list of fully-qualified class names (one line for each named component). If you’re still having trouble send me a link to the project and I’ll check it out. -- Cheers, Stuart On Tuesday, 17 March 2015 at 01:10, Cristiano Gavião wrote: > Thanks Stuart, > > I tried it and it worked when the MyPojo class was in the same jar as > MyMojo. > > But when I moved MyPojo class to another jar and add that jar as a > dependency of the plugin, I got the following error: > > [WARNING] Error injecting: org.c4biz.tools.build.MyMojo, > > com.google.inject.ProvisionException: Guice provision errors:, , 1) null > > returned by binding at org.eclipse.sisu.wire.LocatorWiring, but parameter > > 4 of org.c4biz.tools.build.MyMojo.<init>() is not @Nullable, while > > locating org.c4biz.tools.build.MyInterface, for parameter 4 at > > org.c4biz.tools.build.MyMojo.<init>(Unknown Source), while locating > > org.c4biz.tools.build.MyMojo, , 1 error, at > > com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1006), > > at > > com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1032), > > at > > org.eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.java:48), > > at > > com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:86), > > at > > com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:55), > > at > > com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70), > > at > > com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:100), > > at > > org.eclipse.sisu.plexus.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:133), > > at > > com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:109), > > at > > com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55), > > at > > com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68), > > at > > com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:47), > > at > > com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:997), > > at > > com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1047), > > at > > com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:993), > > at com.google.inject.Scopes$1$1.get(Scopes.java:59), at > > org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:82), > > at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51), > > at > > org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:260), > > at > > org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:252), > > at > > org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:462), > > at > > org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:119) > > > > > > Then I tried to create a custom binding in a module class as suggested > here: https://wiki.eclipse.org/Sisu/PlexusMigration > > @Named > > public class MyPluginModule extends com.google.inject.AbstractModule { > > public void configure() { > > bind(MyInterface.class).annotatedWith(Names.named("default")).to( > > MyPojo.class); > > } > > > > > But I couldn't get any breakpoint in this configure method to work. so > seems it is not being called. > > anyone have any idea how I can resolve this ? or it is a kind of limitation? > > thanks, > > Cristiano > > 2015-03-16 16:57 GMT-03:00 Stuart McCulloch <mccu...@gmail.com > (mailto:mccu...@gmail.com)>: > > > Assuming you’re using Maven 3.1.1 or later then yes, that should work. > > > > -- > > Cheers, Stuart > > > > > > On Monday, 16 March 2015 at 18:09, Cristiano Gavião wrote: > > > > > Hello, > > > > > > I've create a mojo and set it to use sisu based injection. > > > > > > I added to this mojo a constructor like this: > > > > > > @Inject > > > public MyMojo( RuntimeInformation runtimeInformation, > > > MavenProjectHelper projectHelper, BuildContext > > > buildContextr) { > > > > > > this.buildContext = buildContext; > > > this.runtimeInformation = runtimeInformation; > > > this.projectHelper = projectHelper; > > > } > > > > > > and it worked properly. > > > > > > Now suppose that I have a pojo component annotated with a @Named > > > annotation and it should be consumed by the mojo: > > > > > > @Named > > > public MyPojo{ > > > > > > } > > > > > > Is it possible to inject objects from the maven classes into an instance > > > of this pojo as I did with the mojo above? > > > > > > thanks, > > > > > > Cristiano > > > -- > "Tudo vale a pena se a alma não é pequena..." > >