处理gradle任务依赖项

时间:2014-09-05 12:56:46

标签: gradle build.gradle

将gradle与其spring-boot插件(1.5.1)和first spirit plugin一起使用会引发错误:

D:\Coden\WS\STS\fs-db-import>gradle build                                                     
:genJaxb                                                                                      
:compileJava UP-TO-DATE                                                                       
:processResources UP-TO-DATE                                                                  
:classes UP-TO-DATE                                                                           
:jar UP-TO-DATE                                                                               
:fsm UP-TO-DATE                                                                               
:bootRepackage FAILED                                                                         

FAILURE: Build failed with an exception.                                                      

* What went wrong:                                                                            
Execution failed for task ':bootRepackage'.                                                   
> Unable to deduce layout for 'D:\Coden\WS\STS\fs-db-import\build\fsm\fs-db-import-0.0.1.fsm' 

似乎来自spring boot插件的bootRepackage无法处理或打包fsm文件。

a)如何排除它?

另一种方法是切换'fsm'和'bootRepackage'任务,但是将以下行添加到build.gradle

bootRepackage.dependsOn -= fsm
tasks.bootRepackage.dependsOn -= fsm
fsm.dependsOn bootRepackage

结果

Circular dependency between the following tasks:
:bootRepackage
\--- :fsm
     \--- :bootRepackage (*)

(*) - details omitted (listed previously)

b)如何从'bootRepackage'中删除'fsm'的依赖关系?

c)是否可以显示gradle任务依赖关系图? (不是项目依赖项)

1 个答案:

答案 0 :(得分:3)

默认情况下,Spring Boot插件会尝试重新打包Jar类型的所有任务。正义FSM任务从Jar延伸,插件尝试重新打包它们。您可以明确告诉插件要使用哪个Jar任务。

bootRepackage {
    withJarTask jar
}

更多信息可在Spring Documentation

中找到