Migrating from Ant to Gradle is very easy with the importBuild method from AntBuilder. We only have to add this single line and reference our existing Ant build XML file and all Ant tasks can now be executed as Gradle tasks. We can automatically rena…
Gradle Goodness: Task Output Annotations Create Directory Automatically One of the great features of Gradle is incremental build support. With incremental build support a task is only executed if it is really necessary. For example if a task generate…
We can run a Gradle build without any of the task actions being executed. This is a so-called dry run of our build. We can use the dry run of a build to see if the task dependencies we have defined or are defined in a plugin are defined properly. Bec…
Gradle support the definition of so called live collections. These collections are mostly created based on criteria like with a filter() or matching() method. The collection content can change if the content of the source collection changes. For exam…
Gradle Goodness: Copy Files with Filtering Gradle's copy task is very powerful and includes filtering capabilities. This means we can change the contents of the files that are copied before they reach their new destination. We use the filter() method…
With the Gradle copy task we can define renaming rules for the files that are copied. We use the rename() method of the copy task to define the naming rules. We can use a closure where the filename is the argument of the closure. The name we return f…
In Gradle we can group related tasks using the group property of a task. We provide the name of our group and if we look at the output of the tasks task we can see our tasks grouped in section with the given name. In the next sample we create a new t…
Gradle Goodness: Init Script for Adding Extra Plugins to Existing Projects Gradle is very flexible. One of the ways to alter the build configuration is with initialization or init scripts. These are like other Gradle scripts but are executed before t…
请通过下面方式下载本系列文章的Github演示样例代码: git clone https://github.com/davenkin/gradle-learning.git     Gradle的Project从本质上说仅仅是含有多个Task的容器,一个Task与Ant的Target相似.表示一个逻辑上的运行单元.我们能够通过非常多种方式定义Task,全部的Task都存放在Project的TaskContainer中.   (1)调用Project的task()方法创建Task 在使用Gradl…
最近打算学习下 gradle 在 Android 中的使用,结果百度出来的文章都是介绍性文章,没啥干货.后来找到 gradle 官网教程,自己对着撸. Gradle 概述: Gradle 是一个基于 Apache Ant 和 Apache Maven 概念的项目自动化构建工具.它使用一种基于 Groovy 的特定领域语言来声明项目设置,而不是传统的 XML.Gradle 就是工程的管理,帮我们做了依赖.打包.部署.发布.各种渠道的差异管理等工作. Gradle优势: 一款最新的,功能最强大的构建…
To get the current Gradle version we can use the gradleVersion property of the Gradle object. This returns a string value we can use for displaying the values. If we want to compare Gradle versions we can use the GradleVersion object. With this class…
If we use Gradle in a multi-module project we can define project dependencies between modules. Gradle uses the information from the project dependencies to determine which tasks need to be run. For example if module B depends on module A and we want…
If we run a Gradle build and one of the tasks fails, the whole build stops immediately. So we have fast feedback of our build status. If we don't want to this and want Gradle to execute all tasks, even though some might have failed, we use the comman…
原文地址:http://java.dzone.com/articles/gradle-goodness-set-java If we want to set an explicit encoding for the Java compiler in Gradle we can use the options.encoding property. For example we could add the following line to our Gradle build file to chan…
一.ANT任务之Junit: 学习ANT其实主要是学习ANT的task,ANT众多task中有一个Testing Tasks,它下面有两个任务:Junit和JunitReport,主要用来进行单元测试及生成单元测试报告. Testing Tasks Task Name Description Junit Runs tests from the Junit testing framework. This task has been tested with JUnit 3.0 up to JUnit…
JMeter Ant Task 生成的*.jtl打开之后request和response data是空的,怎样让其不是空的呢?修改JMeter.properties,将jmeter.save.saveservice多处的false改成true,保存之后重启JMeter生效 # legitimate values: none, first, all#jmeter.save.saveservice.assertion_results=nonejmeter.save.saveservice.asser…
Gradle has a very powerful incremental build feature. This means Gradle will not execute a task unless it is necessary. We can help Gradle and configure our task so it is ready for an incremental build. Suppose we have a task that generates a file. T…
In a previous post we learned how we can use the inputs and outputs properties to set properties or files that need to be checked to see if a task is up to date. In this post we learn how a custom task class can use annotations to set input propertie…
To see which tasks are available for our build we can run Gradle with the command-line option -t or --tasks. Gradle outputs the available tasks from our build script. By default only the tasks which are dependencies on other tasks are shown. To see a…
If we want to set an explicit encoding for the Java compiler in Gradle we can use the options.encoding property. For example we could add the following line to our Gradle build file to change the encoding for the compileJava task: 0.apply plugin: 'ja…
To create an archive with Gradle is easy. We have several tasks like Zip, Tar, Jar, War and Ear to create a new archive. But there is no UnZip or UnTar to unpack an archive in Gradle. To unpack an archive we must use the Copy task and copy the conten…
Gradle uses the name build.gradle as the default name for a build file. If we write our build code in a file build.gradle then we don't have to specify the build filename when we run tasks. We can create build files with a different name other than b…
平时经常会用Ant来写一写脚本,但最近跨入到Groovy的时代,试着做一些改变.Groovy里集成了AntBuilder能非常方便的调用到Ant的对象模型. 现考察如下 1. Groovy里定义的属性如何能在Ant的Task里调用? def testMsg = "hello world" def ant = new AntBuilder() ant.echo(message:"${testMsg}") 2. 如何在Groovy里访问Ant里定义的属性? def an…
Normally Gradle looks for a build script file with the name build.gradle in the current directory to execute a build. But we can easily use a different name or directory for the build file. We only have to use the -b or --build-file command-line opti…
在android4.0以后的sdk里那个脚本就失效了,主要是因为 apkbuilder这个程序不见了: 人家sdk升级,我们的脚本也要跟上趟,修改一下喽. 上网一查,大家的文章还停留在我去年的脚本程度,算了,自己动手查阅了资料之后,具体实现如下: 先输一下生成key的命令 keytool -genkey -alias android.keystore -keyalg RSA -validity 20000 -keystore android.keystore 输入keystore密码:再次输入新…
使用Ant非常简单,当正确安装Ant后,只要输入ant或ant.bat即可. 如果运行ant命令时没有指定任何参数,Ant会在当前目录下搜索build.xml文件.如果找到了就以该文件作为生成文件,并执行默认的target 如果运行时使用 -find或者-s 选项(这两个选项的作用完全相同),Ant就会到上级目录中搜索生成文件,直至到达文件系统的根路径. 要想让Ant使用其他生成文件,可以使用 -buildfile<生成文件>选项,其中-buildfile可以使用 -file或-f来代替,这三…
原文出自:http://blog.csdn.net/zhuche110/article/details/2663904点击打开链接 Ant是一种基于Java的build工具.理论上来说,它有些类似于(Unix)C中的make ,但没有make的缺陷. 既然我们已经有了make, gnumake, nmake, jam以及其他的build工具为什么还要要一种新的build工具呢?因为Ant的原作者在多种(硬件)平台上开发软件时,无法忍受这些工具的限制和不便.类似于make的工具本质上是基于shel…
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationExcep…
时间:2019/12/7 这次接着整理加载gradle时出现的错误 出现的错误: Gradle sync failed: Could not find com.android.tools.build:gradle:3.5.0. Searched in the following locations: file:/F:/studio/studio2.0/gradle/m2repository/com/android/tools/build/gradle/2.8/gradle-2.8.pom fil…
 Eclipse项目导入Android Stuio 配置出现 Error:Timeout waiting to lock buildscript class cache for build file 'H:\studioproject\Generic_SN\build.gradle' (C:\Users\Administrator\.gradle\caches\2.2.1\scripts\build_81ep6udn3nlzszbotl32uedjz\ProjectScript\buildscr…