Gradle:多项目并构建WAR文件



我正在更改我们的项目以使用gradle作为构建工具,但正在努力解决两个问题;

上下文:它是多项目的gradle配置

:project-root
------:client //GWT Java Files & GWT Centric resources, e.g. CSS, Images, ui-xml etc..
------:server //Server based logic, e.g. controllers, services, repositories etc.
------:web-app//NON GWT resources for the web-app, e.g. , web.xml, static pages, images 

1:要在:client build.gradle中运行gwtCompile任务,我将其添加为对战争任务的依赖性,例如:

war{
    dependsOn ':client:compileGwt'
    from {'src/main/root-content'}
    webInf {from 'src/main/web-inf-content'}
}

我不喜欢这样做,所以这样做有更简单的方法,以便当javaCompile任务在:client项目中完成时,gwtCompile任务被调用,以便GWT编译器可以访问生成的字节码?通过简单地将compile project(':client')放入:Web-App依赖项中调用javaCompile,而不是gwtCompile任务(正如我预期的那样)..

2:我努力从:client项目中获取GWT JavaScript输出,并将这些文件复制到战争文件中。我需要from属性中的以下内容:

war{
    from {'src/main/root-content','$:CLIENT/gwt-compiler-js-output-dir-as-declared-in-client-build-file}
    webInf {from 'src/main/web-inf-content'}
}

非常感谢,

ian。

您可以手动声明自己的任务依赖项,只要您不引入依赖性问题。:)您是否尝试过这样的事情?

javaCompile.dependsOn(project(':yourproject').taskName)

希望有帮助!

最新更新