1

我的 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!

嗯......为什么会出现“检测到变化”?

4

0 回答 0