4

I am trying to get QueryDSL to work on a Spring Roo project.

Here is my plugin config:

        <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>maven-apt-plugin</artifactId>
            <version>1.0.2</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/generated-sources</outputDirectory>
                        <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
        </plugin>

When I run the following command: mvn apt:process, I get the following error:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building suivitrc 0.1.0.BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-apt-plugin:1.0.2:process (default-cli) @ suivitrc ---
[ERROR] Either processor or processors need to be given
[ERROR] execute error
java.lang.IllegalArgumentException: Either processor or processors need to be given
        at com.mysema.maven.apt.AbstractProcessorMojo.buildProcessor(AbstractProcessorMojo.java:140)
        at com.mysema.maven.apt.AbstractProcessorMojo.execute(AbstractProcessorMojo.java:157)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at 

    org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
            at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
            at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
            at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
            at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
            at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
            at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
            at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
            at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1.375s
    [INFO] Finished at: Wed Sep 05 12:22:16 CEST 2012
    [INFO] Final Memory: 7M/18M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal com.mysema.maven:maven-apt-plugin:1.0.2:process (default-cli) on project suivitrc: Either processor
    to be given -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Of course I have already tried mvn install which doesn't generate any source.

Any advice welcome.

EDIT: The only output from maven-apt-plugin is this:

[INFO] --- maven-apt-plugin:1.0.2:process (default) @ suivitrc ---
balteo
  • 23,602
  • 63
  • 219
  • 412

1 Answers1

3

You are calling the goal directly. The execution configuration is not used in this case. Do you get the same exception when running clean install?

Timo Westkämper
  • 21,824
  • 5
  • 78
  • 111
  • No I don't get the same error when running clean install. It just doesn't generate the QueryDsl classes... – balteo Sep 05 '12 at 12:38
  • Hi Timo. I made an edit to my post with the output from `mvn clean install`. – balteo Sep 05 '12 at 12:46
  • 1
    Do you have JPA Entity annotated classes? Spring Roo might use some other annotations. – Timo Westkämper Sep 05 '12 at 13:04
  • Ummm... I thought about that too actually. The annotations are located in .aj (AsjpecJ) files and weaved at compile time. Should I change the phase in the plugin configuration? If so what phase should I choose? – balteo Sep 05 '12 at 13:10
  • APT does source code inspection, so this approach doesn't work here. – Timo Westkämper Sep 05 '12 at 13:24
  • I'll have to push in the `@Entity` annotations then... Thanks for your support Timo! – balteo Sep 05 '12 at 13:29
  • You can also use the GenericExporter tool, here is a related thread with some code examples https://groups.google.com/forum/#!msg/querydsl/Q305SAqXrIw/FJFs1ptr3wEJ – Timo Westkämper Sep 05 '12 at 14:12
  • To run the goal directly (ie `apt:process` or `processor:process`) along with the execution configuration, you can use the `default-cli` execution id. Check [this so question](http://stackoverflow.com/questions/3779369/run-a-single-maven-plugin-execution). – dev Nov 12 '13 at 16:29