[英]Wrong files added to WAR package using Gradle
I'm using Gradle 1.5 and I'm trying to adapt the WAR plugin to an Eclipse dynamic project. 我正在使用Gradle 1.5,我正在尝试将WAR插件改编为Eclipse动态项目。
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. 当通过eclipse导出WAR时,它会在war文件的根目录中直接显示
xhtml
文件,并且我设法使用Gradle执行此操作。
But on my Gradle exported war I have the xhtml
files duplicated inside WEB-INF/classes
along with my .class
files 但是在我的Gradle导出的战争中,我在
WEB-INF/classes
复制了xhtml
文件以及我的.class
文件
I only want to have my .class
files in that folder, but I haven't found a way to do it 我只想将我的
.class
文件放在该文件夹中,但我还没有找到办法
Here's the relevant part of my build.gradle
file 这是我的
build.gradle
文件的相关部分
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.
}
The only customization I have done to the war plugin was change the webAppDirName
to point to my WebContent
folder. 我对war插件进行的唯一自定义是将
webAppDirName
更改为指向我的WebContent
文件夹。
Does anyone know how to define what goes inside the WEB-INF/classes
directory? 有谁知道如何定义
WEB-INF/classes
目录中的内容? I can't seem to get the hang of it. 我似乎无法掌握它。
EDIT I have managed to remove the .xhtml
duplicates by referring the resources to my bin
directory like this: 编辑我已设法通过将资源引用到我的
bin
目录来删除.xhtml
重复项,如下所示:
sourceSets {
main {
java {
srcDir 'src'
}
resources {
srcDir 'bin'
}
}
}
But I still have wrong files in my WEB-INF
. 但我的
WEB-INF
仍有错误的文件。
I have even this structure WEB-INF/classes/WEB-INF
. 我甚至有这个结构
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
我不知道为什么这些文件夹被添加到我的
classes
目录中,因为它们不存在于我的bin
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 我希望我的
bin
的类位于WEB-INF/classes
,而我的WebContent
的静态资源位于WAR文件的根目录中
By default, what goes into WEB-INF/classes
is the output of the main
source set (compiled classes and processed resources). 默认情况下,进入
WEB-INF/classes
是main
源集的输出(已编译的类和已处理的资源)。 Your build script declares an additional source directory ( src
), and keeps the default resource directory. 您的构建脚本声明了一个额外的源目录(
src
),并保留了默认的资源目录。 Do you have any files under src/main/java
or src/main/resources
? 你有
src/main/java
或src/main/resources
吗?
Eclipse使用bin
文件夹作为其输出文件夹,因此有可能您的文件以这种方式混淆。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.