can't generate metamodel from jpa entities

716 views
Skip to first unread message

Jake Cooper

unread,
Feb 11, 2016, 1:49:33 PM2/11/16
to Querydsl
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/target/generated-sources/java</outputDirectory>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
<options>
<querydsl.entityAccessors>false</querydsl.entityAccessors>
<querydsl.useFields>true</querydsl.useFields>
<querydsl.includedPackages>com.api.domain</querydsl.includedPackages>
</options>
</configuration>
</execution>
</executions>
</plugin>

<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>${querydsl.version}</version>
</dependency>

<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>${querydsl.version}</version>
<scope>provided</scope>
</dependency>

I run the process goal and it runs in less than a second not generating anything.
[INFO] ------------------------------------------------------------------------
[INFO] Building API 1.3_API-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- apt-maven-plugin:1.1.3:process (default-cli) @ api ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Jake Cooper

unread,
Feb 12, 2016, 11:09:55 AM2/12/16
to Querydsl
I changed it to this : 
<plugin>
<groupId>com.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>${project.basedir}/target/generated-sources/java</targetFolder>
<packages>
<package>com.api.domain</package>
</packages>
</configuration>
</execution>
</executions>
</plugin>

But get:
[ERROR] Failed to execute goal com.querydsl:querydsl-maven-plugin:4.0.7:jpa-export (default-cli) on project api: The parameters 'targetFolder', 'packages' for goal com.querydsl:querydsl-maven-plugin:4.0.7:jpa-export are missing or invalid -> [Help 1]

Richard Richter

unread,
Feb 13, 2016, 8:41:45 AM2/13/16
to Querydsl
In the second case you definitely used the wrong plugin, the first one seems OK, dependencies are also good. How about trying the first case with some simpler, more default config? Something like:

<plugin>
        <groupId>com.mysema.maven</groupId>
        <artifactId>apt-maven-plugin</artifactId>
        <version>1.1.3</version>
        <executions>
          <execution>
            <goals>
              <goal>process</goal>
            </goals>
            <configuration>
              <outputDirectory>target/generated-sources/java</outputDirectory>
              <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
            </configuration>
          </execution>
        </executions>
      </plugin>

Just to see what it does. Also, this step can be easily debugged in some IDE - run maven build in a debugger, put line breakpoint in AbstractQuerydslProcessor and then see how it goes on.

Virgo

timowest

unread,
Feb 14, 2016, 3:37:57 AM2/14/16
to Querydsl
I'd also be interested to see how it works without any options. Does the code generation work then?

Timo

Jake Cooper

unread,
Feb 15, 2016, 10:13:48 AM2/15/16
to Querydsl
It wasn't an issue with the options. I was running the apt:process goal via command line and maven plugin in IntelliJ -> didn't do/generate anything.
But when I run "mvn generate-sources" I get my static meta model.

Ruben Dijkstra

unread,
Feb 15, 2016, 10:29:44 AM2/15/16
to Querydsl
Hi Jake,

Please move the <configuration /> outside of the <execution />, then the configuration will also apply when running apt:process manually.

Best regards,

Ruben Dijkstra
Reply all
Reply to author
Forward
0 new messages