Gradle GWT多项目,compileGwt没有找到子项目类路径

时间:2015-11-11 22:58:59

标签: eclipse gwt gradle

我有一个多项目GWt Gradle,其中来自gradle的compileGwt找不到子项目但是如果我使用标准的Eclipse GWT插件则编译很好

通过gradle构建时,我收到以下错误

:main:compileGwt
Loading inherited module 'com.stratebo.gwt.client.main.MainPage'
Loading inherited module 'com.stratebo.gwt.common'
  [ERROR] Unable to find 'com/stratebo/gwt/common.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?

项目结构如下:

TMSRoot
|--settings.gradle
|--build.gradle
|--CommonGwt
|----build.gradle
|--main
|----build.gradle

Tms Root settings.gradle

include "CommonGWT", "main"

TmsRoot build.gradle

subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'

repositories {
   mavenCentral()
}

dependencies {
    testCompile 'junit:junit:4.8.2'

}

version = '1.0'

jar {
    manifest.attributes provider: 'Stratebo Technologies'
}
}
project('main'){
dependencies {
compile project(":CommonGWT")
}
}

CommonGWT build.gradle

apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'gwt'
apply plugin: 'eclipse'
apply plugin: 'jetty'


dependencies {
compile 'org.slf4j:slf4j-api:1.7.12'
testCompile 'junit:junit:4.12'
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
version = '1.0'
buildscript {
    repositories {
        jcenter() //repository where to fetch gwt gradle plugin
}
dependencies {
    classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
    classpath  files(project(":CommonGWT").sourceSets.main.java.srcDirs)
}
}

repositories {
   mavenCentral()
}

compileJava{
    options.incremental = true
}

gwt {
   gwtVersion='2.7.0'
   modules 'com.stratebo.gwt.common'

  sourceSets {
    main {
        java {
            srcDir 'src'
        }
    }
}
logLevel = 'ERROR'
minHeapSize = "512M";
maxHeapSize = "1024M";
superDev {
    noPrecompile=true
}

Eclipse.
eclipse{
    addGwtContainer=false // Default set to true
}

jettyRunWar.httpPort = 8089
}
task wrapper(type: Wrapper) {
    gradleVersion = '2.8'
}

main build.gradle

apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'gwt'
apply plugin: 'eclipse'
apply plugin: 'jetty'


dependencies {
compile 'org.slf4j:slf4j-api:1.7.12'
testCompile 'junit:junit:4.12'
}

sourceCompatibility = 1.7
targetCompatibility = 1.7

version = '1.0'

dependencies{
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
compile group: 'commons-codec', name: 'commons-codec', version: '1.5'
compile group: 'org.gwtbootstrap3', name: 'gwtbootstrap3', version: '0.9.1'
compile group: 'junit', name: 'junit', version: '4.11'
compile project(':CommonGWT')

testCompile group: 'junit', name: 'junit', version: '4.+'
}

 def platformSources() {

return files('../CommonGWT/src/main/java', '../CommonGWT/src/main/resources')

}
buildscript {
repositories {
    jcenter() //repository where to fetch gwt gradle plugin
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
}
}

repositories {
mavenCentral()
}

compileJava{
options.incremental = true
}
gwt {
gwtVersion='2.7.0'
modules 'com.stratebo.gwt.client.main.MainPage'
sourceSets {
    main {
        java {
            srcDir 'src'

        }
    }
}
logLevel = 'ERROR'
minHeapSize = "512M";
maxHeapSize = "1024M";
superDev {
    noPrecompile=true
}
eclipse{
    addGwtContainer=false // Default set to true
}
//Specify the deployment Port
jettyRunWar.httpPort = 8089
}
task wrapper(type: Wrapper) {
gradleVersion = '2.8'
}

CommonGWt common.gwt.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.6.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.6.1/distro-source/core/src/gwt-module.dtd">
<module>
<inherits name="com.google.gwt.user.User" />
<inherits name="com.stratebo.gwt.common" />
<source path="client" />
<source path="common" />
</module>

最后是Main MainPage.gwt.xml

    

<module>
    <inherits name="org.gwtbootstrap3.GwtBootstrap3NoTheme" />
    <inherits name="com.google.gwt.user.User" />
    <stylesheet src="/mytheme.cache.css" />
    <entry-point class="com.stratebo.gwt.client.main.MainPage">
</entry-point>
<inherits name="com.stratebo.gwt.common" />
<source path="client" />
<source path="common" />
</module>

任何帮助非常感谢

1 个答案:

答案 0 :(得分:1)

我认为你错过了你可以添加到jar commonGWT build.gradle的commonGWT项目的资源:

    jar {
        from sourceSets.main.allSource
    }

commonGWT jar将包含允许编译依赖项目的源。