使用Gradle将错误的文件添加到WAR包中 [英] Wrong files added to WAR package using Gradle

查看:86
本文介绍了使用Gradle将错误的文件添加到WAR包中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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/javasrc/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屋!

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