代码之家  ›  专栏  ›  技术社区  ›  Peter Tillemans

为什么当运行mvn install两次时,来自生成源的类就消失了?

  •  2
  • Peter Tillemans  · 技术社区  · 6 年前

    我有一个从xsd模式用jaxb生成java类的项目。

    POM包含

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>2.2</version>
                <executions>
                    <execution>
                        <id>xjc</id>
                        <goals>
                            <goal>xjc</goal>
                        </goals>
                        <phase>generate-sources</phase>
                    </execution>
                </executions>
                <configuration>
                    <!-- The package of your generated sources -->
                    <packageName>com.melexis.mfgdil.b2mml</packageName>
                    <sources>
                        <source>src/main/schema/AllSchemas.xsd</source>
                    </sources>
                </configuration>
            </plugin>
    

    当我打字时 mvn clean install Java源代码是从 xsd文件到 目标/生成源/jaxb ,编译并最终 目标/类 ,太好了!

    当我敢马上跑 mvn install 再一次,没有任何改变,我明白了:

    [INFO] --- jaxb2-maven-plugin:2.2:xjc (xjc) @ b2mml ---
    [INFO] Ignored given or default xjbSources 
    [/home/pti/Projects/b2mml/src/main/xjb], since it is not an existent file or directory.
    [INFO] No changes detected in schema or binding files - skipping JAXB 
    generation.  
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ b2mml ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 0 resource
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ b2mml ---
    [INFO] Changes detected - recompiling the module!
    [INFO] Compiling 1 source file to /home/pti/Projects/b2mml/target/classes
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ b2mml ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] skip non existing resourceDirectory /home/pti/Projects/b2mml/src/test/resources
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ 
    

    2亿英镑--- [信息]无需编译-所有类都是最新的 [信息]

    这个 目标/类 文件夹被清除,并且 目标/生成源 已经不存在了,在我的 src/main/java文件 树在左边。

    我不明白为什么maven会检测到更改,而且我得到的更少的是,它会重新编译模块,但会忘记生成的源代码。我忘了什么?

    0 回复  |  直到 6 年前