获取Android gradle插件& checkstyle一起工作/命令行用法 [英] Get Android gradle plugin & checkstyle working together / command line usage
问题描述
我正在评估新的基于gradle的构建系统重现我们当前基于ant的构建过程的能力,作为gradle初学者,我未能通过android gradle插件获取checkstyle。
环境:
-
标准的java项目(包括checkstyle检查目标)
-
没有eclipse,没有android studio,只有我可爱的终端
症状:
目标项目是 https://github.com/nibua-r/LigoTextDemo ,我成功地使用Gradle构建它,但如果我天真地添加 apply plugin:checkstyle
到我的 build.gradle
:
buildscript {
存储库{
mavenCentral()
}
依赖关系{
classpath'com.android.tools.build:gradle:0.4.2'
}
}
apply plugin:'android'
apply plugin:'checkstyle'
android {
buildToolsVersion'17'
compileSdkVersion 15
testBuildType'debug'
defaultConfig {
versionCode = 1
versionName ='1.0'
minSdkVersion 12
targetSdkVersion 15
}
buildTypes {
debug {
packageNameSuffix ='.debug'
}
}
}
然后 gradle check
甚至不会抱怨找不到 checkstyle.xml
文件(在默认的 config / checkstyle $ c
$ b
:check up-to-date
建立成功$($ c> location)并返回: b $ b
需要什么:
首先,我只需要一个正在运行的checkstyle目标。然后,我需要将checkstyle运行自动化为编译的依赖(但可以让chekstyle目标先运行)。
假设: >
这可能与以下事实有关(从[用户指南] [1]):
Android插件使用自己的sourceSets
,但我不够节俭效率了解我在那里错过了什么。请尊重您的宝贵知识,为我提供宝贵的启发!
解决方案java-base而不是java(即sourceSets管理是特定的),checkstyle插件依赖于java。因此,需要一些gradle上游修改来完成这件事。 Gradle团队正在研究这个问题,正如twitter上所看到的那样:
@ anzix Android源码集很快就会被通用代码质量插件所理解。这方面的工作已经开始。
— Gradle构建系统(@Gradleware) 2013年5月26日I'm evaluating the ability of the new gradle-based build system to reproduce our current ant-based build process and, as a gradle beginner, I failed to get checkstyle running with the android gradle plugin.
Environment:
gradle 1.6 running fine on a standard java project (checkstyle check target included)
up-to-date android SDK (22.0.1 with platform tools and build tools 17)
no eclipse, no android studio, only my lovely terminal
Symptom:
The target project is https://github.com/nibua-r/LigoTextDemo and I succeeded to build it using gradle but if I naively add apply plugin: checkstyle
to my build.gradle
:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}
apply plugin: 'android'
apply plugin: 'checkstyle'
android {
buildToolsVersion '17'
compileSdkVersion 15
testBuildType 'debug'
defaultConfig {
versionCode = 1
versionName = '1.0'
minSdkVersion 12
targetSdkVersion 15
}
buildTypes {
debug {
packageNameSuffix = '.debug'
}
}
}
then gradle check
doesn't even complain on not finding the checkstyle.xml
file (at the default config/checkstyle
location) and returns:
:check UP-TO-DATE
BUILD SUCCESSFUL
What's needed:
First, I just need a running checkstyle target. Then, I need to automate checkstyle running as a dependency of the compilation (but lets get the chekstyle target up and running first).
Assumption:
This may be related to the fact that (from the [user guide][1]):
The Android plugin […] uses its own sourceSets
but I'm not enough gradle-efficient to understand what I'm missing there. Please, gradle Master, enlighten me with your valuable knowledge!
I found by digging on the web that the Android plugin depends on java-base and not java (i.e. the sourceSets management is specific) and the checkstyle plugin rely on java. As a consequence, some gradle upstream modification are needed to get the thing done. The gradle team is working on that, as seen on twitter:
@anzix Android source sets will be soon understood by the generic code quality plugins. Work on that has already started.
— Gradle Build System (@Gradleware) May 26, 2013这篇关于获取Android gradle插件& checkstyle一起工作/命令行用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!