【问题标题】:Gradle: Multi-projects & build WAR fileGradle:多项目和构建 WAR 文件
【发布时间】:2012-11-07 06:23:16
【问题描述】:

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

上下文:它是一个多项目的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:为了让gwtCompile 任务在:client build.gradle 中运行,我将其添加为对war 任务的依赖项,如下所示:

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 输出,并将这些文件复制到 war 文件中。我在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'}
}

非常感谢,

伊恩。

【问题讨论】:

    标签: java gwt gradle


    【解决方案1】:

    您可以手动声明自己的任务依赖项,前提是您没有引入依赖项问题。 :) 你试过做这样的事情吗?

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

    希望有帮助!

    【讨论】:

    • 非常感谢 - 但是 :yourproject.taskname 需要在 javaCompile 任务位置之后运行..
    • 所以应该倒过来? taskName.dependsOn(project(':theOtherProject').javaCompile)
    猜你喜欢
    • 2015-04-26
    • 2017-02-11
    • 2019-02-18
    • 1970-01-01
    • 1970-01-01
    • 2017-10-13
    • 2013-07-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多