Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sisu-users] Annotation processor not picking custom qualifiers

Hello Stuart,

In plain Java application everything works as expected, but my application is an OSGi application developed using Eclipse PDE and built using Maven/Tycho.

As you suggested, in my case the index was generated by the Sisu APT and therefore only for those bundles that have a direct dependencies toward Sisu (for example, because they use the Mediator API or the Sisu @Priority annotation).
To the contrary, the sisu-maven-plugin was either not called or its output not collected during build.
I was eventually able to have the index generated by the sisu-maven-plugin included in the bundles by changing the phase from "package" to "compile".

Don't know why it does not work during the "package" phase, maybe it's a problem with Tycho. For the records, we are using Tycho version  0.22.0

Thanks for your help.
GianMaria


-----sisu-users-bounces@xxxxxxxxxxx wrote: -----
To: Sisu project community <sisu-users@xxxxxxxxxxx>
From: Stuart McCulloch
Sent by: sisu-users-bounces@xxxxxxxxxxx
Date: 08/28/2015 01:40PM
Subject: Re: [sisu-users] Annotation processor not picking custom qualifiers

Hi Gian,

This works for me locally with a simple setup, could you provide more details about your pom.xml?  Perhaps a public project that recreates the issue?

Is the library containing MyQualifier a compile dependency of the project where you’re doing the index? The indexer needs access to the annotation bytecode to verify it is a qualifier.

Also note that the APT6 annotation processor behaves slightly differently to the sisu-maven-plugin for performance reasons (because it’s automatically triggered when you compile using Java6+ with Sisu on the project classpath). By default it only looks for @Named, as this is very fast given the information immediately available in APT, but you can tell it to look for other qualifiers with the “qualifiers” option:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <compilerArgs>
            <arg>-Aqualifiers=ALL</arg>
          </compilerArgs>
        </configuration>
      </plugin>

-- 
Cheers, Stuart

On Friday, 28 August 2015 at 09:25, gian.maria.romanato@xxxxxxxxxxxx wrote:


Hello,

I have a custom qualifier defined as follows:

@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public @interface MyQualifier {
}


@MyQualifier
public class MyComponent {

}

And I am using the sisu annotation processor in the maven build of my osgi application to produce the Named index:

            <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>

It turns out that classes annotated @Named show up in the index, while classes annotated @MyQualifier don't.

What am I doing wrong? This was tricky to find out because in development I am using BeanScanning=ON
while when deploying the final application I am using BeanScanning=INDEX under the assumption that the APT
would list in the index file also classes featuring my custom qualifier.


_______________________________________________
sisu-users mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

_______________________________________________
sisu-users mailing list
sisu-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/sisu-users

Back to the top