【问题标题】:Gradle - multi project compiles but shared project classes not foundGradle - 多项目编译但未找到共享项目类
【发布时间】:2014-01-11 10:48:06
【问题描述】:

我们正在尝试设置多项目构建。

我们有 2 个项目:

1) 播放器管理器 2) 共享

当我们运行 gradle.test 任务时,我们的项目编译并且所有测试都成功

问题是当我们尝试从 eclipse 中在 tomcat 上运行项目时,我们得到共享项目中所有文件的类未找到错误。

这是我们的 gradle.build 文件:

PlayerManager(根)

=======================

apply plugin: 'war' 
apply plugin: 'jetty' 
apply plugin: 'eclipse-wtp' 
apply plugin: 'eclipse' 
apply from: 'dependencies.gradle' 
apply from: 'xmlHandler.gradle' 
apply plugin: 'base'

dependsOn(":NGShared:NGShared")

task wrapper(type: Wrapper) { 
gradleVersion = '1.9' 
}

repositories { 
mavenCentral() 
}

dependencies { 
providedCompile 'javax.servlet:servlet-api:2.5' 
compile 'org.springframework:spring-webmvc:3.2.2.RELEASE' 
runtime 'javax.servlet:jstl:1.1.2' 
}

/* Change context path (base url). otherwise defaults to name of project */ 
jettyRunWar.contextPath = ''

task cleanAndBuild(dependsOn: ['clean', 'assemble'])

assemble.mustRunAfter clean

tasks.withType(Test) { 
testLogging { 
events 'passed' 
} 
}

task testSanity(type: Test, dependsOn: testClasses) { 
exclude '*/TimeBaseTest*' 
}

共享(子项目)

=======================

apply plugin: 'java' 
apply plugin: 'eclipse' 
apply from: 'dependencies.gradle'

task wrapper(type: Wrapper) { 
gradleVersion = '1.9' 
}

settings.gradle

include ":NGShared:NGShared"

======================================================

Our path for the project is:

/NGPlayerManager/ 
/NGPlayerManager/NGShared/NGShared

有什么想法吗?

谢谢

【问题讨论】:

    标签: java spring build gradle


    【解决方案1】:

    您是否尝试过运行“gradle eclipseClean”然后运行“gradle eclipse”以让 gradle 重新生成所有内部 eclipse 配置文件?如果您不这样做,Eclipse 将不会自动重新生成其配置,并且不会将您的子项目包含到 .ear 或 .war 包中

    【讨论】:

    • 我想我明白了!将 dependsOn(":NGShared:NGShared") 更改为 dependencies { /* rest of dependencies...*/ compile project(':NGShared:NGShared') }
    猜你喜欢
    • 2018-04-09
    • 2013-08-05
    • 1970-01-01
    • 2016-02-10
    • 1970-01-01
    • 2020-04-13
    • 2019-01-20
    • 2012-11-15
    • 1970-01-01
    相关资源
    最近更新 更多