Because of the time. No way, take notes and translate at the same time, about Gradle User Guide. This blog is no longer relevant considerations. Only translations and non-translated chapters in this publication.
For other chapter translations please note GitHub this project: https://github.com/msdx/gradledoc/tree/1.12, interview: http://gradledoc.qiniudn.com/1.12/ Userguide/userguide.html
This article is original. Reprint Please specify source: http://blog.csdn.net/maosidiaoxian/article/details/40920093
My translation of Gradle is subject to the project on GitHub and the documentation on http://gradledoc.qiniudn.com.
Where the translation is found to be wrong. will be updated in the above two places first.
Due to time and energy issues, the translation published in the blog is basically not synchronized changes.
Nineth Chapter. Groovy High speed Getting Startedto build a groovy project. You need to useGroovy Plugin。 The plugin extends the Java plug-in and adds groovy's compilation functionality to your project. Your project can include groovy source code, Java source code, or both.
In all other respects. The groovy project is almost the same as the Java project we showed in chapter seventh Java QuickStart .
9.1. A major groovy projectLet's take a look at the example. To use the groovy plugin, you need to include the following in the build script file:
Example 9.1. Groovy Plugin
build.gradle
apply plugin: ' groovy '
Note: The code for this sample can be in the Gradle binary file or in the source code.samples/groovy/quickstart
See.
This code will apply the Java plug-in to project at the same time, assuming the Java plugin has not yet been applied. The Groovy plugin inherits
compile
tasks. In the
src/main/groovy
folder to locate the source file, and inherit the
compileTest
tasks, in
src/test/groovy
folder to find the source file of the test. These compilation tasks use federated Compilation of these folders, which means they can include both Java and groovy source files at the same time.
to use groovy to compile the task, You must also declare the groovy version number you want to use and where to get the groovy library.
You can finish by groovy
adding dependencies to the configuration. The compile
configuration inherits this dependency, so that when compiling groovy and Java source code. The Groovy library is also included in the classpath.
In the following example, we will use the groovy 2.2.0 version number in the MAVEN central repository.
Example 9.2. Dependency on Groovy 2.2.0
build.gradle
repositories { mavencentral ()}dependencies { ' org.codehaus.groovy:groovy-all:2.2.0 '}
Here is the build file we wrote:
Example 9.3. Groovy Example-complete Build File
build.gradle
Apply plugin:' Eclipse 'Apply plugin:' Groovy 'repositories {mavencentral ()}dependencies {compile' org.codehaus.groovy:groovy-all:2.2.0 'Testcompile' junit:junit:4.11 '}
Execution gradle build
will compile your project. Test and hit into a jar package.
9.2. SummaryThis chapter describes a very easy groovy project. Typically, a real project requires more than that. Because a groovy project also
is aA Java project, because Groovyproject is also a javaproject, so you can do things with Java that groovy can do.
you can read 24th chapter   Groovy Plug-ins Get to know a lot of other things about groovy plugins, or in the Gradle release package, samples/groovy
folder, found many other groovy demo sample projects.
Gradle 1.12 Translations--nineth groovy high-speed entry