How to configure maven to generate QueryDSL classes when using both my own AspectJ ITDs and Roo?

2,716 views
Skip to first unread message

Eric B

unread,
Jan 23, 2014, 11:19:47 AM1/23/14
to quer...@googlegroups.com
I'm using Spring ROO and AspectJ to add ITCs to my @RooEntity classes.  I'm using JPA.

I was previously using the apt-maven-plugin to generate the Q classes, but now that I've added AspectJ ITDs to my classes, it no longer seems to work (ie: nothing is generated).
I changed the plugin to use the querydsl-maven-plugin with goal jpa-export, but that too does nothing.

Is there a way to get this to work with both ROO and my own AspectJ ITDs?

Original config that no longer worked after adding my own ITDs:

<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/java</outputDirectory>
For @RooEntity annotated classes
<processor>com.mysema.query.apt.roo.RooAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>



This was changed to:

<plugin>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-maven-plugin</artifactId>
<version>${querydsl.version}</version>
<executions>
<execution>
<goals>
<goal>jpa-export</goal>
</goals>
<configuration>
<processor>com.mysema.query.apt.roo.RooAnnotationProcessor</processor>
<targetFolder>target/generated-sources/java</targetFolder>
<packages>
<package>com.ia.domain</package>
</packages>
</configuration>
</execution>
</executions>
</plugin>    


But still does not work.  I am using QDSL 3.3.0

Am I missing something or doing something wrong?

Thanks,

Eric

Eric B

unread,
Jan 23, 2014, 1:53:19 PM1/23/14
to quer...@googlegroups.com
So I've done some more digging around trying to find out what is happening, and realize I'm in a terrible infinite-loop/Catch-22 situation.

I am using AspectJ and ITDs to weave additional fields into my Entity classes, so I understand I need to use the GenericExporter to generate my Q-classes.  If do I a `maven clean` and clear out the target folder, I have no more generated Q-classes.  So in the process of weaving my fields into my Entity classes, ajc tries to compile all sources weave all aspects in everywhere.  In doing so, if I have any classes that reference the Q classes, it will fail given that these Q classes do not exist.

However, in order to generate the Q classes, I need to have my entity classes woven.  But ajc fails when it tries to weave since it doesn't understand references to the Q classes.

So I'm a bit in an infinite-loop situation here.  The only thing I can imagine is somehow structuring things such that I first weave just the entity classes, then generate the Q classes, then rerun ajc to weave the rest of the application.  But I have no idea how to configure something like that in the pom in order to have ajc only compile/weave in a handful of things first, then run GenericExporter plugin and then rerun ajc all before javac runs.

Am I in an impossible situation here?

Thanks,

Eric

timowest

unread,
Jan 23, 2014, 2:50:39 PM1/23/14
to quer...@googlegroups.com
Hi.

I just realized that the documentation jpa-export usage is incomplete. A phase needs to be given to the execution, since the goal doesn't have a default phase:


<plugin>
  <groupId>com.mysema.querydsl</groupId>
  <artifactId>querydsl-maven-plugin</artifactId>
  <version>${querydsl.version}</version> 
  <executions>
    <execution>   
      <phase>process-classes</phase>

      <goals>
        <goal>jpa-export</goal>       
      </goals>
      <configuration>
        <targetFolder>target/generated-sources/java</targetFolder>
        <packages>
          <package>com.example.domain</package>

        </packages>
      </configuration>     
    </execution>
  </executions>
</plugin>

Your analysis seems to be right. You might need multiple phases of compilation.


On Thursday, January 23, 2014 8:53:19 PM UTC+2, Eric B wrote:
So I've done some more digging around trying to find out what is happening, and realize I'm in a terrible infinite-loop/Catch-22 situation.

I am using AspectJ and ITDs to weave additional fields into my Entity classes, so I understand I need to use the GenericExporter to generate my Q-classes.  If do I a `maven clean` and clear out the target folder, I have no more generated Q-classes.  So in the process of weaving my fields into my Entity classes, ajc tries to compile all sources weave all aspects in everywhere.  In doing so, if I have any classes that reference the Q classes, it will fail given that these Q classes do not exist.

However, in order to generate the Q classes, I need to have my entity classes woven.  But ajc fails when it tries to weave since it doesn't understand references to the Q classes.

So I'm a bit in an infinite-loop situation here.  The only thing I can imagine is somehow structuring things such that I first weave just the entity classes, then generate the Q classes, then rerun ajc to weave the rest of the application.  But I have no idea how to configure something like that in the pom in order to have ajc only compile/weave in a handful of things first, then run GenericExporter plugin and then rerun ajc all before javac runs.

I am not familiar how weaving is configured in Maven, but putting executions into the right order might work.

This might be helpful if you are unsure which Maven buildlifecycle phase to use http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

Timo
 

Dishi Jain

unread,
Feb 16, 2017, 11:09:12 AM2/16/17
to Querydsl
Very well and detailed explanation to this problem. I am going through the same exact issue. Can you please share if you could solve it?
Reply all
Reply to author
Forward
0 new messages