2016-06-28 101 views
-1

我有兩個模塊,一個項目的IntelliJ:運行gradle這個 「戰爭」 不包括相關的IntelliJ項目

web-services(我的API),library-services(業務邏輯)。

的build.gradle網絡serivces的:

apply plugin: 'java' 
apply plugin: 'war' 
apply plugin: 'maven-publish' 
apply from: ext.gradleDir + '/common.gradle' 
apply from: ext.gradleDir + '/integration_test.gradle' 

sourceCompatibility = 1.8 
targetCompatibility = 1.8 
project.version = '1.0.' + getBuildNumber() 


dependencies { 
    compile project(':library-services') 
    compile('com.waze.automation:common:1.0.80') 

    compile('com.sun.jersey:jersey-bundle:1.19') 
    compile('com.sun.jersey:jersey-json:1.19') 
    compile group: 'org.codehaus.jackson', name:'jackson-jaxrs', version: '1.1.1' 

    compile('com.google.guava:guava:18.0') 

    testCompile group: 'junit', name: 'junit', version: '4.11' 
    testCompile('org.hamcrest:hamcrest-all:1.3') 
    testCompile('org.mockito:mockito-all:1.9.5') 

} 

war { 
    from 'src/main' // include source files in war 
} 

我運行此命令的gradle:

~/workspaceQa/MobileAutomationWebService/web-services ⮀ 
❯ ./gradlew war 

但在創建戰我沒有看到圖書館服務類

和我的服務拋出ClassNoFound異常。

這裏是我的日誌的一部分。我怎樣才能解決這個問題?

12:10:28.081 [INFO] [org.gradle.BuildLogger] Tasks to be executed: [task ':library-services:compileJava', task ':library-services:processResources', task ':library-services:verifyDependencies', task ':library-services:classes', task ':library-services:setProjectVersion', task ':library-services:jar', task ':web-services:compileJava', task ':web-services:processResources', task ':web-services:verifyDependencies', task ':web-services:classes', task ':web-services:war'] 
+0

我認爲你需要運行時的依賴。它擴展了編譯依賴。它應該是:運行時項目(':library-services')。根據:https://docs.gradle.org/current/userguide/war_plugin.html(47.6) – OscarBcn

+0

爲什麼?它應該依賴於編譯時間。沒有? –

+0

我認爲運行時擴展了編譯,看起來你在運行時需要這些類,而不僅僅是編譯時。運行時,你的依賴項目應該包含在你的lib文件夾中,這些類將準備好用於你的web服務項目 – OscarBcn

回答

-1

我刪除了這條線的問題得到解決後:

gradle.properties文件:

#org.gradle.parallel=true 
+0

我不會推薦這個解決方案,除非沒有別的因爲它可以顯着增加大型項目的編譯時間。 –

相關問題