On Mon, Mar 20, 2017 at 10:56 AM John Ament <john.ament@spartasystems.com> wrote:

For me, that still doesn't discover.  The only thing I can think of is that the JAR that includes StringSearchModelInterpolator may have a beans.xml (does it?)

No. 

I spoke with John off-list; wanted to shed more light on my setup.

I pushed a shaky incomplete version of what I'm doing here: https://github.com/ljnelson/microbean-maven-cdi/blob/master/src/main/java/org/microbean/maven/cdi/MavenExtension.java

The purpose of this frightening :-) extension is uninteresting for the subject under discussion here.  Briefly, it does just enough Plexus annotation processing to be mildly dangerous and break things in cool ways, and no more.

The test method is here: https://github.com/ljnelson/microbean-maven-cdi/blob/master/src/test/java/org/microbean/maven/cdi/TestMavenExtension.java#L65-L70

Note in particular the main method is not in this project.  It is in this one, which is a test-scoped dependency: https://github.com/ljnelson/microbean-main/blob/master/src/main/java/org/microbean/main/Main.java#L125-L134

That project's META-INF/beans.xml has bean discovery set to none (https://github.com/ljnelson/microbean-main/blob/master/src/main/resources/META-INF/beans.xml#L7), since there are no beans in that bean archive (it houses only the main class).  John indicated that this was likely the source of the problem:

"Ok, knowing that this is the setup helps out dramatically.  If I had to guess, the case of having the beans.xml from the main set to none is what's causing this.  I remember Martin mentioned some issues with SE originally when I pushing [sic] that by default we should do discovery.  My guess is that Weld is seeing the beans.xml from the root component [microbean-main] and actually falling back to the CDI 1.0 discovery behavior."

This project's META-INF/beans.xml has bean discovery of "annotated" (https://github.com/ljnelson/microbean-maven-cdi/blob/master/src/main/resources/META-INF/beans.xml#L7), though I confess that's mostly because I just wanted to use the default behavior, not because I carefully considered whether that was something I should use here or not.  In any event, I don't anticipate there being any classes in this project with bean-defining annotations on them, nor any other classes that I would want discovered automatically.

Perhaps I have misunderstood bean discovery: I thought that the discovery mode applied to the bean archive in question alone, not to an aggregate.

Best,
Laird