Groovy 項目構建工具,Gradle 2.0 發布
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 發布,下載地址:
gradle-2.0-all.zip (binaries, sources and documentation)
gradle-2.0-bin.zip (binaries only)
gradle-2.0-src.zip (sources only)
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
- New and noteworthy
- Updated to Groovy 2.3.2
- Support for Java 8
- New API for resolving source and javadoc artifacts
- Access Ivy extra info from component metadata rules
- Collaborate with plugins via
plugins.withId()
- Support for Ivy and Maven repositories with SFTP scheme
- Apache Maven POM profile activation based on absence of system property
- Fine grained control of arguments passed to native tools
- Simplified support for native cross compilation and custom platforms (GCC based toolchains)
- New 'ivy' layout support for Ivy repositories
- Default versions of code quality tools updated
- Tooling API improvements
- Fixed issues
- Potential breaking changes
- Upgraded to Groovy 2.3.2
- Can no longer run Gradle using Java 5
- Upgrades to code quality tool default versions
- Custom TestNG listeners are applied before Gradle's listeners
- Support for reading or changing file permissions on certain platforms with Java 6
- Support for terminal integration on certain platforms
- Build script changes
- Native binaries model changes
- New Java component model changes
- Support for the deprecated Gradle Open API removed
- Properties are no longer dynamically created on assignment
- += operator changes that typically affect configuration of eclipse and idea plugin
- Removed deprecated plugins
- Changes to Groovy and Scala plugins
- Removed deprecated command line options
- Removed deprecated classes
- Removed deprecated methods
- Removed deprecated properties
- Changes to file DSL
- Changes to dependency management DSL
- Tasks cannot be changed after task has started execution
- Removed incubating method
- Task constructor injection changes
- Task constructor changes
- External contributions
- Known issues
<p>詳細的改進說明請看:<a target="_blank" href="/misc/goto?guid=4958836051804875734">http://www.gradle.org/docs/current/release-notes</a></p>