2016-09-02 3 views
-2

groovyという名前の非常に単純なgradleファイルを作成しました。シンプルなGroovyプログラム - Gradle

task groovy << {} 

println "Hello Groovy!" 

私は

gradle groovy 

として(私はWindowsの8.1を使用しています)が、私はこのエラーを取得するCMDに私のプロジェクトのフォルダの下にそれを実行しよう:

FAILURE: Build failed with an exception. 

What went wrong: 
Task 'groovy' not found in root project 'MyExercise'. 

Try: 
Run gradle tasks to get a list of available tasks. Run with --stacktrace  
option 
to get the stack trace. Run with --info or --debug option to get more log  
output 

なぜできませんグルーヴィーな仕事を見つける?私のbuild.gradleファイルで宣言されています。 Gradleが取り付けられています。ここに私のバージョンがあります。

Gradle 3.0 
------------------------------------------------------------ 

Build time: 2016-08-15 13:15:01 UTC 
Revision:  ad76ba00f59ecb287bd3c037bd25fc3df13ca558 

Groovy:  2.4.7 
Ant:   Apache Ant(TM) version 1.9.6 compiled on June 29 2015 
JVM:   1.8.0_45 (Oracle Corporation 25.45-b02) 
OS:   Windows 8.1 6.3 amd64 

とコマンドGradleのタスクを示しています

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

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

Help tasks 
---------- 
buildEnvironment - Displays all buildscript dependencies declared 
t 'MyExercise'. 
components - Displays the components produced by root project 'MyE 
ubating] 
dependencies - Displays all dependencies declared in root project 
dependencyInsight - Displays the insight into a specific dependenc 
ect 'MyExercise'. 
help - Displays a help message. 
model - Displays the configuration model of root project 'MyExerci 
ng] 
projects - Displays the sub-projects of root project 'MyExercise'. 
properties - Displays the properties of root project 'MyExercise'. 
tasks - Displays the tasks runnable from root project 'MyExercise' 

To see all tasks and more detail, run gradle tasks --all 

To see more detail about a task, run gradle help --task <task> 

BUILD SUCCESSFUL 

任意のアイデア?

ありがとう

Theo。

+0

を使用することができますと 'Gradleではtasks'があなたに何を示しんのでご注意しますか? –

+0

私の質問にgradleタスクの結果を入れました – Theo

+0

他のタスクgroovyのようなものを見なければならないと思うのですが、私はそうではありません:( – Theo

答えて

1

もし私が正しく理解していれば、あなたのファイル名はbuild.gradleではありません。この場合、gradleはそのファイルを読んでいないので、groovyというタスクが何であるか分かりません。

build.gradle以外のファイルをgradleで評価する場合は、ファイル名をgradleにする必要があります。分かりやすくするために、私はtest.groovyという名前のファイルを使用し、groovyファイルでタスクを実行する方法を示しました。あなただけの別のbuild.gradleにあなたのタスクを追加する必要がある場合

~/temp/39294812 $ cat test.groovy 
task groovy << { 
    println "Hello to you!" 
} 

println "Hello groovy" 

~/temp/39294812 $ gradle -q -b test.groovy groovy 
Hello groovy 
Hello to you! 

はまた、あなたがapply from: <path>

// to call groovy from inside a `build.gradle` file 
apply from: 'test.groovy' 
+1

はい、私は作った。実際には、コードをgradleファイルの中に入れるのを忘れていた。 – Theo

関連する問題