0

我使用 Eclipse 进行了以下项目设置:

project
    build.gradle
    libraries.gradle
    settings.gradle
    ear-project
        build.gradle
    ejb-project
        build.gradle
    war-project
        build.gradle

这是来自根项目的 build.gradle:

apply from: "./libraries.gradle"

allprojects {
    repositories {
        mavenCentral()
    }
}

buildscript {
    repositories {
        mavenCentral()
    }
}

subprojects {
    apply plugin: "java"
    apply plugin: "eclipse"
    apply plugin: "findbugs"

    group = "foo.bar"
    version = "1.0.0-SNAPSHOT"
    sourceCompatibility = JavaVersion.VERSION_1_7
    targetCompatibility = JavaVersion.VERSION_1_7

    configurations {
        provided {
            description = "Non-exported compile-time dependencies"
        }
    }

    sourceSets.main {
        compileClasspath += configurations.provided
    }

    eclipse {
        classpath {
            plusConfigurations += configurations.provided
        }
    }

    dependencies {
        provided(libraries.javaee)
        provided(libraries.ejb)
        provided(libraries.cdi)
        provided(libraries.jpa)
    }
}

耳朵项目 build.gradle:

apply plugin: "ear"

dependencies {
    deploy project(path: ":ejb")
    deploy project(path: ":war", configuration: "archives")
}

ejb-项目 build.gradle

apply plugin: "java"

战争项目 build.gradle

apply plugin: "war"

从命令行运行“gradle build”后,会生成 .ear 文件,但 .war 文件仅包含未编译的 .java 类。ejb 项目中的类被编译成.class。为什么war-project中的类没有编译?

4

1 回答 1

5

Java 文件必须在src/main/java. 不是src/main/webappsrc/main/webapp是webapp静态资产所在的目录:JSP文件、HTML文件、JS文件等。

于 2013-07-20T15:14:20.470 回答