Is it possible to restrict JPAAnnotationProcessor to search for annotations only in a given package?

826 views
Skip to first unread message

Martin Busik

unread,
Feb 24, 2014, 9:09:10 AM2/24/14
to quer...@googlegroups.com
Hello group,
accoring to the docs, the typical usage of the JPAAnnotationProcessor in a maven project looks like:

<plugin>
<groupId>com.mysema.maven</groupId>
...
<configuration>
<outputDirectory>target/generated-sources/querydsl/java</outputDirectory>
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>

I have the impression that the whole classpath is searched for classes with appropriate annotations.
Is it possible to restrict the search to a given package/package subtree, e.g. "org.project.model.*" ?

Martin

timowest

unread,
Feb 24, 2014, 2:20:05 PM2/24/14
to quer...@googlegroups.com
Hi Martin.

The default is that all sources are inspected. For inclusions and exclusions you can use the inclusion/exclusion options as documented here http://www.querydsl.com/static/querydsl/3.3.1/reference/html/ch03s03.html#d0e2019

Br,
Timo

Martin Busik

unread,
Feb 25, 2014, 2:29:00 PM2/25/14
to quer...@googlegroups.com
Hi Timo,


> The default is that all sources are inspected. For inclusions and exclusions you can use the inclusion/exclusion options as documented

Thanks, that is what I've been looking for. Unfortunately, I still do something the wrong way.

We've used querydsl 3.2.3, I startet with:

        <plugin>
          <groupId>com.mysema.maven</groupId>
          <artifactId>apt-maven-plugin</artifactId>
          <version>1.1.1</version>
          <executions>
          <execution>
            <goals>
              <goal>process</goal>
            </goals>

            <configuration>
              <outputDirectory>target/generated-sources/querydsl/java</outputDirectory>
              <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
              <options>
                <querydsl.excludedPackages>java,javax,org,com</querydsl.excludedPackages>
              </options>  
            </configuration>
          </execution>
        </executions>
      </plugin>

Neither querydsl.excludedPackages or querydsl.includedPackages seem to effect something.
Then I've upgraded to querydsl 3.3.1, still without the desired effect.

(Moreover, I get an java.lang.ClassFormatError: "Absent Code attribute in method that is not native or abstract in class file javax/persistence/FetchType
" which is caused by the dependency javax:javaee-api:6.0. This leads me to the assumption, that the querydsl.excludedPackages parameter is not being processed)

The mvn -X output suggest, that the parameter is passed to the processor:

[DEBUG] Configuring mojo com.mysema.maven:apt-maven-plugin:1.1.1:process from plugin realm ClassRealm[plugin>com.mysema.maven:apt-maven-plugin:1.1.1, parent: sun.misc.Launcher$AppClassLoader@5889949a]
[DEBUG] Configuring mojo 'com.mysema.maven:apt-maven-plugin:1.1.1:process' with basic configurator -->
[DEBUG]   (s) options = {querydsl.excludedPackages=java,javax,org,com}
[DEBUG]   (s) outputDirectory = D:\juli\RechteDB\quellen\kern\target\generated-sources\querydsl\java
[DEBUG]   (s) pluginArtifacts = [com.mysema.maven:apt-maven-plugin:maven-plugin:1.1.1:, org.sonatype.plexus:plexus-build-api:jar:0.0.7:compile, org.codehaus.plexus:plexus-utils:jar:1.5.8:compile, backport-util-concurrent:backport-util-concurrent:jar:3.1:compile, org.codehaus.plexus:plexus-interpolation:jar:1.11:compile, junit:junit:jar:3.8.1:compile]
[DEBUG]   (s) processor = com.mysema.query.apt.jpa.JPAAnnotationProcessor
[DEBUG]   (s) project = MavenProject: de.wlps.juli:Kern:0.37.0-SNAPSHOT @ D:\juli\RechteDB\quellen\kern\pom.xml
[DEBUG]   (s) sourceEncoding = UTF-8
[DEBUG] -- end configuration --



Any ideas?

Thanks for your effort,
Martin


timowest

unread,
Feb 26, 2014, 4:20:57 PM2/26/14
to quer...@googlegroups.com
Hi Martin.

I am not able to replicate this issue.

Could you provide a minimal example project which replicates this issue? One JPA annoated entity class + pom.xml should be enough.

Br,
Timo

Martin Busik

unread,
Feb 27, 2014, 12:15:14 PM2/27/14
to quer...@googlegroups.com
Hi Timo,


> Could you provide a minimal example project which replicates this issue?

Please take a look at:
http://www.wlp-systems.de/querydsl-test.zip  (~ 12k - pom.xml, one entity-class and the mvn -X output)

Thanks in advance,
Martin



timowest

unread,
Feb 27, 2014, 3:36:59 PM2/27/14
to quer...@googlegroups.com
Hi.

I replaced the JPA dependency with this one and then it worked. The stub dependency didn't work.

  <dependency>
      <groupId>org.hibernate.javax.persistence</groupId>
      <artifactId>hibernate-jpa-2.0-api</artifactId>
      <version>1.0.0.Final</version>
      <scope>provided</scope>
    </dependency>

Any other issues?

Br,
Timo

Martin Busik

unread,
Mar 10, 2014, 2:24:51 PM3/10/14
to quer...@googlegroups.com
Hi Timo


> I replaced the JPA dependency with this one and then it worked. The stub dependency didn't work.
> Any other issues?

That was the solution. Now it works fine. Thanks a lot.

Martin

Reply all
Reply to author
Forward
0 new messages