├── .gitattributes ├── .gitignore ├── .travis.yml ├── LICENSE.txt ├── README.md ├── build.gradle ├── plugin ├── build.gradle ├── ci │ ├── gradle-publish.gradle │ ├── publish.gradle │ └── tag_release.sh ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ └── main │ ├── groovy │ └── org │ │ └── stoyicker │ │ └── androidcheck │ │ ├── CheckExtension.groovy │ │ ├── CheckPlugin.groovy │ │ ├── CommonCheck.groovy │ │ ├── CommonConfig.groovy │ │ ├── Utils.groovy │ │ ├── checkstyle │ │ ├── CheckstyleCheck.groovy │ │ └── CheckstyleConfig.groovy │ │ └── pmd │ │ ├── PmdCheck.groovy │ │ └── PmdConfig.groovy │ └── resources │ ├── META-INF │ └── gradle-plugins │ │ └── org.stoyicker.android-check.properties │ ├── checkstyle │ ├── checkstyle.xsl │ └── conf-default.xml │ └── pmd │ ├── conf-default.xml │ └── pmd.xsl ├── sample ├── app │ ├── build.gradle │ ├── lint.xml │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── assets │ │ └── logback.xml │ │ ├── java │ │ └── plugin │ │ │ └── example │ │ │ └── MainActivity.java │ │ └── res │ │ ├── drawable-hdpi │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ │ ├── drawable-xxhdpi │ │ └── ic_launcher.png │ │ ├── layout │ │ └── main.xml │ │ └── values │ │ └── strings.xml ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── libs │ └── sample-java-library │ │ ├── build.gradle │ │ └── src │ │ └── main │ │ └── java │ │ └── plugin │ │ └── example │ │ └── JavaLibrary.java └── settings.gradle └── settings.gradle /.gitattributes: -------------------------------------------------------------------------------- 1 | # Default 2 | * text=auto 3 | 4 | # Android 5 | *.gradle text 6 | *.java text 7 | *.properties text 8 | *.xml text 9 | /gradlew text eol=lf 10 | /gradlew.bat text eol=crlf 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.properties 2 | !gradle-wrapper.properties 3 | !org.stoyicker.android-check.properties 4 | .gradle 5 | build 6 | .idea 7 | *.iml 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | language: android 3 | jdk: oraclejdk8 4 | branches: 5 | except: 6 | - /^[0-9]/ # Workaround to not to trigger Travis with tags - https://github.com/travis-ci/travis-ci/issues/1532 7 | android: 8 | components: 9 | - tools 10 | - platform-tools 11 | - android-27 12 | - build-tools-28.0.3 13 | before_install: 14 | - cd .. && mv android-check-2 android-check && cd android-check # Required by the release plugin since Gradle 4.8 15 | - yes | sdkmanager "platforms;android-27" 16 | - printf "bintray.user=$BINTRAY_USER\nbintray.key=$BINTRAY_KEY\ngradle.publish.key=$GRADLE_PUBLISH_KEY\ngradle.publish.secret=$GRADLE_PUBLISH_SECRET\n" > plugin/gradle.properties 17 | - cd plugin 18 | - ./gradlew publishToMavenLocal 19 | - cd .. 20 | before_script: 21 | - | 22 | if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then 23 | echo "Do not open PRs against master; merge dev into master locally and push instead." 24 | exit 1 25 | fi 26 | - cd sample 27 | script: 28 | - ./gradlew check --refresh-dependencies --rerun-tasks --stacktrace 29 | after_success: 30 | - cd .. 31 | - | 32 | if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then 33 | echo "CI on master succeded. Executing release tasks..." 34 | git fetch --unshallow 35 | cd plugin 36 | ./gradlew bintrayUpload publishPlugins 37 | ./ci/tag_release.sh 38 | cd .. 39 | fi 40 | notifications: 41 | email: false 42 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Jorge Antonio Diaz-Benito Soriano 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Android Check 2 2 | =============== 3 | 4 | Static code analysis plugin for Android projects. 5 | This is a fork of [the original android-check plugin][1], which implements a really useful concept, but unfortunately seems abandoned. 6 | Works for application, library and feature modules. 7 | 8 | *Current version tested with Android plugin for Gradle 3.1.3*. 9 | 10 | Who uses this? 11 | ------------ 12 | [![Schibsted Products & Technology](https://i.imgur.com/YwLGGgJ.png)](http://www.schibsted.com/en/About-Schibsted/Schibsted-Products-and-Technology/) 13 | [![China Euro Vehicle Technology](https://i.imgur.com/8OxYcwv.png)](http://www.cevt.se/) 14 | 15 | 16 | Build status 17 | ------------ 18 | 19 | ### master [![master](https://travis-ci.org/stoyicker/android-check-2.svg?branch=master)](https://travis-ci.org/stoyicker/android-check-2) 20 | ### dev [![dev](https://travis-ci.org/stoyicker/android-check-2.svg?branch=dev)](https://travis-ci.org/stoyicker/android-check-2) 21 | 22 | Usage 23 | ----- 24 | 25 | [ ![Download](https://api.bintray.com/packages/stoyicker-org/android-check-2/org.stoyicker.android-check/images/download.svg) ](https://bintray.com/stoyicker-org/android-check-2/org.stoyicker.android-check/_latestVersion) 26 | 27 | This plugin is available in [the Gradle Plugin Portal](https://plugins.gradle.org/plugin/org.stoyicker.android-check). It attaches itself to the `check` task, but you can also execute the corresponding tasks manually when desired: `androidCheckstyle` for CheckStyle, and `androidPmd` for PMD. 28 | 29 | In order to add it to your project, you can use this snippet for Gradle 2.1 and later: 30 |
31 | Kotlin 32 | 33 | ```kotlin 34 | plugins { 35 | id("org.stoyicker.android-check") version "+" 36 | } 37 | ``` 38 | 39 |
40 |
41 | Groovy 42 | 43 | ```groovy 44 | plugins { 45 | id "org.stoyicker.android-check" version "+" 46 | } 47 | ``` 48 | 49 |
50 | 51 | Or this one for older Gradle versions or where dynamic configuration is required: 52 | 53 |
54 | Kotlin 55 | 56 | ```kotlin 57 | buildscript { 58 | repositories { 59 | gradlePluginPortal() 60 | } 61 | dependencies { 62 | classpath("org.stoyicker.android-check:plugin:+") 63 | } 64 | } 65 | 66 | apply(plugin = "org.stoyicker.android-check") 67 | ``` 68 | 69 |
70 |
71 | Groovy 72 | 73 | ```groovy 74 | buildscript { 75 | repositories { 76 | gradlePluginPortal() 77 | } 78 | dependencies { 79 | classpath("org.stoyicker.android-check:plugin:+") { 80 | // These are to avoid some conflicts with the Android plugin due to how classloading is performed by Gradle 81 | // Only required before Gradle 4.8: https://github.com/gradle/gradle/issues/5092 82 | exclude module: "asm" 83 | exclude module: "gson" 84 | exclude module: "guava" 85 | exclude module: "commons-logging" 86 | // This one is required because Checkstyle and PMD use different Saxon artifacts that have overlapping packages 87 | // Also only required before Gradle < 4.8 88 | exclude module: "Saxon-HE" 89 | } 90 | } 91 | } 92 | 93 | apply plugin: "org.stoyicker.android-check" 94 | ``` 95 | 96 |
97 | 98 | Configuration 99 | ------------- 100 | 101 | ### Recommended 102 | 103 | The default one. 104 | 105 | ### Customized 106 | 107 |
108 | Kotlin 109 | 110 | ```kotlin 111 | // Configuration is completely optional, defaults will be used if not present 112 | check { 113 | // Do absolutely nothing, default: false 114 | skip(true/false) 115 | // Fails build if a violation is found, default: true. Ignored if all per-tool confs are set to abortOnError false (see below) 116 | abortOnError(true/false) 117 | // Checkstyle configuration 118 | checkstyle { 119 | // Completely skip Checkstyle, default: false 120 | skip(true/false) 121 | // Fails build if Checkstyle rule violations are found, default: false 122 | abortOnError(true/false) 123 | // Configuration file for Checkstyle, default: /config/checkstyle.xml, if non-existent then //config/checkstyle.xml, if non-existent then plugin/src/main/resources/checkstyle/conf-default.xml 124 | config("path/to/config.xml") 125 | // Output file for XML reports, default: File(project.buildDir, "outputs/checkstyle/checkstyle.xml") 126 | reportXML(File(project.buildDir, "path/where/you/want/checkstyle.xml")) 127 | // Output file for HTML reports, default: File(project.buildDir, "outputs/checkstyle/checkstyle.html") 128 | reportHTML(File(project.buildDir, "path/where/you/want/checkstyle.html")) 129 | } 130 | // PMD configuration 131 | pmd { 132 | // Completely skip PMD, default: false 133 | skip(true/false) 134 | // Fails build if PMD rule violations are found, default: false 135 | abortOnError(true/false) 136 | // Configuration file for PMD, default: /config/pmd.xml, if non-existent then //config/pmd.xml, if non-existent then plugin/src/main/resources/pmd/conf-default.xml 137 | config("path/to/config.xml") 138 | // Output file for XML reports, default: File(project.buildDir, "outputs/pmd/pmd.xml") 139 | reportXML(File(project.buildDir, "path/where/you/want/pmd.xml")) 140 | // Output file for HTML reports, default: File(project.buildDir, "outputs/pmd/pmd.html") 141 | reportHTML(File(project.buildDir, "path/where/you/want/pmd.html")) 142 | } 143 | } 144 | ``` 145 | 146 |
147 |
148 | Groovy 149 | 150 | ```groovy 151 | // Configuration is completely optional, defaults will be used if not present 152 | check { 153 | // Do absolutely nothing, default: false 154 | skip(true/false) 155 | // Fails build if a violation is found, default: true. Ignored if all per-tool confs are set to abortOnError false (see below) 156 | abortOnError(true/false) 157 | // Checkstyle configuration 158 | checkstyle { 159 | // Completely skip Checkstyle, default: false 160 | skip(true/false) 161 | // Fails build if Checkstyle rule violations are found, default: false 162 | abortOnError(true/false) 163 | // Configuration file for Checkstyle, default: /config/checkstyle.xml, if non-existent then //config/checkstyle.xml, if non-existent then plugin/src/main/resources/checkstyle/conf-default.xml 164 | config("path/to/config.xml") 165 | // Output file for XML reports, default: new File(project.buildDir, "outputs/checkstyle/checkstyle.xml") 166 | reportXML(new File(project.buildDir, "path/where/you/want/checkstyle.xml")) 167 | // Output file for HTML reports, default: new File(project.buildDir, "outputs/checkstyle/checkstyle.html") 168 | reportHTML(new File(project.buildDir, "path/where/you/want/checkstyle.html")) 169 | } 170 | // PMD configuration 171 | pmd { 172 | // Completely skip PMD, default: false 173 | skip(true/false) 174 | // Fails build if PMD rule violations are found, default: false 175 | abortOnError(true/false) 176 | // Configuration file for PMD, default: /config/pmd.xml, if non-existent then //config/pmd.xml, if non-existent then plugin/src/main/resources/pmd/conf-default.xml 177 | config("path/to/config.xml") 178 | // Output file for XML reports, default: new File(project.buildDir, "outputs/pmd/pmd.xml") 179 | reportXML(new File(project.buildDir, "path/where/you/want/pmd.xml")) 180 | // Output file for HTML reports, default: new File(project.buildDir, "outputs/pmd/pmd.html") 181 | reportHTML(new File(project.buildDir, "path/where/you/want/pmd.html")) 182 | } 183 | } 184 | ``` 185 | 186 |
187 | 188 | Also, if `abortOnError` is `true`, the browser will open the report for the tool that caused the failure (if your system supports it). 189 | 190 | Developed By 191 | ============ 192 | 193 | The original version of this plugin was developed by: 194 | 195 | - [Noveo Group][2] 196 | - [Pavel Stepanov](https://github.com/stefan-nsk) - 197 | 198 | This fork is owned and maintained by [Jorge Antonio Diaz-Benito Soriano](https://www.linkedin.com/in/jorgediazbenitosoriano). 199 | 200 | License 201 | ======= 202 | 203 | See [LICENSE.txt](LICENSE.txt). 204 | 205 | Original work licensed under [MIT license](https://github.com/noveogroup/android-check/blob/master/LICENSE.txt). 206 | 207 | [1]: https://github.com/noveogroup/android-check 208 | [2]: http://noveogroup.com/ 209 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | task clean(type: Delete) { 2 | delete rootProject.allprojects.collect {project -> project.buildDir} 3 | followSymlinks false 4 | } 5 | -------------------------------------------------------------------------------- /plugin/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'groovy' 2 | 3 | repositories { jcenter() } 4 | 5 | dependencies { 6 | compileOnly gradleApi() 7 | // Checkstyle 8 | implementation('com.puppycrawl.tools:checkstyle:8.14') { 9 | exclude module: "guava" 10 | exclude module: "commons-logging" 11 | exclude module: "Saxon-HE" 12 | } 13 | // PMD 14 | implementation('net.sourceforge.pmd:pmd-java:6.8.0') { 15 | exclude module: "asm" 16 | exclude module: "gson" 17 | } 18 | // The following dependencies need to be respected with regards to the version that lint brings of them 19 | compileOnly 'com.google.guava:guava:22.0' 20 | compileOnly 'commons-logging:commons-logging:1.1.1' 21 | compileOnly 'org.ow2.asm:asm:5.1' 22 | compileOnly 'com.google.code.gson:gson:2.7' 23 | } 24 | 25 | def masterCommitCount = 'git rev-list --count HEAD'.execute([], project.rootDir).text.trim() 26 | if (masterCommitCount == "") { masterCommitCount = "0" } 27 | if (masterCommitCount == "50") { masterCommitCount = "99999" } // Dirty hack to make mavenLocal gain prio on Travis 28 | masterCommitCount = Integer.parseInt(masterCommitCount) + 62 29 | 30 | project.ext { 31 | plugin = 'org.stoyicker.android-check' 32 | name = 'Android Check Plugin 2' 33 | description = 'Static code analysis plugin for Android projects.' 34 | groupId = 'org.stoyicker.android-check' 35 | artifactId = 'plugin' 36 | version = "2.$masterCommitCount" 37 | website = 'https://github.com/stoyicker/android-check-2' 38 | scm = 'https://github.com/stoyicker/android-check-2' 39 | tags = ['android', 'plugin', 'check', 'checkstyle', 'pmd'] 40 | pom = { 41 | licenses { 42 | license { 43 | name 'The MIT License (MIT)' 44 | url 'https://opensource.org/licenses/MIT' 45 | distribution 'repo' 46 | } 47 | } 48 | scm { 49 | url project.ext.scm 50 | connection 'scm:git@github.com:stoyicker/android-check-2.git' 51 | developerConnection 'scm:git@github.com:stoyicker/android-check.git' 52 | } 53 | issueManagement { 54 | system 'GitHub' 55 | url "${project.ext.scm}/issues" 56 | } 57 | developers { 58 | developer { 59 | name 'Jorge Antonio Diaz-Benito Soriano' 60 | url 'https://www.linkedin.com/in/jorgediazbenitosoriano' 61 | roles { 62 | role 'developer' 63 | } 64 | } 65 | } 66 | } 67 | bintray = { 68 | user = project.hasProperty('bintray.user') ? project['bintray.user'] : 'anonymous' 69 | key = project.hasProperty('bintray.key') ? project['bintray.key'] : 'api-key' 70 | repo = 'android-check-2' 71 | org = 'stoyicker-org' 72 | licenses = ['MIT'] 73 | issueTracker = 'https://github.com/stoyicker/android-check-2/issues' 74 | vcs = project.ext.scm 75 | sign = true 76 | dryRun = false 77 | publish = true 78 | } 79 | } 80 | 81 | apply from: project.file('ci/gradle-publish.gradle') 82 | apply from: project.file('ci/publish.gradle') 83 | -------------------------------------------------------------------------------- /plugin/ci/gradle-publish.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | maven { url 'https://plugins.gradle.org/m2/' } 4 | } 5 | dependencies { 6 | classpath 'com.gradle.publish:plugin-publish-plugin:0.10.0' 7 | } 8 | } 9 | 10 | // hack: plugin 'com.gradle.plugin-publish' is not visible by name 11 | apply plugin: com.gradle.publish.PublishPlugin 12 | 13 | pluginBundle { 14 | website = project.ext.website 15 | vcsUrl = project.ext.scm 16 | description = project.ext.description 17 | plugins { 18 | checkPlugin { 19 | id = project.ext.plugin 20 | displayName = project.ext.name 21 | tags = project.ext.tags 22 | version = project.ext.version 23 | } 24 | } 25 | mavenCoordinates { 26 | groupId = project.ext.groupId 27 | artifactId = project.ext.artifactId 28 | version = project.ext.version 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /plugin/ci/publish.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'maven-publish' 2 | 3 | task('groovydocJar', type: Jar, dependsOn: groovydoc) { 4 | group 'documentation' 5 | description 'Assembles a jar archive containing Groovydoc API documentation.' 6 | classifier = 'groovydoc' 7 | from javadoc.getDestinationDir() 8 | } 9 | 10 | task('sourcesJar', type: Jar) { 11 | group 'documentation' 12 | description 'Assembles a jar archive containing the main source code.' 13 | classifier = 'sources' 14 | from sourceSets.main.allSource 15 | } 16 | 17 | publishing { 18 | publications { 19 | maven(MavenPublication) { 20 | from components.java 21 | artifact groovydocJar 22 | artifact sourcesJar 23 | groupId project.ext.groupId 24 | artifactId project.ext.artifactId 25 | version project.ext.version 26 | 27 | pom.withXml { 28 | asNode().appendNode('name', project.ext.name) 29 | asNode().appendNode('description', project.ext.description) 30 | asNode().appendNode('url', project.ext.website) 31 | asNode().children().last() + project.ext.pom 32 | } 33 | } 34 | } 35 | } 36 | 37 | buildscript { 38 | repositories { 39 | jcenter() 40 | } 41 | dependencies { 42 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' 43 | } 44 | } 45 | 46 | // hack: plugin 'com.jfrog.bintray' is not visible by name 47 | apply plugin: com.jfrog.bintray.gradle.BintrayPlugin 48 | // hack: without it bintray property is not visible 49 | logger.debug("$project.ext.bintray") 50 | 51 | bintray { 52 | user = project.ext.bintray.user 53 | key = project.ext.bintray.key 54 | publications = ['maven'] 55 | dryRun = project.ext.bintray.dryRun 56 | publish = project.ext.bintray.publish 57 | pkg { 58 | repo = project.ext.bintray.repo 59 | userOrg = project.ext.bintray.org 60 | name = project.ext.bintray.groupId 61 | desc = project.description 62 | websiteUrl = project.ext.website 63 | issueTrackerUrl = project.ext.issueTracker 64 | vcsUrl = project.ext.vcs 65 | licenses = project.ext.bintray.licenses 66 | labels = project.ext.tags 67 | publicDownloadNumbers = true 68 | groupId = project.ext.bintray.groupId 69 | artifactId = project.ext.bintray.artifactId 70 | version { 71 | name = project.ext.bintray.version 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /plugin/ci/tag_release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | BRANCH_NAME=${TRAVIS_BRANCH} 5 | ARTIFACT_VERSION="2."$(($(git rev-list --count HEAD)+62)) 6 | 7 | tagAndCreateGitHubRelease() { 8 | git fetch --tags 9 | LAST_TAG=$(git describe --tags --abbrev=0) 10 | THIS_RELEASE=$(git rev-parse --short ${BRANCH_NAME}) 11 | local IFS=$'\n' 12 | RELEASE_NOTES_ARRAY=($(git log --format=%B $LAST_TAG..$THIS_RELEASE | tr -d '\r')) 13 | for i in "${RELEASE_NOTES_ARRAY[@]}" 14 | do 15 | RELEASE_NOTES="$RELEASE_NOTES\\n$i" 16 | done 17 | 18 | BODY="{ 19 | \"tag_name\": \"$ARTIFACT_VERSION\", 20 | \"target_commitish\": \"$BRANCH_NAME\", 21 | \"name\": \"$ARTIFACT_VERSION\", 22 | \"body\": \"$RELEASE_NOTES\" 23 | }" 24 | 25 | echo ${BODY} 26 | 27 | # Create the release in GitHub and extract its id from the response 28 | curl \ 29 | -u stoyicker:${GITHUB_TOKEN} \ 30 | --header "Accept: application/vnd.github.v3+json" \ 31 | --header "Content-Type: application/json; charset=utf-8" \ 32 | --request POST \ 33 | --data "${BODY}" \ 34 | https://api.github.com/repos/stoyicker/android-check-2/releases 35 | } 36 | 37 | tagAndCreateGitHubRelease 38 | -------------------------------------------------------------------------------- /plugin/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stoyicker/android-check-2/b4443d3aa5cd633b61c928bd9201b97e1651b99e/plugin/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /plugin/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /plugin/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /plugin/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /plugin/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'plugin' 2 | -------------------------------------------------------------------------------- /plugin/src/main/groovy/org/stoyicker/androidcheck/CheckExtension.groovy: -------------------------------------------------------------------------------- 1 | package org.stoyicker.androidcheck 2 | 3 | import org.stoyicker.androidcheck.checkstyle.CheckstyleConfig 4 | import org.stoyicker.androidcheck.pmd.PmdConfig 5 | import org.gradle.api.Action 6 | import org.gradle.api.Project 7 | 8 | class CheckExtension { 9 | 10 | static final String NAME = 'check' 11 | 12 | private final Project project 13 | 14 | CheckstyleConfig checkstyle 15 | 16 | void checkstyle(Action action) { action.execute(checkstyle) } 17 | 18 | PmdConfig pmd 19 | 20 | void pmd(Action action) { action.execute(pmd) } 21 | 22 | CheckExtension(Project project) { 23 | this.project = project 24 | this.checkstyle = new CheckstyleConfig(project) 25 | this.pmd = new PmdConfig(project) 26 | } 27 | 28 | private boolean skip = false 29 | 30 | void skip(boolean skip) { this.skip = skip } 31 | 32 | Boolean getSkip() { 33 | return skip 34 | } 35 | 36 | private boolean abortOnError = true 37 | 38 | void abortOnError(boolean abortOnError) { this.abortOnError = abortOnError } 39 | 40 | boolean getAbortOnError() { 41 | return abortOnError 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /plugin/src/main/groovy/org/stoyicker/androidcheck/CheckPlugin.groovy: -------------------------------------------------------------------------------- 1 | package org.stoyicker.androidcheck 2 | 3 | import org.stoyicker.androidcheck.checkstyle.CheckstyleCheck 4 | import org.stoyicker.androidcheck.pmd.PmdCheck 5 | import org.gradle.api.Plugin 6 | import org.gradle.api.Project 7 | 8 | class CheckPlugin implements Plugin { 9 | 10 | @Override 11 | void apply(Project target) { 12 | target.extensions.create(CheckExtension.NAME, CheckExtension, target) 13 | 14 | new CheckstyleCheck().apply(target) 15 | new PmdCheck().apply(target) 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /plugin/src/main/groovy/org/stoyicker/androidcheck/CommonCheck.groovy: -------------------------------------------------------------------------------- 1 | package org.stoyicker.androidcheck 2 | 3 | import org.gradle.api.GradleException 4 | import org.gradle.api.Project 5 | 6 | import java.awt.* 7 | import java.util.List 8 | 9 | abstract class CommonCheck { 10 | 11 | final String taskCode 12 | final String taskName 13 | final String taskDescription 14 | 15 | CommonCheck(String taskCode, String taskName, String taskDescription) { 16 | this.taskCode = taskCode 17 | this.taskName = taskName 18 | this.taskDescription = taskDescription 19 | } 20 | 21 | private static enum OsType { 22 | TYPE_LINUX("xdg-open %s"), 23 | TYPE_WINDOWS("start microsoft-edge:%s"), 24 | TYPE_MAC_OS("open %s") 25 | 26 | private String mCmdReplacement 27 | 28 | OsType(String cmdReplacement) { 29 | mCmdReplacement = cmdReplacement 30 | } 31 | } 32 | 33 | protected Set getDependencies() { [] } 34 | 35 | protected abstract Config getConfig(CheckExtension extension) 36 | 37 | protected abstract void performCheck(Project project, List sources, 38 | File configFile, File xmlReportFile) 39 | 40 | protected abstract int getErrorCount(File xmlReportFile) 41 | 42 | protected abstract String getErrorMessage(int errorCount, File htmlReportFile) 43 | 44 | protected void reformatReport(Project project, File styleFile, 45 | File xmlReportFile, File htmlReportFile) { 46 | project.ant.xslt(in: xmlReportFile, out: htmlReportFile) { 47 | style { string(styleFile.text) } 48 | } 49 | } 50 | 51 | void apply(Project target) { 52 | target.task( 53 | [group : 'verification', 54 | description: taskDescription], 55 | taskName).doLast { 56 | CheckExtension extension = target.extensions.findByType(CheckExtension) 57 | Config config = getConfig(extension) 58 | 59 | boolean skip = config.resolveSkip(extension.getSkip()) 60 | boolean abortOnError = config.resolveAbortOnError(extension.getAbortOnError()) 61 | File configFile = config.resolveConfigFile(taskCode) 62 | File styleFile = config.resolveStyleFile(taskCode) 63 | File xmlReportFile = config.resolveXmlReportFile(taskCode) 64 | File htmlReportFile = config.resolveHtmlReportFile(taskCode) 65 | List sources = config.getAndroidSources() 66 | 67 | if (skip) { 68 | target.logger.warn "Skipping $taskName" 69 | } else { 70 | xmlReportFile.parentFile.mkdirs() 71 | performCheck(target, sources, configFile, xmlReportFile) 72 | htmlReportFile.parentFile.mkdirs() 73 | reformatReport(target, styleFile, xmlReportFile, htmlReportFile) 74 | 75 | int errorCount = getErrorCount(xmlReportFile) 76 | if (errorCount) { 77 | String errorMessage = getErrorMessage(errorCount, htmlReportFile) 78 | if (abortOnError) { 79 | final String path = "file://" + htmlReportFile.absolutePath 80 | if (Desktop.isDesktopSupported()) { 81 | Desktop.getDesktop().browse(new URI(path)) 82 | } else { 83 | final String osName = System.getProperty("os.name") 84 | final String osNameMatch = osName.toLowerCase(Locale.ENGLISH) 85 | final OsType osType 86 | if(osNameMatch.contains("linux")) { 87 | osType = OsType.TYPE_LINUX 88 | } else if(osNameMatch.contains("windows")) { 89 | osType = OsType.TYPE_WINDOWS 90 | } else if(osNameMatch.contains("mac os") || osNameMatch.contains("macos") || osNameMatch.contains("darwin")) { 91 | osType = OsType.TYPE_MAC_OS 92 | } else { 93 | target.logger.warn "Your system was not identified as able to auto-open the report. " + 94 | "Please open an issue at https://github.com/stoyicker/android-check-2/issues/" 95 | osType = null 96 | } 97 | if (osType != null) { 98 | Runtime.getRuntime().exec(String.format(osType.mCmdReplacement, path, Locale.ENGLISH)) 99 | } 100 | } 101 | throw new GradleException(errorMessage) 102 | } else { 103 | target.logger.warn errorMessage 104 | } 105 | } 106 | } 107 | } 108 | 109 | target.afterEvaluate { 110 | if (target.tasks.find({ it.name == 'check' }) != null) { 111 | target.tasks.getByName('check').dependsOn taskName 112 | } else { 113 | target.logger.warn 114 | "task check not found in project $target.name. You may need to run the plugin tasks manually" 115 | } 116 | } 117 | dependencies.each { target.tasks.getByName(taskName).dependsOn it } 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /plugin/src/main/groovy/org/stoyicker/androidcheck/CommonConfig.groovy: -------------------------------------------------------------------------------- 1 | package org.stoyicker.androidcheck 2 | 3 | import org.gradle.api.Project 4 | import org.gradle.api.resources.TextResource 5 | 6 | class CommonConfig { 7 | 8 | protected final Project project 9 | 10 | CommonConfig(Project project) { 11 | this.project = project 12 | } 13 | 14 | private Boolean skip = null 15 | 16 | void skip(boolean skip) { this.skip = skip } 17 | 18 | private Boolean abortOnError = null 19 | 20 | void abortOnError(boolean abortOnError) { this.abortOnError = abortOnError } 21 | 22 | private TextResource configResource = null 23 | private File configFile = null 24 | 25 | private void checkConfigDefined() { 26 | if (configResource || configFile) { 27 | throw new IllegalArgumentException('configuration XML is already defined') 28 | } 29 | } 30 | 31 | void config(TextResource resource) { 32 | checkConfigDefined() 33 | this.configResource = resource 34 | } 35 | 36 | void config(File file) { 37 | checkConfigDefined() 38 | this.configFile = file 39 | } 40 | 41 | void config(String path) { 42 | config(project.file(path)) 43 | } 44 | 45 | private File reportXML 46 | private File reportHTML 47 | 48 | void reportXML(File reportXML) { 49 | this.reportXML = reportXML 50 | } 51 | 52 | void reportHTML(File reportHTML) { 53 | this.reportHTML = reportHTML 54 | } 55 | 56 | boolean resolveSkip(boolean defaultSkip) { 57 | return skip == null ? defaultSkip : skip 58 | } 59 | 60 | boolean resolveAbortOnError(boolean defaultAbortOnError) { 61 | return abortOnError == null ? defaultAbortOnError : abortOnError 62 | } 63 | 64 | private String resolveConfig(String code) { 65 | if (configResource) { 66 | return configResource.asString() 67 | } 68 | if (configFile) { 69 | return configFile.text 70 | } 71 | 72 | File file = project.file("config/${code}.xml") 73 | if (file.exists()) { 74 | return file.text 75 | } 76 | 77 | File rootFile = project.rootProject.file("config/${code}.xml") 78 | if (rootFile.exists()) { 79 | return rootFile.text 80 | } 81 | 82 | return Utils.getResource(project, "$code/conf-default.xml") 83 | } 84 | 85 | File resolveConfigFile(String code) { 86 | File file = new File(project.buildDir, "tmp/android-check/${code}.xml") 87 | file.parentFile.mkdirs() 88 | file.delete() 89 | file << resolveConfig(code) 90 | return file 91 | } 92 | 93 | private String resolveStyle(String code) { 94 | return Utils.getResource(project, "$code/${code}.xsl") 95 | } 96 | 97 | File resolveStyleFile(String code) { 98 | File file = new File(project.buildDir, "tmp/android-check/${code}.xsl") 99 | file.parentFile.mkdirs() 100 | file.delete() 101 | file << resolveStyle(code) 102 | return file 103 | } 104 | 105 | private File resolveReportFile(String extension, File reportFile, String code) { 106 | if (reportFile) { 107 | return reportFile 108 | } 109 | 110 | return new File(project.buildDir, "outputs/${code}/${code}.${extension}") 111 | } 112 | 113 | File resolveXmlReportFile(String code) { 114 | return resolveReportFile('xml', reportXML, code) 115 | } 116 | 117 | File resolveHtmlReportFile(String code) { 118 | return resolveReportFile('html', reportHTML, code) 119 | } 120 | 121 | List getAndroidSources() { 122 | return Utils.getAndroidSources(project) 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /plugin/src/main/groovy/org/stoyicker/androidcheck/Utils.groovy: -------------------------------------------------------------------------------- 1 | package org.stoyicker.androidcheck 2 | 3 | import org.gradle.api.GradleException 4 | import org.gradle.api.Project 5 | 6 | import java.util.jar.JarEntry 7 | import java.util.jar.JarFile 8 | 9 | final class Utils { 10 | 11 | private Utils() { throw new UnsupportedOperationException() } 12 | 13 | static String getResource(Project project, String resourcePath) { 14 | Set files = new HashSet<>() 15 | files += project.buildscript.configurations.classpath.resolve() 16 | files += project.rootProject.buildscript.configurations.classpath.resolve() 17 | File file = files.find { new JarFile(it).getJarEntry(resourcePath) } 18 | if (file == null) { 19 | return null 20 | } else { 21 | JarFile jarFile = new JarFile(file) 22 | JarEntry jarEntry = jarFile.getJarEntry(resourcePath) 23 | return jarFile.getInputStream(jarEntry).text 24 | } 25 | } 26 | 27 | static List getAndroidSources(Project project) { 28 | if (project.plugins.hasPlugin("com.android.application") 29 | || project.plugins.hasPlugin("com.android.library")) { 30 | project.android.sourceSets.inject([]) { 31 | dirs, sourceSet -> dirs + sourceSet.java.srcDirs 32 | } 33 | } else if (project.plugins.hasPlugin("java")) { 34 | def dirs = new ArrayList() 35 | project.sourceSets.forEach { 36 | it.getAllJava().getSrcDirs().forEach { 37 | dirs.add(it) 38 | } 39 | } 40 | return dirs 41 | } else { 42 | throw new GradleException("No Android or Java sources found") 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /plugin/src/main/groovy/org/stoyicker/androidcheck/checkstyle/CheckstyleCheck.groovy: -------------------------------------------------------------------------------- 1 | package org.stoyicker.androidcheck.checkstyle 2 | 3 | import com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask 4 | import com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask.Formatter 5 | import com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask.FormatterType 6 | import groovy.util.slurpersupport.GPathResult 7 | import org.stoyicker.androidcheck.CheckExtension 8 | import org.stoyicker.androidcheck.CommonCheck 9 | import org.stoyicker.androidcheck.CommonConfig 10 | import org.gradle.api.Project 11 | 12 | class CheckstyleCheck extends CommonCheck { 13 | 14 | CheckstyleCheck() { super('checkstyle', 'androidCheckstyle', 'Runs Android Checkstyle') } 15 | 16 | @Override 17 | protected CommonConfig getConfig(CheckExtension extension) { return extension.checkstyle } 18 | 19 | @Override 20 | protected void performCheck(Project project, List sources, 21 | File configFile, File xmlReportFile) { 22 | CheckstyleAntTask checkStyleTask = new CheckstyleAntTask() 23 | 24 | checkStyleTask.project = project.ant.antProject 25 | checkStyleTask.config = configFile.absolutePath 26 | checkStyleTask.addFormatter(new Formatter(type: new FormatterType(value: 'xml'), tofile: xmlReportFile)) 27 | 28 | checkStyleTask.failOnViolation = false 29 | 30 | sources.findAll { it.exists() }.each { 31 | checkStyleTask.addFileset(project.ant.fileset(dir: it)) 32 | } 33 | 34 | checkStyleTask.perform() 35 | } 36 | 37 | @Override 38 | protected int getErrorCount(File xmlReportFile) { 39 | GPathResult xml = new XmlSlurper().parseText(xmlReportFile.text) 40 | return xml.file.inject(0) { count, file -> count + file.error.size() } 41 | } 42 | 43 | @Override 44 | protected String getErrorMessage(int errorCount, File htmlReportFile) { 45 | return "$errorCount Checkstyle rule violations were found. See the report at: ${htmlReportFile.toURI()}" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /plugin/src/main/groovy/org/stoyicker/androidcheck/checkstyle/CheckstyleConfig.groovy: -------------------------------------------------------------------------------- 1 | package org.stoyicker.androidcheck.checkstyle 2 | 3 | import org.stoyicker.androidcheck.CommonConfig 4 | import org.gradle.api.Project 5 | 6 | class CheckstyleConfig extends CommonConfig { 7 | 8 | CheckstyleConfig(Project project) { super(project) } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /plugin/src/main/groovy/org/stoyicker/androidcheck/pmd/PmdCheck.groovy: -------------------------------------------------------------------------------- 1 | package org.stoyicker.androidcheck.pmd 2 | 3 | import net.sourceforge.pmd.ant.Formatter 4 | import groovy.util.slurpersupport.GPathResult 5 | import org.stoyicker.androidcheck.CheckExtension 6 | import org.stoyicker.androidcheck.CommonCheck 7 | import org.stoyicker.androidcheck.CommonConfig 8 | import net.sourceforge.pmd.ant.PMDTask 9 | import org.gradle.api.Project 10 | 11 | import java.nio.file.Paths 12 | 13 | class PmdCheck extends CommonCheck { 14 | 15 | PmdCheck() { super('pmd', 'androidPmd', 'Runs Android PMD') } 16 | 17 | @Override 18 | protected CommonConfig getConfig(CheckExtension extension) { return extension.pmd } 19 | 20 | @Override 21 | protected void performCheck(Project project, List sources, 22 | File configFile, File xmlReportFile) { 23 | PMDTask pmdTask = new PMDTask() 24 | 25 | pmdTask.cacheLocation = new File("./build/.pmd-cache") 26 | pmdTask.project = project.ant.antProject 27 | pmdTask.ruleSetFiles = configFile.toString() 28 | pmdTask.addFormatter(new Formatter(type: 'xml', toFile: xmlReportFile)) 29 | 30 | pmdTask.failOnError = false 31 | pmdTask.failOnRuleViolation = false 32 | 33 | sources.findAll { it.exists() }.each { 34 | pmdTask.addFileset(project.ant.fileset(dir: it)) 35 | } 36 | 37 | pmdTask.perform() 38 | } 39 | 40 | @Override 41 | protected int getErrorCount(File xmlReportFile) { 42 | GPathResult xml = new XmlSlurper().parseText(xmlReportFile.text) 43 | return xml.file.inject(0) { count, file -> count + file.violation.size() } 44 | } 45 | 46 | @Override 47 | protected String getErrorMessage(int errorCount, File htmlReportFile) { 48 | return "$errorCount Checkstyle rule violations were found. See the report at: ${htmlReportFile.toURI()}" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /plugin/src/main/groovy/org/stoyicker/androidcheck/pmd/PmdConfig.groovy: -------------------------------------------------------------------------------- 1 | package org.stoyicker.androidcheck.pmd 2 | 3 | import org.stoyicker.androidcheck.CommonConfig 4 | import org.gradle.api.Project 5 | 6 | class PmdConfig extends CommonConfig { 7 | 8 | PmdConfig(Project project) { super(project) } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /plugin/src/main/resources/META-INF/gradle-plugins/org.stoyicker.android-check.properties: -------------------------------------------------------------------------------- 1 | implementation-class=org.stoyicker.androidcheck.CheckPlugin 2 | -------------------------------------------------------------------------------- /plugin/src/main/resources/checkstyle/checkstyle.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 83 | 84 | 85 | 86 | 87 | 88 |
79 | 82 |

CheckStyle Audit

Designed for use with CheckStyle and Ant.
89 |
90 | 91 | 92 | 93 |
94 | 95 | 96 | 97 |
98 | 99 | 100 | 101 | 102 |
103 | 104 | 105 | 106 | 107 |
108 | 109 | 110 | 111 | 112 |

Files

113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 |
NameErrors
129 |
130 | 131 | 132 | 133 | 134 |

File

135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 |
Error DescriptionLine
150 | Back to top 151 |
152 | 153 | 154 | 155 |

Summary

156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 |
FilesErrors
169 |
170 | 171 | 172 | 173 | a 174 | b 175 | 176 | 177 |
178 | 179 | -------------------------------------------------------------------------------- /plugin/src/main/resources/checkstyle/conf-default.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 65 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 90 | 91 | 92 | 94 | 95 | 96 | 97 | 99 | 100 | 101 | 102 | 104 | 105 | 112 | 113 | 114 | 115 | 116 | 118 | 119 | 120 | 121 | 123 | 124 | 125 | 126 | 128 | 129 | 130 | 131 | 133 | 134 | 135 | 136 | 138 | 140 | 142 | 144 | 145 | 155 | 156 | 157 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 199 | 200 | 201 | 203 | 204 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | -------------------------------------------------------------------------------- /plugin/src/main/resources/pmd/conf-default.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | POM rule set file 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /plugin/src/main/resources/pmd/pmd.xsl: -------------------------------------------------------------------------------- 1 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | - 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | PMD <xsl:value-of select="//pmd:pmd/@version"/> Report 24 | 81 | 82 | 83 | 84 | 85 | 86 | 88 | 89 | 90 |
87 |

PMD Report. Generated on

91 |
92 | 93 | 94 | 95 |
96 | 97 | 98 | 99 |
100 | 101 | 102 | 103 |
104 | 105 | 106 | 107 | 108 |
109 | 110 | 111 | 112 | 113 |
114 | 115 | 116 | 117 | 118 |

Rules

119 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 129 | 130 | 132 | 133 | 134 | 135 | 137 | 138 | 139 | 140 | 143 | 146 | 150 | 151 | 152 | 153 |
RuleViolationsSeverity
141 | [] 142 | 144 | 145 |
147 | 148 |
149 |
154 |
155 | 156 | 157 | 158 | 159 |

Files

160 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 173 | 174 | 176 | 177 | 178 | 179 | 180 | 181 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 |
File
5
4
3
2
1
182 | 183 | 184 |
194 |
195 | 196 | 197 | 198 | 199 | 200 | 201 |

File

202 | 203 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 217 | 227 | 230 | 231 | 232 |
ViolationError DescriptionLine
215 |
216 |
218 | [.] 219 | - 220 | 221 | 222 | 223 | 224 | 225 | 226 | 228 | - 229 |
233 | Back to top 234 |
235 | 236 | 237 | 238 | 239 |

Summary

240 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 |
FilesTotal
Priority 1
Priority 2
Priority 3
Priority 4
Priority 5
262 |
263 | 264 | 265 | 266 | 267 | a 268 | b 269 | 270 | 271 |
272 | -------------------------------------------------------------------------------- /sample/app/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenLocal() 4 | google() 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.2.1' 9 | //noinspection GradleDynamicVersion 10 | classpath 'org.stoyicker.android-check:plugin:+' 11 | } 12 | } 13 | 14 | apply plugin: 'com.android.application' 15 | apply plugin: 'org.stoyicker.android-check' 16 | 17 | android { 18 | compileSdkVersion 27 19 | buildToolsVersion '28.0.3' 20 | defaultConfig { 21 | versionCode 1 22 | versionName '1.0' 23 | minSdkVersion 14 24 | targetSdkVersion 27 25 | } 26 | compileOptions { 27 | sourceCompatibility JavaVersion.VERSION_1_7 28 | targetCompatibility JavaVersion.VERSION_1_7 29 | } 30 | lintOptions { 31 | abortOnError true 32 | checkAllWarnings true 33 | } 34 | } 35 | repositories { 36 | google() 37 | jcenter() 38 | } 39 | dependencies { 40 | implementation project(':libs:sample-java-library') 41 | } 42 | check { 43 | abortOnError(false) 44 | pmd { 45 | reportHTML(new File(project.buildDir, "reports/pmd/pmd.html")) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /sample/app/lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /sample/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 12 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /sample/app/src/main/assets/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Example%nopex 8 | 9 | 10 | %d{HH:mm:ss.SSS} %logger - %msg 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /sample/app/src/main/java/plugin/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package plugin.example; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.util.Log; 6 | 7 | public class MainActivity extends Activity { 8 | 9 | // CR Code Review 10 | 11 | // TODO To Do 12 | 13 | @Override 14 | public void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.main); 17 | final String processed = JavaLibrary.process(this); 18 | if (BuildConfig.DEBUG) { 19 | Log.d("MainActivity", "MainActivity::onCreate"); 20 | Log.d("MainActivity.process", processed); 21 | } 22 | 23 | new Thread() { 24 | @Override 25 | public void run() { 26 | try { 27 | Object object = ""; 28 | Double value = (Double) object; 29 | } catch (Exception e) { 30 | 31 | } 32 | 33 | "".length(); 34 | } 35 | }.start(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /sample/app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stoyicker/android-check-2/b4443d3aa5cd633b61c928bd9201b97e1651b99e/sample/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stoyicker/android-check-2/b4443d3aa5cd633b61c928bd9201b97e1651b99e/sample/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stoyicker/android-check-2/b4443d3aa5cd633b61c928bd9201b97e1651b99e/sample/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stoyicker/android-check-2/b4443d3aa5cd633b61c928bd9201b97e1651b99e/sample/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/app/src/main/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /sample/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Example 5 | Hello, world! 6 | 7 | -------------------------------------------------------------------------------- /sample/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stoyicker/android-check-2/b4443d3aa5cd633b61c928bd9201b97e1651b99e/sample/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sample/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /sample/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /sample/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /sample/libs/sample-java-library/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenLocal() 4 | google() 5 | jcenter() 6 | } 7 | dependencies { 8 | //noinspection GradleDynamicVersion 9 | classpath 'org.stoyicker.android-check:plugin:+' 10 | } 11 | } 12 | 13 | apply plugin: 'java' 14 | 15 | sourceCompatibility = JavaVersion.VERSION_1_7 16 | targetCompatibility = JavaVersion.VERSION_1_7 17 | -------------------------------------------------------------------------------- /sample/libs/sample-java-library/src/main/java/plugin/example/JavaLibrary.java: -------------------------------------------------------------------------------- 1 | package plugin.example; 2 | 3 | import java.lang.Object; 4 | 5 | public final class JavaLibrary { 6 | 7 | private JavaLibrary() { 8 | throw new UnsupportedOperationException(); 9 | } 10 | 11 | public static String process(Object ignored) { 12 | return "a result"; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /sample/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':libs:sample-java-library', ':app' 2 | rootProject.name = 'sample' 3 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':plugin', ':sample' 2 | rootProject.name = 'android-check-2' 3 | --------------------------------------------------------------------------------