简体   繁体   English

使用Gradle将错误的文件添加到WAR包中

[英]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/classesmain源集的输出(已编译的类和已处理的资源)。 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/javasrc/main/resources吗?

Eclipse使用bin文件夹作为其输出文件夹,因此有可能您的文件以这种方式混淆。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM