使用Gradle将错误的文件添加到WAR包中 [英] Wrong files added to WAR package using Gradle
问题描述
我正在使用Gradle 1.5,并且正在尝试使用 WAR插件到Eclipse动态项目.
I'm using Gradle 1.5 and I'm trying to adapt the WAR plugin to an Eclipse dynamic project.
当通过Eclipse导出WAR时,它在战争文件的根目录上直接有xhtml
个文件,而我设法通过Gradle做到了.
When the WAR is exported by eclipse it has the xhtml
files straight on the root of the war file, and I managed to do that with Gradle.
但是在我的Gradle出口战争中,我将xhtml
文件与.class
文件一起复制在WEB-INF/classes
内部
But on my Gradle exported war I have the xhtml
files duplicated inside WEB-INF/classes
along with my .class
files
我只想将我的.class
文件放在该文件夹中,但是我没有找到解决方法
I only want to have my .class
files in that folder, but I haven't found a way to do it
这是我的build.gradle
文件的相关部分
Here's the relevant part of my build.gradle
file
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'
webAppDirName = 'WebContent'
sourceSets {
main {
java {
srcDir 'src'
}
}
}
eclipse {
// my eclipse plugin config..
}
dependencies {
// my dependencies config.
}
我对war插件所做的唯一定制是将webAppDirName
更改为指向我的WebContent
文件夹.
The only customization I have done to the war plugin was change the webAppDirName
to point to my WebContent
folder.
有人知道如何定义WEB-INF/classes
目录中的内容吗?我似乎无法掌握它.
Does anyone know how to define what goes inside the WEB-INF/classes
directory? I can't seem to get the hang of it.
编辑
通过设法将资源引用到我的bin
目录中,我设法删除了.xhtml
重复项:
EDIT
I have managed to remove the .xhtml
duplicates by referring the resources to my bin
directory like this:
sourceSets {
main {
java {
srcDir 'src'
}
resources {
srcDir 'bin'
}
}
}
但是我的WEB-INF
中仍然有错误的文件.
But I still have wrong files in my WEB-INF
.
我甚至有这个结构WEB-INF/classes/WEB-INF
.我不知道为什么将这些文件夹添加到我的classes
目录中,因为它们在我的bin
I have even this structure WEB-INF/classes/WEB-INF
. I don't know why these folders are being added to my classes
directory, since they don't exist in my bin
我希望bin
中的类位于WEB-INF/classes
中
并将WebContent
中的静态资源放在WAR文件的根目录中
I want the classes in my bin
to be in WEB-INF/classes
and the static resources in my WebContent
to be in the root of the WAR file
推荐答案
默认情况下,WEB-INF/classes
中包含main
源集(编译类和已处理资源)的输出.您的构建脚本会声明一个附加的源目录(src
),并保留默认的资源目录.您在src/main/java
或src/main/resources
下是否有文件?
By default, what goes into WEB-INF/classes
is the output of the main
source set (compiled classes and processed resources). Your build script declares an additional source directory (src
), and keeps the default resource directory. Do you have any files under src/main/java
or src/main/resources
?
这篇关于使用Gradle将错误的文件添加到WAR包中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!