Maven-compiler-plugin 3.6.0 does not compile generated sources from annotations

We just updated JBoss from version 6.1.0 to Wildfly 10.1 and made a lot of related updates with modules and artifact versions and so on. In one module, this caused cobertura to fail to compile with a compiler error. I found an IllegalStateException in the generation of the Hibernate metamodel with maven and updated to maven-compiler-plugin 3.6.0 (from 3.1). This seems to have solved my problem, but only locally. I can compile a module for cobertura, but it causes a new problem.

Some of the sources generated by the annotation for this module are used by another module, but class files were not found. What changed? The generated sources directory contains java files, but the classes are not compiled.

He looked at one point, for example, changing the build-helper phase to generate sources from process sources, but this did not succeed afterwards.

Is there anything else that needs to be changed due to changes between 3.1 and 3.6.0? (I'm not familiar with annotation processing - I'm just a Cobertura support guy.)

pom file:

<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> <description>The JPA entities for the Element Manager</description> <artifactId>em-model</artifactId> <groupId>com.myprod.em</groupId> <parent> <artifactId>em</artifactId> <groupId>com.myprod</groupId> <version>3.5.0.0.0-SNAPSHOT</version> </parent> <packaging>jar</packaging> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <executions> <execution> <phase>process-sources</phase> <configuration> <sources> <source>${project.build.directory}/generated-sources/annotations</source> </sources> </configuration> <goals> <goal>add-source</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-jar-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId> <configuration> <finalName>em-model</finalName> </configuration> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <compilerArgument>-proc:none</compilerArgument> </configuration> <executions> <execution> <id>run-annotation-processors-only</id> <phase>generate-sources</phase> <configuration> <compilerArgument>-proc:only</compilerArgument> </configuration> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.glassfish</groupId> <artifactId>javax.el</artifactId> <version>3.0.1-b08</version> <scope>test</scope> </dependency> <dependency> <groupId>org.jboss.spec.javax.ejb</groupId> <artifactId>jboss-ejb-api_3.2_spec</artifactId> <scope>provided</scope> </dependency> <!-- Since hibernate validator is used in unit tests, these JBoss logging deps are needed --> <dependency> <groupId>org.jboss.slf4j</groupId> <artifactId>slf4j-jboss-logmanager</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.jboss.logmanager</groupId> <artifactId>jboss-logmanager</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.codehaus.jackson</groupId> <artifactId>jackson-mapper-asl</artifactId> <version>1.8.5</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-io</artifactId> <version>1.3.2</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.myco.csp</groupId> <artifactId>nrp_jpa</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>com.myco.cim</groupId> <artifactId>cs_cim_jpa</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-jpamodelgen</artifactId> <version>1.0.0.Final</version> <scope>provided</scope> </dependency> <!-- Test --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> </dependency> <dependency> <groupId>com.myco.logging</groupId> <artifactId>logging-client</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>apache-log4j</groupId> <artifactId>log4j</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>com.myprod.prodCommon</groupId> <artifactId>unit-test-utils</artifactId> <version>${project.version}</version> <scope>test</scope> </dependency> </dependencies> 

0
java maven annotations hibernate-annotations maven-compiler-plugin
source share
1 answer

I solved this by removing the -proc:none compiler argument from the compiler plugin. Moreover, none of the generated sources was compiled at all. With plugin 3.1 I had to do this, but with 3.6.0 I can not.

I also tried to implement the answer fooobar.com/questions/836485 / ... by specifying compilerArg at the default compilation stage, but would not compile the generated sources, If I had not reused the default compilation identifier that the collector worked with and gave me generated class files, but he performed two compilation phases, with -proc:none one second, which seemed unnecessary.

The last part of pom for the compiler is as follows:

 <plugin> <artifactId>maven-compiler-plugin</artifactId> <executions> <execution> <id>run-annotation-processors-only</id> <phase>generate-sources</phase> <configuration> <compilerArgument>-proc:only</compilerArgument> </configuration> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin> 
0
source share

All Articles