首页 > IDEA使用gradle开发多module的java项目

IDEA使用gradle开发多module的java项目

现在尝试使用IDEA+gradle开发java项目。其中项目结构是这样的。


JFinal-ext是自己写的一base module。开发其他项目基于此base module。
Feedback是一个反馈系统。
其中build.gradle代码如下

apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'war'
apply plugin : 'jetty'
apply plugin: 'cargo'
//apply plugin: 'tomcat'

task createJavaProject << {
    sourceSets*.java.srcDirs*.each { it.mkdirs() }
    sourceSets*.resources.srcDirs*.each { it.mkdirs()}
}

task createWebProject(dependsOn: 'createJavaProject') << {
    def webAppDir = file("$webAppDirName")
    webAppDir.mkdirs()
}

sourceCompatibility = 1.5
version = '1.0'

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
//        classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.2.3'
        classpath 'org.gradle.api.plugins:gradle-cargo-plugin:0.6.1'
    }
}

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'

    compile project(':JFinal-ext')

    def cargoVersion = '1.3.3'
    cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion", "org.codehaus.cargo:cargo-ant:$cargoVersion"



war {
    from 'src/main/java'
    webInf { from 'src/main/webapp/WEB-INF/' }
    webXml = file('src/main/webapp/WEB-INF/web.xml')
}

jettyRun{
    webAppSourceDirectory file("$projectDir/src/main/webapp")
    contextPath project.name
    scanIntervalSeconds 10
    reload "automatic"
}
httpPort = 8080
stopPort = 8011
stopKey = 'jetty6'

cargo {
    containerId = 'jetty8x'
    port = 8080
    deployable {
        file = file('build/libs/Feedback-1.0.war')
        context = '/Feedback'
    }
    local {
        installer {
            installUrl = 'http://mirrors.yun-idc.com/eclipse//jetty/stable-8/dist/jetty-distribution-8.1.16.v20140903.tar.gz'
            downloadDir = file("$buildDir/download")
            extractDir = file("$buildDir/extract")
        }

    }
}

tasks.withType(JavaCompile) {
    options.encoding = "UTF-8"
}

    /*def tomcatVersion = '8.0.18'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
        "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
    exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
}*/
}

/*tomcat {
    httpPort = 8090
    stopPort = 8091
    //httpsPort = 8091
    //enableSSL = true
}

tomcatRun{
    contextPath= project.name
    URIEncoding= 'UTF-8'
    reloadable = 'true'

}
*/

每次启动jetty都特别慢 有的时候终止jetty还特别慢。希望大家贴出自己的build.gradle让我参考参考。谢谢了。如果能加我Q更是感谢:562470201 谢谢


jetty插件 启动慢的问题解决了吗? 我这边是根本就启动不了..但是用命令行瞬间就能启动,不知道是什么情况


你用红笔涂了前面 可漏了后面 酷我的哥们你好

【热门文章】
【热门文章】