2014-10-10 77 views
0

我已經在Ubuntu 14.04上安裝了Gradle 2.0,並且我想用Gradle運行一個小的Web應用程序,但是當我在Eclipse Luna上構建Gradle項目時(我已經安裝了用於Eclipse 4.4的Gradle集成插件),我在終端上輸入「gradle tasks」,它不會顯示任務「jettyEclipse」來運行servlet。Gradle與Eclipse的集成

這裏我的build.gradle

buildscript { 
     repositories { 
      jcenter() 
     } 

     dependencies { 
      classpath (group: 'com.sahlbach.gradle', name: 'gradle-jetty-eclipse-plugin',  version: '1.9.2') 
     } 
    } 

    apply plugin: 'java' 
    apply plugin: 'war' 
    apply plugin: 'jettyEclipse' 
    apply plugin: 'eclipse' 
    apply plugin: 'eclipse-wtp' 


    repositories { 
     mavenCentral()            
    } 

    dependencies { 
     providedCompile 'javax.servlet:javax.servlet-api:3.0.1' 
    } 

這裏編譯輸出:

[sts] ----------------------------------------------------- 
[sts] Starting Gradle build for the following tasks: 
[sts]  :cleanEclipse 
[sts]  :eclipse 
[sts] ----------------------------------------------------- 
:cleanEclipseClasspath 
:cleanEclipseJdt 
:cleanEclipseProject 
:cleanEclipseWtpComponent 
:cleanEclipseWtpFacet 
:cleanEclipseWtp 
:cleanEclipse 
:eclipseClasspath 
:eclipseJdt 
:eclipseProject 
:eclipseWtpComponent 
:eclipseWtpFacet 
:eclipseWtp 
:eclipse 

BUILD SUCCESSFUL 

Total time: 1.14 secs 
[sts] ----------------------------------------------------- 
[sts] Build finished succesfully! 
[sts] Time taken: 0 min, 1 sec 
[sts] ----------------------------------------------------- 

在這裏,我的 「gradle這個任務」 輸出:

:tasks 

------------------------------------------------------------ 
All tasks runnable from root project 
------------------------------------------------------------ 

Build Setup tasks 
----------------- 
init - Initializes a new Gradle build. [incubating] 
wrapper - Generates Gradle wrapper files. [incubating] 

Help tasks 
---------- 
dependencies - Displays all dependencies declared in root project 'me'. 
dependencyInsight - Displays the insight into a specific dependency in root project 'me'. 
help - Displays a help message 
projects - Displays the sub-projects of root project 'me'. 
properties - Displays the properties of root project 'me'. 
tasks - Displays the tasks runnable from root project 'me'. 

To see all tasks and more detail, run with --all. 

BUILD SUCCESSFUL 

Total time: 3.35 secs 

我也有嘗試1.9和2.1 gradle版本。

任何人都可以幫助我嗎?

+1

看起來像'gradle這個tasks'從錯誤的目錄中運行。輸出是就像從一個沒有'build.gradle'的目錄運行'gradle tasks'一樣,甚至沒有顯示Java插件的任務,這個問題不太可能與'jettyEclipse'插件相關。 – 2014-10-10 12:37:02

+0

非常感謝。從我的主目錄運行gradle ... – 2014-10-10 15:12:35

回答

0

我在我的主目錄執行gradle tasks,而不是在項目目錄(其中我有build.gradle。彼得感謝您的幫助。