【发布时间】:2018-03-07 20:23:03
【问题描述】:
我们刚刚将 JBoss 从 6.1.0 升级到 Wildfly 10.1,并对模块和工件版本等进行了各种相关的升级。在一个模块中,这导致我们的 cobertura 编译失败并出现编译器错误。我找到了IllegalStateException in Hibernate metamodel generation with maven 并升级到 maven-compiler-plugin 3.6.0(从 3.1 开始)。这似乎解决了我的问题,但仅限于本地。我可以为 cobertura 编译模块,但结果却导致了一个新问题。
此模块的一些注释生成的源被另一个模块使用,并且找不到类文件。发生了什么变化? generated-sources 目录包含 java 文件,但未编译类。
它曾考虑将 build-helper 阶段更改为从 process-sources 帮助生成源,但随后失败了。
由于 3.1 和 3.6.0 之间的更改,是否还有其他需要更改的地方? (我不熟悉如何处理注释 - 我只是 Cobertura 支持人员。)
pom 文件:
<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>
【问题讨论】:
标签: java maven annotations hibernate-annotations maven-compiler-plugin