maven-processor-plugin to ignore undefined symbols

I've JPA 2 maven project and I want to process sources to have the static meta model. What I did I took JBoss' static meta model processor and set it up to run during generate-sources phase. Now, obviously I have some classes that reference the meta model and compilation itself goes fine. But maven-processor-plugin itself generates errors complaining that it can't find symbols from meta model like this:

[INFO] --- maven-processor-plugin:2.2.4:process (process) @ ng-grid-java ---
[ERROR] diagnostic: c:\...\service\position\PositionSpecifications.java:13: cannot find symbol
symbol  : class Position_

Which is logical because it actually generates these classes, but is not right since it brings errors to an otherwise correct project. Or maybe I'm using it wrong? Am I missing something?

Update: I have been able to inhibit the error output by using configuration parameter outputDiagnostics but I'm not sure that's the right way.

Answers


The solution could be adding the generated classes to project classpath using the build-helper-maven-plugin, as follows:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>artifactId</artifactId>
        <groupId>groupId</groupId>
        <version>1.0.0-SNAPSHOT</version>       
    </parent>
    <artifactId>jpa-metamodel-generation</artifactId>

    <dependencies>

        <!-- Hibernate JPA metamodel generator -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-jpamodelgen</artifactId>
            <version>1.2.0.Final</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.hibernate.javax.persistence</groupId>
                    <artifactId>hibernate-jpa-2.0-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

    </dependencies>

    <build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerArgument>-proc:none</compilerArgument>
                </configuration>
            </plugin>

            <!-- Plugin to generate JPA metamodel -->
            <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>process-sources</phase>
                        <configuration>
                            <outputDirectory>${project.build.directory}/metamodel</outputDirectory>
                            <processors>
                                <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
                            </processors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Build helper plugin to add generated sources to classpath -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.build.directory}/metamodel</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

I have setted the phase-s of the plugins like:

build-helper-maven-plugin --> <phase>process-sources</phase>

and

maven-processor-plugin --> <phase>compile</phase>

Need Your Help

Capistrano Net::SSH::AuthenticationFailed

ruby-on-rails ubuntu deployment capistrano bitbucket

This is my situation: I have this rails app that I have "capified" and I'm trying to deploy with capistrano onto my Ubuntu cloud server. I have been following this guide -> http://robmclarty.com/bl...

How to reset git author recent two commits?

git rebase

When I commit changed files, one more commit is made automatically after pull(or fetch) if there is no conflict btw remote and local repo.