私の pom.xml には、次のような OpenJPA のメタモデルを生成するセクションがあります。
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>generate-entity-metamodel</id>
<phase>generate-sources</phase>
<goals>
<goal>
compile
</goal>
</goals>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<optimize>true</optimize>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<proc>only</proc>
<compilerArgument>-Aopenjpa.metamodel=true</compilerArgument>
<generatedSourcesDirectory>${project.build.directory}/generated-sources/openjpa-metamodel</generatedSourcesDirectory>
</configuration>
</execution>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
私が抱えている「問題」は、ソースコードに変更がある場合にのみ maven-compiler-plugin のこの「デフォルト」実行が呼び出されることです-これは予想されますが、「generate-entity-metamodel」は常に呼び出され、失敗につながりますこれらの生成クラスは、以前のビルドから既に存在するためです。ビルドが成功するためには、常にやらなければなりません。mvn clean compile
これを修正して、ソース ファイルに変更があった場合にのみ "generate-entity-metamodel" を呼び出すにはどうすればよいですか?
これが私がしたときの出力です
mvn test
[INFO] --- build-helper-maven-plugin:1.8:add-source (default) @ icmynet-core ---
[INFO] Source directory: E:\Projekti\release-repo\icmynet\trunk\icmynet-core\target\generated-sources\openjpa-metamodel added.
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (generate-entity-metamodel) @ icmynet-core ---
[INFO] Changes detected - recompiling the module!
うーん...なぜ「検出された変更」があるのですか?