Question

I am fixing a legacy project that uses Querydsl apt. For some reason the apt-maven-plugin started to fail. The only workaround I found was to use the alter ego maven-processor-plugin.

I have reinstalled maven, eclipse and M2E with not much success. The maven-apt-plugin is unable to create the Q classes under /target/generated-sources/metamodel.

edit: adding debug from maven

[DEBUG] Configuring mojo com.mysema.maven:apt-maven-plugin:1.0.8:process from pl
ugin realm ClassRealm[plugin>com.mysema.maven:apt-maven-plugin:1.0.8, parent: su
n.misc.Launcher$AppClassLoader@6d9bf996]
[DEBUG] Configuring mojo 'com.mysema.maven:apt-maven-plugin:1.0.8:process' with
basic configurator -->
[DEBUG]   (s) logOnlyOnError = true
[DEBUG]   (s) outputDirectory = C:\DEV\myproject\mainstuff\mainstuff-jpa\target\generate
d-sources\metamodel
[DEBUG]   (s) pluginArtifacts = [com.mysema.maven:apt-maven-plugin:maven-plugin:
1.0.8:, org.sonatype.plexus:plexus-build-api:jar:0.0.7:compile, org.codehaus.ple
xus:plexus-utils:jar:1.5.8:compile, backport-util-concurrent:backport-util-concu
rrent: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: com.yreham.mainstuff:mainstuff-jpa:1.0
 @ C:\DEV\myproject\mainstuff\mainstuff-jpa\pom.xml
[DEBUG]   (s) sourceEncoding = ISO-8859-1
[DEBUG] -- end configuration --
[DEBUG] Using build context: org.sonatype.plexus.build.incremental.DefaultBuildC
ontext@27bb2f11
[ERROR] C:\DEV\myproject\mainstuff\mainstuff-jpa\src\main\java\com\yreham\mainstuff\j
pa\queries\InstancesQuery.java:40: error: cannot find symbol
import com.yreham.mainstuff.jpa.entity.QCIEntity;

Some details of the config m2e - Maven Integration for Eclipse 1.2.0.20120903-1050 org.eclipse.m2e.feature.feature.group Eclipse.org - m2e

java version "1.7.0_15" Java(TM) SE Runtime Environment (build 1.7.0_15-b03) Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

(The target build is Java 1.6)

Here's the old pom XML

<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.0.8</version>
<executions>
 <execution>
   <goals>
      <goal>process</goal>
   </goals>
  <configuration>
   <outputDirectory>${apt.target.dir}</outputDirectory>
   processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
   <logOnlyOnError>true</logOnlyOnError>
   </configuration>
  </execution>
 </executions>
</plugin>

The new POM with bsc plugin

<plugin>
<groupId>org.bsc.maven</groupId> 
<artifactId>maven-processor-plugin</artifactId> 
 <version>2.0.5</version> 
  <executions> 
   <execution> 
    <id>process</id> 
    <goals> 
      <goal>process</goal> 
    </goals> 
 <phase>generate-sources</phase> 
  <configuration>
  <outputDirectory>${apt.target.dir}</outputDirectory>
    <processors>
      <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
    </processors>                  
  </configuration>
  </execution>
 </executions> 
 <dependencies> 
  <dependency> 
    <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-jpamodelgen</artifactId> 
       <version>1.2.0.Final</version> 
       </dependency> 
   </dependencies> 
</plugin>
Was it helpful?

Solution 2

Turns out it was a JPA configuration problem. I didn't see it was using an Hibernate layer on top Querydsl. Since we moved to the Eclipse J2EE version and added M2E WTP http://www.eclipse.org/m2e-wtp/, the jpa module was correctly reconfigured.

OTHER TIPS

Does your project build in command line?

If it doesn't, it'll most probably fail to build in eclipse too.

Now if CLI actually works, have you tried to install m2e-apt? It'll make annotation processing part of eclipse's incremental build process. See https://github.com/jbosstools/m2e-apt/ for more details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top