gradle01_helloworld

简介: win7  64 gradle 2.1 build.gradle task hello { doLast { println 'Hello world!' }} In a command-line shell, move to the containing directory and execute the build


win7  64

gradle 2.1




build.gradle

task hello {
    doLast {
        println 'Hello world!'
    }
}


In a command-line shell, move to the containing directory and execute the build script with gradle -q hello   :



E:\download\developer\gradle\project_test\hello_world>gradle -q hello:


FAILURE: Build failed with an exception.

* What went wrong:
Project 'hello' not found in root project 'hello_world'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info o
r --debug option to get more log output.

E:\download\developer\gradle\project_test\hello_world>gradle -q --info
 hello
Starting Build
Settings evaluated using empty settings script.
Projects loaded. Root project using build file 'E:\download\developer\
gradle\project_test\hello_world\build.gradle'.
Included projects: [root project 'hello_world']
Evaluating root project 'hello_world' using build file 'E:\download\de
veloper\gradle\project_test\hello_world\build.gradle'.
All projects evaluated.
Selected primary task 'hello' from project :
Tasks to be executed: [task ':hello']
:hello (Thread[main,5,main]) started.
:hello
Executing task ':hello' (up-to-date check took 0.002 secs) due to:
  Task has not declared any outputs.
Hello world!
:hello (Thread[main,5,main]) completed. Took 0.145 secs.

BUILD SUCCESSFUL

Total time: 3.745 secs
E:\download\developer\gradle\project_test\hello_world>






There is a shorthand way to define a task like our hello task above, which is more concise.

Example 6.3. A task definition shortcut

build.gradle

task hello << {
    println 'Hello world!'
}





目录
相关文章
|
Java API Apache
Gradle从0入门到实战系列【一】Hello World Gradle
早期没有项目管理工具时,对于项目所依赖的第三方包采用的是:拷贝三方jar包到本地,然后加入到lib目录下,这样做劣势不言而喻,管理复杂容易冲突。 Gradle是一个基于Apache Ant和Apache Maven概念的项目自动化构建开源工具。它使用一种基于Groovy的特定领域语言(DSL)来声明项目设置,也增加了基于Kotlin语言的kotlin-based DSL,抛弃了基于XML的各种繁琐配置。面向Java应用为主。
658 0
Gradle从0入门到实战系列【一】Hello World Gradle
|
Java Android开发 程序员
build.gradle中buildTypes和productFlavors详解
用过AS的程序猿都知道build.gradle文件的作用,但我仍坚信还是有很多猿友不知道build.gradle文件中的一些代码的意思到底是什么? 这里来说下buildTypes和productFlavors的作用,顺便会说下其他一些配置。
1628 0
|
6月前
|
Java Maven
Run HelloWorld using Maven(JavaFX)
Run HelloWorld using Maven(JavaFX)
|
5月前
|
Java Maven 开发者
gradle项目对比maven项目的目录架构以及对gradle wrapper的理解
gradle项目对比maven项目的目录架构以及对gradle wrapper的理解
58 0
|
7月前
|
缓存 Java API
build.gradle文件介绍,gradle版本对应
build.gradle文件介绍,gradle版本对应
196 0
|
Java Shell 数据处理
Android 根目录下和应用目录下的build.gradle的详解,以及groovy语法的讲解
Android 根目录下和应用目录下的build.gradle的详解,以及groovy语法的讲解
241 0
|
缓存 Java 编译器
|
前端开发 Java Maven
Gradle build.gradle 文件
Gradle build.gradle 文件
Gradle build.gradle 文件
|
Java 测试技术 程序员