在同一个Gradle项目中生成WAR和EAR构件 [英] Generating WAR and EAR artifacts inside the same Gradle project

查看:181
本文介绍了在同一个Gradle项目中生成WAR和EAR构件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个带有标准Web项目布局的Gradle Web项目 src / main / webapp



Project myproject-web build.gradle

  apply plugin:'java'
apply plugin:'eclipse-wtp'
apply plugin:'war'

我知道我可以包装由 myproject生成的 .war 文件如果我定义了一个二级项目(比如 myproject-ear ),那么在 .ear >),它将 ear 插件和引用 myproject-web 作为依赖关系:



项目 myproject-ear build.gradle

  deploy project(':myproject-web')

我知道,只有一个 .war 内部创建 .ear 文件是没有意义的但这就是我需要在我目前的工作中提供工件的方式)。因此,可以完全跳过项目 myproject-ear 的定义,直接在内部直接使用 ear 插件 myproject-web 的构建文件?



谢谢!

解决方案

将耳塞添加到战争项目中,然后使用以下配置将战争添加到耳中:

  ear {
from war.outputs.files
}


Suppose that I have a Gradle web project with a standard web project layout src/main/webapp.

Project myproject-web, build.gradle:

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'

I know that I can wrap the resulting .war file generated by myproject-web inside an .ear if I define a secondary project (say, myproject-ear) which applies the ear plugin and references myproject-web as a dependency:

Project myproject-ear, build.gradle:

deploy project(':myproject-web')

I know it's a bit pointless to create an .ear file with only one .war inside (but that's how I'm required to deliver artifacts at my current job). So would it be possible to entirely skip the definition of the project myproject-ear and just use the ear plugin directly inside myproject-web's build file?

Thanks!

解决方案

Add the ear plugin to your war project, then add the war into the ear using the following configuration:

ear {
    from war.outputs.files
}

这篇关于在同一个Gradle项目中生成WAR和EAR构件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆