Groovy 项目构建工具,Gradle 2.0 发布

jopen 10年前

Gradle就是可以使用Groovy来书写构建脚本的构建系统,支持依赖管理和多项目,类似Maven,但比之简单轻便。

usePlugin 'groovy'    repositories {      flatDir dirs: "lib"  }    dependencies {      groovy ':groovy-all:1.7.0'      compile fileTree(dir: 'lib', includes: ['*.jar'])      runtime fileTree(dir: 'lib', includes: ['*.jar'])  }    // usage: gradle -i run  task run(dependsOn: classes) << {      captureStandardOutput(LogLevel.INFO)      ant.java(           classname: 'fox.gem.GroovyClass',          fork: true,          classpath: "${sourceSets.main.runtimeClasspath.asPath}"      )  }

以上是Gradle的构建文件build.gradle中的内容,是不是比Ant的build.xml要简单太多了?这就是“惯例”的力量。由此,我们可 以了解Gradle的第一个特点:“CoC(惯例优于配置)”。只要按照Gradle的惯例,那么可以最大限度的减少build文件的内容。

Gradle 2.0 发布,下载地址:

Version 2.0

Gradle 2.0 is an important milestone in the evolution of Gradle. As explained in the Gradle 2.0 announcement, the change in major version number signals a new backwards compatibility baseline. Many deprecated features and API have been removed in this release, allowing the development team to simplify the codebase and implement new functionality. The “Potential Breaking Changes” section of these release notes list all of the breaking changes that have been made and all Gradle users are strongly encouraged to read the list.

Gradle has matured considerably in the evolution from 1.0 to 2.0. It is more performant and is more memory efficient, particularly for large builds. Performance optimization is a persistent area of investment and work, with further optimizations to come during the 2.x stream. Performance, in all aspects, is critically important to a build system.

In addition to the breaking changes, it's business as usual with the steady evolution of Gradle via new and refined API and features.

The move to Groovy 2.3.2 from Groovy 1.8 brings with it all of the new features added to Groovy in this time. There is now a public API for resolving “source” and “javadoc” JARs for JVM library components. The exposing of Ivy “Extra Info” attributes enables a new class of advanced dependency management use cases. It is now possible to use the SFTP protocol for dependency consumption without using custom Ivy resolvers. Maven POM profile support has also been improved through support for profile activation through absence of a system property. There are also other refinements and improvements detailed below, including improvements to Gradle's support for building native projects.

We hope you enjoy Gradle 2.0 and the coming releases in the 2.x stream.

Table Of Contents

详细的改进说明请看:http://www.gradle.org/docs/current/release-notes