• 作者:老汪软件技巧
  • 发表时间:2024-09-08 00:03
  • 浏览量:

这是增量构建导致的。

参考资料:maven-compiler-plugin

如何关闭增量构建

//命令行参数
-Dmaven.compiler.useIncrementalCompilation=false
// 插件配置

        <plugins>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-compiler-pluginartifactId>
                <configuration>
                  <useIncrementalCompilation>falseuseIncrementalCompilation>
                configuration>
            plugin>
        plugins>
    

to enable/disable incremental compilation feature.

This leads to two different modes depending on the underlying compiler. The default javac compiler does the following:

“启用 / 禁用增量编译功能。这会根据底层编译器产生两种不同的模式。默认的 javac 编译器会进行以下操作:

true(默认值):在这种模式下,编译器插件会确定当前模块所依赖的任何 JAR 文件在当前构建运行中是否发生了变化;或者自上次编译以来是否有任何源文件被添加、删除或更改。如果是这种情况,编译器插件会重新编译所有源文件。

false(不推荐):这种模式下只会编译比其对应的类文件更新的源文件,即自上次编译以来发生了变化的源文件。这不会重新编译使用了已更改类的其他类,可能会导致这些类中保留对不再存在的方法的引用,从而在运行时产生错误。”

总结api被其他项目依赖,service不被其他项目依赖。添加-pl参数删除-U命令关闭增量构建 。添加 piler.useIncrementalCompilation=false

现在统一取消-U命令,并且关闭增量构建

mvn  clean  package install deploy -T4C -Dmaven.test.skip=true -Dmaven.compiler.useIncrementalCompilation=false -pl api
mvn  clean  package  -T4C -Dmaven.test.skip=true -Dmaven.compiler.useIncrementalCompilation=false -pl service 

构建现在只需要2分钟

观察日志,阅读文档,调整参数。

参考资料

maven-fast-build


上一条查看详情 +Nacos 注册中心和配置中心应用实践
下一条 查看详情 +没有了