├── config ├── jarjar │ ├── rule.txt │ └── jarjar-1.4.jar └── setupEnv ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src ├── main │ ├── resources │ │ ├── META-INF │ │ │ └── gradle-plugins │ │ │ │ └── si.kamino.soter.properties │ │ └── config │ │ │ └── xsl │ │ │ └── checkstyle.xsl │ └── groovy │ │ └── si │ │ └── kamino │ │ └── gradle │ │ ├── extensions │ │ ├── PMDExtension.groovy │ │ ├── DocsExtension.groovy │ │ ├── FabricExtension.groovy │ │ ├── LogsExtension.groovy │ │ ├── CodeCoverageExtension.groovy │ │ ├── AmazonApkExtension.groovy │ │ ├── TestsExtension.groovy │ │ ├── PluginBaseExtension.groovy │ │ ├── FindbugsExtension.groovy │ │ ├── AmazonExtension.groovy │ │ ├── RemoteExtension.groovy │ │ ├── AfterAllExtension.groovy │ │ ├── PublishExtension.groovy │ │ ├── CheckstyleExtension.groovy │ │ └── SoterExtension.groovy │ │ ├── task │ │ ├── FindBugs.groovy │ │ ├── PushRemoteTask.groovy │ │ ├── Pmd.groovy │ │ ├── Checkstyle.groovy │ │ ├── UploadTask.groovy │ │ └── AfterAllTask.groovy │ │ ├── SoterPlugin.groovy │ │ ├── commons │ │ └── Utils.groovy │ │ └── manager │ │ └── TaskManager.groovy └── test │ └── groovy │ └── si │ └── kamino │ └── gradle │ └── manager │ ├── SoterPluginTest.groovy │ └── TaskManagerTest.groovy ├── .gitignore ├── settings.gradle ├── gradle.properties ├── LICENSE ├── gradlew.bat ├── maven_push.gradle ├── README.md ├── CHANGELOG.md └── gradlew /config/jarjar/rule.txt: -------------------------------------------------------------------------------- 1 | rule org.apache.http.** si.kamino.http@1 -------------------------------------------------------------------------------- /config/jarjar/jarjar-1.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agb-mobile/soter/HEAD/config/jarjar/jarjar-1.4.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agb-mobile/soter/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/si.kamino.soter.properties: -------------------------------------------------------------------------------- 1 | implementation-class=si.kamino.gradle.SoterPlugin 2 | -------------------------------------------------------------------------------- /config/setupEnv: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export GITHUB_TOKEN=your_token 4 | export TRAVIS_BUILD_NUMBER=454.1 5 | export TRAVIS_BUILD_ID=9437567 6 | export TRAVIS_BRANCH=localTest 7 | 8 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/extensions/PMDExtension.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.extensions 2 | /** 3 | * Created by blazsolar on 02/09/14. 4 | */ 5 | class PMDExtension extends PluginBaseExtension { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/extensions/DocsExtension.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.extensions 2 | 3 | /** 4 | * Created by blazsolar on 11/01/15. 5 | */ 6 | class DocsExtension extends PluginBaseExtension { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/extensions/FabricExtension.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.extensions 2 | 3 | /** 4 | * Created by blazsolar on 02/09/14. 5 | */ 6 | class FabricExtension { 7 | 8 | boolean upload = false; 9 | String[] variants = ["release"] 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/extensions/LogsExtension.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.extensions 2 | 3 | import org.gradle.api.tasks.Input 4 | 5 | /** 6 | * Created by blazsolar on 02/09/14. 7 | */ 8 | class LogsExtension { 9 | 10 | @Input boolean uploadReports = false; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/extensions/CodeCoverageExtension.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.extensions 2 | 3 | import org.gradle.api.tasks.Input 4 | 5 | /** 6 | * Created by blazsolar on 11/01/15. 7 | */ 8 | class CodeCoverageExtension { 9 | 10 | @Input boolean uploadReports = false; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/extensions/AmazonApkExtension.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.extensions 2 | 3 | /** 4 | * Created by blazsolar on 02/09/14. 5 | */ 6 | class AmazonApkExtension { 7 | 8 | boolean upload = false; 9 | boolean uploadMapping = false; 10 | String[] variants = ["release"] 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/extensions/TestsExtension.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.extensions 2 | 3 | import org.gradle.api.tasks.Input 4 | 5 | /** 6 | * Created by blazsolar on 02/09/14. 7 | */ 8 | class TestsExtension { 9 | 10 | @Input boolean uploadAndroidTestReports = false; 11 | @Input boolean uploadUnitTestReports = false; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/extensions/PluginBaseExtension.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.extensions 2 | 3 | import org.gradle.api.tasks.Input 4 | 5 | /** 6 | * Created by blazsolar on 11/09/14. 7 | */ 8 | class PluginBaseExtension { 9 | 10 | @Input boolean enabled = true 11 | @Input boolean uploadReports = false 12 | @Input boolean ignoreFailures = false 13 | 14 | } 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | #built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # OSX files 19 | .DS_Store 20 | 21 | # Android Studio 22 | .idea 23 | .gradle 24 | build/ 25 | *.iml 26 | *.iws 27 | *.ipr 28 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/extensions/FindbugsExtension.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.extensions 2 | 3 | import org.gradle.api.tasks.Input 4 | 5 | /** 6 | * Created by blazsolar on 02/09/14. 7 | */ 8 | class FindbugsExtension extends PluginBaseExtension { 9 | 10 | @Input String effort = "max" 11 | @Input String reportLevel = "low" 12 | @Input String reportType = "html" 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/extensions/AmazonExtension.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.extensions 2 | 3 | import org.gradle.api.tasks.Input 4 | 5 | /** 6 | * Created by blazsolar on 02/09/14. 7 | */ 8 | class AmazonExtension { 9 | 10 | @Input boolean enabled = false 11 | @Input String accessKey 12 | @Input String secretKey 13 | @Input String bucket 14 | @Input String path = "" 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/extensions/RemoteExtension.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.extensions 2 | 3 | import org.gradle.api.tasks.Input 4 | 5 | /** 6 | * Created by blazsolar on 10/11/14. 7 | */ 8 | class RemoteExtension { 9 | 10 | @Input boolean pushToRemote = false; 11 | @Input String gitRoot; 12 | @Input String remote 13 | @Input String branch 14 | @Input String username; 15 | @Input String password; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This settings file was auto generated by the Gradle buildInit task 3 | * by 'blazsolar' at '9/2/14 11:22 AM' with Gradle 1.12 4 | * 5 | * The settings file is used to specify which projects to include in your build. 6 | * In a single project build this file can be empty or even removed. 7 | * 8 | * Detailed information about configuring a multi-project build in Gradle can be found 9 | * in the user guide at http://gradle.org/docs/1.12/userguide/multi_project_builds.html 10 | */ 11 | 12 | rootProject.name = projectName 13 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | projectGroup=si.kamino.gradle 2 | projectName=soter 3 | projectVersion=2.1.4 4 | 5 | POM_NAME=Soter 6 | POM_DESCRIPTION=Android gradle plugin that adds Checkstyle, Findbugs and PMD functionality 7 | POM_URL=https://github.com/kaminomobile/soter 8 | POM_INCEPTION_YEAR=2014 9 | POM_ORGANIZATION_NAME=Kamino 10 | POM_ORGANIZATION_URL=https://github.com/kaminomobile 11 | POM_SCM_URL=https://github.com/kaminomobile/soter 12 | POM_SCM_CONNECTION=scm:git@github.com:kaminomobile/soter.git 13 | POM_SCM_DEV_CONNECTION=scm:git@github.com:kaminomobile/soter.git 14 | 15 | POM_PACKAGING=jar 16 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/extensions/AfterAllExtension.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.extensions 2 | 3 | import org.gradle.api.tasks.Input 4 | 5 | /** 6 | * Created by blazsolar on 02/09/14. 7 | */ 8 | class AfterAllExtension { 9 | 10 | private static final def TRAVIS_JOB_NUMBER = "TRAVIS_JOB_NUMBER" 11 | private static final def TRAVIS_BUILD_ID = "TRAVIS_BUILD_ID" 12 | 13 | @Input String buildID = System.getenv(TRAVIS_BUILD_ID) 14 | @Input String jobNumber = System.getenv(TRAVIS_JOB_NUMBER) 15 | @Input String ghToken 16 | @Input long pollingInterval = 5000 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/extensions/PublishExtension.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.extensions 2 | 3 | import org.gradle.api.Action 4 | import org.gradle.api.tasks.Input 5 | import org.gradle.internal.reflect.Instantiator 6 | 7 | /** 8 | * Created by blazsolar on 03/10/14. 9 | */ 10 | class PublishExtension { 11 | 12 | @Input boolean enabled = true 13 | final AmazonApkExtension amazon; 14 | final FabricExtension fabric; 15 | 16 | PublishExtension(Instantiator instantiator) { 17 | amazon = instantiator.newInstance(AmazonApkExtension) 18 | fabric = instantiator.newInstance(FabricExtension) 19 | } 20 | 21 | void amazon(Action action) { 22 | action.execute(amazon) 23 | } 24 | 25 | void fabric(Action action) { 26 | action.execute(fabric) 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/test/groovy/si/kamino/gradle/manager/SoterPluginTest.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.manager 2 | import org.gradle.api.Project 3 | import org.gradle.api.internal.plugins.PluginApplicationException 4 | import org.gradle.testfixtures.ProjectBuilder 5 | import org.junit.Test 6 | 7 | import static org.junit.Assert.assertTrue 8 | import static org.junit.Assert.fail 9 | /** 10 | * Created by blazsolar on 18/04/15. 11 | */ 12 | class SoterPluginTest { 13 | 14 | @Test 15 | public void testNoAndroidPlugin() throws Exception { 16 | 17 | try { 18 | Project project = ProjectBuilder.builder().build() 19 | project.apply plugin: 'si.kamino.soter' 20 | fail "Should require android plugin" 21 | } catch (PluginApplicationException e) { 22 | assertTrue e.cause instanceof IllegalStateException 23 | } 24 | 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/extensions/CheckstyleExtension.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.extensions 2 | 3 | import org.gradle.api.tasks.Input 4 | 5 | /** 6 | * Created by blazsolar on 02/09/14. 7 | */ 8 | class CheckstyleExtension extends PluginBaseExtension { 9 | 10 | @Input boolean showViolations = false 11 | @Input boolean enableXml = true 12 | @Input boolean enableHtml = true 13 | @Input boolean defaultHtmlReport = false 14 | 15 | private int maxErrors; 16 | private int maxWarnings = Integer.MAX_VALUE; 17 | 18 | String toolVersion = "7.4" 19 | 20 | public int getMaxErrors() { 21 | return maxErrors; 22 | } 23 | 24 | public void setMaxErrors(int maxErrors) { 25 | this.maxErrors = maxErrors; 26 | } 27 | 28 | int getMaxWarnings() { 29 | return maxWarnings 30 | } 31 | 32 | void setMaxWarnings(int maxWarnings) { 33 | this.maxWarnings = maxWarnings 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/task/FindBugs.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.task 2 | 3 | import org.gradle.api.tasks.TaskAction 4 | import si.kamino.gradle.extensions.FindbugsExtension 5 | 6 | /** 7 | * Created by blazsolar on 07/04/15. 8 | */ 9 | class FindBugs extends org.gradle.api.plugins.quality.FindBugs { 10 | 11 | @Override @TaskAction 12 | void run() { 13 | 14 | excludeFilter = project.configurations.findbugsRules.singleFile 15 | 16 | super.run() 17 | } 18 | 19 | void setup(FindbugsExtension extension) { 20 | 21 | description "Findbugs for debug source" 22 | group "Check" 23 | 24 | ignoreFailures extension.ignoreFailures 25 | effort extension.effort 26 | reportLevel extension.reportLevel 27 | classes = project.files("$project.buildDir/intermediates/classes") 28 | 29 | include '**/*.java' 30 | exclude '**/gen/**' 31 | 32 | classpath = project.files() 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 D·Labs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/task/PushRemoteTask.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.task 2 | 3 | import org.ajoberstar.grgit.Credentials 4 | import org.ajoberstar.grgit.Grgit 5 | import org.gradle.api.DefaultTask 6 | import org.gradle.api.tasks.TaskAction 7 | /** 8 | * Created by blazsolar on 10/11/14. 9 | */ 10 | class PushRemoteTask extends DefaultTask { 11 | 12 | String gitDir = project.rootDir; 13 | 14 | String remote; 15 | String branch 16 | String username; 17 | String password; 18 | 19 | private def grgit; 20 | 21 | @TaskAction 22 | public void push() { 23 | 24 | if (remote) { 25 | 26 | grgit = Grgit.open(dir: gitDir, creds: new Credentials(username, password)) 27 | 28 | if (!branch) { 29 | branch = grgit.branch.current.getName() 30 | } 31 | 32 | grgit.remote.add(name: 'soter', url: remote) 33 | grgit.push(all: false, remote: 'soter', tags: true, refsOrSpecs: ["refs/heads/$branch:refs/heads/$branch"]) 34 | 35 | 36 | } else { 37 | throw new IllegalStateException("Remote cannot be null"); 38 | } 39 | 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/task/Pmd.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.task 2 | 3 | import com.android.SdkConstants 4 | import com.android.build.gradle.api.AndroidSourceSet 5 | import org.gradle.api.tasks.TaskAction 6 | import si.kamino.gradle.commons.Utils 7 | import si.kamino.gradle.extensions.PMDExtension 8 | 9 | /** 10 | * Created by blazsolar on 07/04/15. 11 | */ 12 | class Pmd extends org.gradle.api.plugins.quality.Pmd { 13 | 14 | @Override @TaskAction 15 | void run() { 16 | 17 | ruleSetFiles = project.files(project.configurations.pmdRules.files) 18 | 19 | super.run() 20 | } 21 | 22 | void setup(PMDExtension extension) { 23 | 24 | description "PMD for debug source" 25 | group "Check" 26 | 27 | ignoreFailures = extension.ignoreFailures 28 | ruleSets = ["java-basic", "java-braces", "java-strings", "java-android"] 29 | 30 | def sets; 31 | if (Utils.is140orAbove()) { 32 | sets = project.android.sourceSets; 33 | } else { 34 | sets = project.android.sourceSetsContainer; 35 | } 36 | 37 | sets.all { AndroidSourceSet sourceSet -> 38 | if (!sourceSet.name.startsWith("test") && !sourceSet.name.startsWith(SdkConstants.FD_TEST)) { 39 | source sourceSet.java.srcDirs 40 | } 41 | } 42 | 43 | include '**/*.java' 44 | exclude '**/gen/**' 45 | 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/test/groovy/si/kamino/gradle/manager/TaskManagerTest.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.manager 2 | 3 | import org.gradle.api.Project 4 | import org.gradle.testfixtures.ProjectBuilder 5 | import org.junit.Test 6 | import si.kamino.gradle.SoterPlugin 7 | import si.kamino.gradle.task.Checkstyle 8 | import si.kamino.gradle.task.UploadTask 9 | 10 | import static org.junit.Assert.assertTrue 11 | 12 | /** 13 | * Created by blazsolar on 18/04/15. 14 | */ 15 | class TaskManagerTest { 16 | 17 | @Test 18 | public void testCheckstyleBasicApp() throws Exception { 19 | 20 | Project project = ProjectBuilder.builder().build() 21 | project.apply plugin: 'com.android.application' 22 | project.apply plugin: 'si.kamino.soter' 23 | 24 | SoterPlugin plugin = project.plugins.getPlugin(SoterPlugin) 25 | 26 | plugin.createCheckTasks() 27 | 28 | assertTrue project.tasks.findByName("checkstyle") instanceof Checkstyle 29 | assertTrue project.tasks.findByName("uploadCheckstyle") instanceof UploadTask 30 | 31 | } 32 | 33 | @Test 34 | public void testCheckstyleBasicLib() throws Exception { 35 | 36 | Project project = ProjectBuilder.builder().build() 37 | project.apply plugin: 'com.android.library' 38 | project.apply plugin: 'si.kamino.soter' 39 | 40 | SoterPlugin plugin = project.plugins.getPlugin(SoterPlugin) 41 | 42 | plugin.createCheckTasks() 43 | 44 | assertTrue project.tasks.findByName("checkstyle") instanceof Checkstyle 45 | assertTrue project.tasks.findByName("uploadCheckstyle") instanceof UploadTask 46 | 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/SoterPlugin.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle 2 | 3 | import com.android.annotations.VisibleForTesting 4 | import org.gradle.api.Plugin 5 | import org.gradle.api.Project 6 | import org.gradle.internal.reflect.Instantiator 7 | import si.kamino.gradle.extensions.SoterExtension 8 | import si.kamino.gradle.manager.TaskManager 9 | 10 | import javax.inject.Inject 11 | /** 12 | * Created by blazsolar on 02/09/14.z 13 | */ 14 | class SoterPlugin implements Plugin { 15 | 16 | private final Instantiator instantiator 17 | 18 | private Project project; 19 | private TaskManager taskManager; 20 | 21 | private SoterExtension extension; 22 | 23 | @Inject 24 | SoterPlugin(Instantiator instantiator) { 25 | this.instantiator = instantiator 26 | } 27 | 28 | def isAndroidProject(Project project) { 29 | project.plugins.hasPlugin('com.android.application') || project.plugins.hasPlugin('com.android.library') || project.plugins.hasPlugin('com.android.test') 30 | } 31 | 32 | @Override 33 | void apply(Project project) { 34 | if (!isAndroidProject(project)) { 35 | throw new IllegalStateException("SoterPlugin only works with Android projects but \"${project.name}\" is none") 36 | } 37 | 38 | this.project = project; 39 | 40 | createExtensions() 41 | createTasks() 42 | } 43 | 44 | private void createExtensions() { 45 | extension = project.extensions.create('soter', SoterExtension, 46 | instantiator) 47 | taskManager = new TaskManager(project, extension); 48 | } 49 | 50 | private void createTasks() { 51 | 52 | taskManager.createTasks() 53 | 54 | project.afterEvaluate { 55 | createCheckTasks() 56 | } 57 | 58 | } 59 | 60 | @VisibleForTesting(visibility = VisibleForTesting.Visibility.PROTECTED) 61 | final void createCheckTasks() { 62 | taskManager.createCheckTasks() 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/task/Checkstyle.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.task 2 | 3 | import com.android.SdkConstants 4 | import com.android.build.gradle.api.AndroidSourceSet 5 | import si.kamino.gradle.commons.Utils 6 | import org.gradle.api.tasks.TaskAction 7 | import si.kamino.gradle.extensions.CheckstyleExtension 8 | 9 | /** 10 | * Created by blazsolar on 07/04/15. 11 | */ 12 | class Checkstyle extends org.gradle.api.plugins.quality.Checkstyle { 13 | 14 | @Override @TaskAction 15 | void run() { 16 | 17 | configFile project.configurations.checkstyleRules.singleFile 18 | 19 | super.run() 20 | } 21 | 22 | void setup(CheckstyleExtension extension) { 23 | 24 | description "Checkstyle for debug source" 25 | group "Check" 26 | 27 | ignoreFailures extension.ignoreFailures 28 | showViolations extension.showViolations 29 | 30 | if (Utils.isGradle34orAbove(project)) { 31 | maxErrors extension.maxErrors 32 | maxWarnings extension.maxWarnings 33 | } else { 34 | if (extension.maxErrors != 0) { 35 | logger.warn("To use soter.checkstyle.maxErrors you have to update gradle to 3.4 or above") 36 | } 37 | 38 | if (extension.maxWarnings != Integer.MAX_VALUE) { 39 | logger.warn("To use soter.checkstyle.maxWarnings you have to update gradle to 3.4 or above") 40 | } 41 | } 42 | 43 | def sets 44 | if (Utils.is140orAbove()) { 45 | sets = project.android.sourceSets; 46 | } else { 47 | sets = project.android.sourceSetsContainer; 48 | } 49 | 50 | sets.all { AndroidSourceSet sourceSet -> 51 | if (!sourceSet.name.startsWith("test") && !sourceSet.name.startsWith(SdkConstants.FD_TEST)) { 52 | source sourceSet.java.srcDirs 53 | } 54 | } 55 | 56 | include '**/*.java' 57 | exclude '**/gen/**' 58 | 59 | classpath = project.files() 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/task/UploadTask.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.task 2 | import com.amazonaws.auth.AWSCredentials 3 | import com.amazonaws.auth.BasicAWSCredentials 4 | import com.amazonaws.services.s3.AmazonS3 5 | import com.amazonaws.services.s3.AmazonS3Client 6 | import com.amazonaws.services.s3.model.CannedAccessControlList 7 | import com.amazonaws.services.s3.model.PutObjectRequest 8 | import org.gradle.api.DefaultTask 9 | import org.gradle.api.tasks.TaskAction 10 | /** 11 | * Created by blazsolar on 16/09/14. 12 | */ 13 | class UploadTask extends DefaultTask { 14 | 15 | String accessKey; 16 | 17 | String secretKey; 18 | 19 | String bucket; 20 | 21 | File[] files; 22 | 23 | String keyPrefix = "" 24 | 25 | boolean isPublic = false; 26 | 27 | private AmazonS3 mAmazonS3; 28 | 29 | @TaskAction 30 | public void upload() { 31 | 32 | AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey); 33 | mAmazonS3 = new AmazonS3Client(credentials); 34 | 35 | files.each { File file -> 36 | if (file.isDirectory()) { 37 | uploadDir("", file) 38 | } else { 39 | uploadFile("", file) 40 | } 41 | } 42 | 43 | } 44 | 45 | void uploadFile(String path, File file) { 46 | def putObjectRequest = new PutObjectRequest( 47 | bucket, keyPrefix + path + file.getName(), file 48 | ) 49 | 50 | if (isPublic) { 51 | putObjectRequest.setCannedAcl(CannedAccessControlList.PublicRead) 52 | } else { 53 | putObjectRequest.setCannedAcl(CannedAccessControlList.Private) 54 | } 55 | 56 | mAmazonS3.putObject(putObjectRequest); 57 | } 58 | 59 | void uploadDir(String path, File dir) { 60 | path += dir.getName() + "/"; 61 | 62 | for (File file : dir.listFiles()) { 63 | if (file.isDirectory()) { 64 | uploadDir(path, file) 65 | } else { 66 | uploadFile(path, file) 67 | } 68 | } 69 | } 70 | 71 | public void setFile(File file) { 72 | files = [ file ]; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/commons/Utils.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.commons 2 | 3 | import org.gradle.api.Project 4 | /** 5 | * Created by blazsolar on 01/09/15. 6 | */ 7 | class Utils { 8 | 9 | public static boolean isGradle34orAbove(Project project) { 10 | return versionCompare(project.gradle.gradleVersion, "3.4") >= 0; 11 | } 12 | 13 | public static boolean is140orAbove() { 14 | return versionCompare(com.android.builder.model.Version.ANDROID_GRADLE_PLUGIN_VERSION, "1.4.0") >= 0; 15 | } 16 | 17 | /** 18 | * Compares two version strings. 19 | * 20 | * Use this instead of String.compareTo() for a non-lexicographical 21 | * comparison that works for version strings. e.g. "1.10".compareTo("1.6"). 22 | * 23 | * @note It does not work if "1.10" is supposed to be equal to "1.10.0". 24 | * 25 | * @param str1 a string of ordinal numbers separated by decimal points. 26 | * @param str2 a string of ordinal numbers separated by decimal points. 27 | * @return The result is a negative integer if str1 is _numerically_ less than str2. 28 | * The result is a positive integer if str1 is _numerically_ greater than str2. 29 | * The result is zero if the strings are _numerically_ equal. 30 | */ 31 | private static int versionCompare(String str1, String str2) { 32 | String[] vals1 = str1.split("-")[0].split("\\."); 33 | String[] vals2 = str2.split("-")[0].split("\\."); 34 | int i = 0; 35 | // set index to first non-equal ordinal or length of shortest version string 36 | while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) { 37 | i++; 38 | } 39 | 40 | // compare first non-equal ordinal number 41 | if (i < vals1.length && i < vals2.length) { 42 | int diff = Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i])); 43 | return Integer.signum(diff); 44 | } 45 | 46 | // the strings are equal or one string is a substring of the other 47 | // e.g. "1.2.3" = "1.2.3" or "1.2.3" < "1.2.3.4" 48 | else { 49 | return Integer.signum(vals1.length - vals2.length); 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/extensions/SoterExtension.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.extensions 2 | import org.gradle.api.Action 3 | import org.gradle.internal.reflect.Instantiator 4 | /** 5 | * Created by blazsolar on 02/09/14. 6 | */ 7 | class SoterExtension { 8 | 9 | final CheckstyleExtension checkstyle 10 | final FindbugsExtension findbugs 11 | final PMDExtension pmd 12 | final LogsExtension logs 13 | final TestsExtension tests 14 | final DocsExtension docs 15 | final CodeCoverageExtension codeCoverage 16 | final PublishExtension publish 17 | final AmazonExtension amazon 18 | final RemoteExtension remote 19 | final AfterAllExtension afterAll 20 | 21 | SoterExtension(Instantiator instantiator) { 22 | checkstyle = instantiator.newInstance(CheckstyleExtension) 23 | findbugs = instantiator.newInstance(FindbugsExtension) 24 | pmd = instantiator.newInstance(PMDExtension) 25 | logs = instantiator.newInstance(LogsExtension) 26 | tests = instantiator.newInstance(TestsExtension) 27 | docs = instantiator.newInstance(DocsExtension) 28 | codeCoverage = instantiator.newInstance(CodeCoverageExtension) 29 | publish = instantiator.newInstance(PublishExtension, instantiator) 30 | amazon = instantiator.newInstance(AmazonExtension) 31 | remote = instantiator.newInstance(RemoteExtension) 32 | afterAll = instantiator.newInstance(AfterAllExtension) 33 | } 34 | 35 | void checkstyle(Action action) { 36 | action.execute(checkstyle) 37 | } 38 | 39 | void findbugs(Action action) { 40 | action.execute(findbugs) 41 | } 42 | 43 | void pmd(Action action) { 44 | action.execute(pmd) 45 | } 46 | 47 | void logs(Action action) { 48 | action.execute(logs) 49 | } 50 | 51 | void tests(Action action) { 52 | action.execute(tests) 53 | } 54 | 55 | void docs(Action action) { 56 | action.execute(docs) 57 | } 58 | 59 | void codeCoverage(Action action) { 60 | action.execute(codeCoverage) 61 | } 62 | 63 | void publish(Action action) { 64 | action.execute(publish) 65 | } 66 | 67 | void amazon(Action action) { 68 | action.execute(amazon) 69 | } 70 | 71 | void remote(Action action) { 72 | action.execute(remote) 73 | } 74 | 75 | void afterAll(Action action) { 76 | action.execute(afterAll) 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /maven_push.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'maven-publish' 2 | 3 | def isReleaseBuild() { 4 | return version.contains("SNAPSHOT") == false 5 | } 6 | 7 | def repoUrl = "" 8 | if (isReleaseBuild()) { 9 | println 'RELEASE BUILD' 10 | repoUrl = "s3://kamino-maven.s3.eu-central-1.amazonaws.com/plugins-snapshot/" 11 | } else { 12 | println 'DEBUG BUILD' 13 | repoUrl = "s3://kamino-maven.s3.eu-central-1.amazonaws.com/plugins-release/" 14 | } 15 | 16 | task sourceJar(type: Jar) { 17 | from sourceSets.main.allJava 18 | } 19 | 20 | publishing { 21 | publications { 22 | mavenJava(MavenPublication) { 23 | 24 | from components.java 25 | 26 | artifact sourceJar { 27 | classifier "sources" 28 | } 29 | 30 | pom.withXml { 31 | asNode().appendNode("name", POM_NAME) 32 | asNode().appendNode("description", POM_DESCRIPTION) 33 | asNode().appendNode("url", POM_URL) 34 | asNode().appendNode("inceptionYear", POM_INCEPTION_YEAR) 35 | 36 | Node organization = asNode().appendNode("organization") 37 | organization.appendNode("name", POM_ORGANIZATION_NAME) 38 | organization.appendNode("url", POM_ORGANIZATION_URL) 39 | 40 | Node developers = asNode().appendNode("developers") 41 | Node developer = developers.appendNode("developer") 42 | developer.appendNode("id", "blazsolar") 43 | developer.appendNode("name", "Blaz Solar") 44 | developer.appendNode("email", "blaz.solar@dlabs.si") 45 | developer.appendNode("organization", POM_ORGANIZATION_NAME) 46 | developer.appendNode("organizationUrl", POM_ORGANIZATION_URL) 47 | developer.appendNode("timezone", "Europe/Ljubljana") 48 | 49 | Node issue = asNode().appendNode("issueManagement") 50 | issue.appendNode("system", "Github") 51 | issue.appendNode("url", "https://github.com/kaminomobile/soter/issues") 52 | 53 | Node scm = asNode().appendNode("scm") 54 | scm.appendNode("connection", POM_SCM_CONNECTION) 55 | scm.appendNode("developerConnection", POM_SCM_DEV_CONNECTION) 56 | scm.appendNode("tag", "HEAD") 57 | scm.appendNode("url", POM_SCM_URL) 58 | 59 | } 60 | 61 | ext.repo = 'artifactory' 62 | 63 | } 64 | 65 | } 66 | 67 | repositories { 68 | maven { 69 | name 'artifactory' 70 | url repoUrl 71 | credentials(AwsCredentials) { 72 | accessKey project.hasProperty('kaminoMavenAccessKey') ? kaminoMavenAccessKey : null 73 | secretKey project.hasProperty('kaminoMavenSecretKey') ? kaminoMavenSecretKey : null 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Soter 2 | 3 | Gradle plugin that adds support for Findbugs, Checkstyle and PMD to android projects. 4 | 5 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Soter-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/1842) 6 | 7 | ## Compatibility 8 | 9 | | Android plugin | Soter | 10 | | :------------: | :----: | 11 | | 1.4.0+ | 1.0.2+ | 12 | | 1.3.0 - 1.4.0 | 1.0.1+ | 13 | | 1.2.2 - 1.3.0 | 0.6.1+ | 14 | | 1.2.0 - 1.2.2 | 0.5.2+ | 15 | 16 | ## Usage 17 | 18 | ### Apply plugin 19 | 20 | buildscript { 21 | repositories { 22 | maven { 23 | url "https://plugins.gradle.org/m2/" 24 | } 25 | } 26 | 27 | dependencies { 28 | classpath "gradle.plugin.si.kamino.gradle:soter:2.1.2" 29 | } 30 | } 31 | 32 | apply plugin: 'si.kamino.soter' 33 | 34 | ### Adding plugin rules 35 | 36 | dependencies { 37 | checkstyleRules "" 38 | findbugsRules "" 39 | pmdRules "" 40 | } 41 | 42 | ### Configuration 43 | 44 | soter { 45 | 46 | checkstyle { 47 | enabled true 48 | uploadReports true 49 | toolVersion "6.7" 50 | enableXml true 51 | enableHtml true 52 | defaultHtmlReport false 53 | maxErrors 0 54 | maxWarnings Integer.MAX_VALUES 55 | } 56 | 57 | findbugs { 58 | enabled true 59 | uploadReports true 60 | reportLevel "low" 61 | reportType "html" 62 | ignoreFailures false 63 | } 64 | 65 | pmd { 66 | enabled true 67 | uploadReports true 68 | ignoreFailures false 69 | } 70 | 71 | logs { 72 | uploadReports true 73 | } 74 | 75 | tests { 76 | uploadAndroidTestReports true 77 | uploadUnitTestReports true 78 | } 79 | 80 | docs { 81 | enabled true 82 | uploadReports true 83 | } 84 | 85 | codeCoverage { 86 | uploadReports true 87 | } 88 | 89 | publish { 90 | enabled true 91 | 92 | amazon { 93 | upload true 94 | uploadMapping true 95 | variants = ["release"] 96 | } 97 | 98 | fabric { 99 | upload true 100 | variants = ["release"] 101 | } 102 | 103 | } 104 | 105 | amazon { 106 | enabled true 107 | accessKey "" 108 | secretKey "" 109 | bucket "" 110 | path "path/in/amazon/bucket" 111 | } 112 | 113 | remote { 114 | pushToRemote true 115 | branch "" // current branch if `null` 116 | username "" 117 | password "" 118 | } 119 | 120 | afterAll { 121 | ghToken "" 122 | } 123 | 124 | } 125 | 126 | ## License 127 | 128 | The MIT License (MIT) 129 | 130 | Copyright (c) 2015 D·Labs 131 | Copyright (c) 2016 Kamino d.o.o. 132 | 133 | Permission is hereby granted, free of charge, to any person obtaining a copy 134 | of this software and associated documentation files (the "Software"), to deal 135 | in the Software without restriction, including without limitation the rights 136 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 137 | copies of the Software, and to permit persons to whom the Software is 138 | furnished to do so, subject to the following conditions: 139 | 140 | The above copyright notice and this permission notice shall be included in all 141 | copies or substantial portions of the Software. 142 | 143 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 144 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 145 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 146 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 147 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 148 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 149 | SOFTWARE. 150 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## Version 2.1.2 *(2018-01-31)* 4 | 5 | * Support for Android Gradle plugin 3.1.0. 6 | 7 | ## Version 2.1.1 *(2017-01-27)* 8 | 9 | * Updating default checkstyle version to 7.4. 10 | * Adding support for `checkstyle.maxErrors` and `checkstyle.maxWarnings` when using Gradle 3.4 or newer. 11 | 12 | ## Version 2.1.0 *(2016-12-14)* 13 | 14 | * Updating default checkstyle to version 7.3. 15 | * Adding support for enabeling and disabling xml and html reports for checkstyle. 16 | * Custom material designed HTML report for checkstyle. New report is used by default but you can still use old verion by setting `soter.checkstyle.defaultHtmlReport=true` 17 | 18 | ## Version 2.0.0 *(2016-10-25)* 19 | 20 | * Changing package name 21 | * Removing notification section that was out of scope for this plugin. 22 | * Fix for 2.2 plugin where test variants are pure application variants (by [sschuberth](https://github.com/sschuberth)) 23 | 24 | ## Version 1.0.8 *(2016-05-26)* 25 | 26 | * Support for test project fix (by [sschuberth](https://github.com/sschuberth)) 27 | 28 | ## Version 1.0.7 *(2016-05-24)* 29 | 30 | * Adding support for test project (by [sschuberth](https://github.com/sschuberth)) 31 | 32 | ## Version 1.0.6 *(2016-03-01)* 33 | 34 | * Do not explicitly depend on gradle android plugin 35 | 36 | ## Version 1.0.5 *(2016-02-20)* 37 | 38 | * Ignore failures for PMG and FindBugs (by [sschuberth](https://github.com/sschuberth)) 39 | 40 | ## Version 1.0.4 *(2015-12-21)* 41 | 42 | * XML reports for FindBugs (by [sschuberth](https://github.com/sschuberth)) 43 | 44 | ## Version 1.0.3 *(2015-09-10)* 45 | 46 | * Library support, for real this time :) 47 | 48 | ## Version 1.0.2 *(2015-09-01)* 49 | 50 | * Support for 1.4.0 android plugin 51 | * Library support (by [sschuberth](https://github.com/sschuberth)) 52 | 53 | ## Version 1.0.1 *(2015-06-05)* 54 | 55 | * Fixed bug where findbugs and checkstyle reports were not uploaded if task failed. 56 | * Findbugs now runs on all variants of the app. 57 | * Fixed bugs where findbugs would not work if app had flavors. 58 | * Default checkstyle version was set to 6.7 and can now be run against java 8 projects. You can also define which version of checkstyle to use via DSL `soter.checkstyle.toolVersion` 59 | * Compatible with 1.3.0-beta1 android plugin 60 | 61 | ## Version 1.0.0 *(2015-05-18)* 62 | 63 | * Changing package name 64 | * Changing dependencies to reduce plugin size 65 | 66 | ## Version 0.6.1 *(2015-05-05)* 67 | 68 | * Fixing and adding javadoc task 69 | * Updating push to git remote task 70 | * Adding support for uploading mapping file 71 | * Change binary folder structure for uploaded files 72 | 73 | ## Version 0.6.0 *(2015-05-03)* 74 | 75 | * Adding support for unit report upload 76 | 77 | ## Version 0.5.2 *(2015-04-27)* 78 | 79 | * Fixing report path for 1.2.0+ Android gradle plugin 80 | 81 | ## Version 0.5.1 *(2015-04-14)* 82 | 83 | * Fixing afterAll task 84 | 85 | ## Version 0.5.0 *(2015-04-12)* 86 | 87 | * Plugin is renamed to Soter 88 | * Refactor of whole plugin 89 | * Check tasks can now be executed as standalone tasks 90 | * Checkstyle task now performs checks on all non test source sets 91 | 92 | ## Version 0.4.3 *(2015-03-06)* 93 | 94 | * Multiple variants fix 95 | 96 | ## Version 0.4.2 *(2015-03-06)* 97 | 98 | * Support for deploying multiple variants 99 | 100 | ## Version 0.4.1 *(2015-02-22)* 101 | 102 | * Master job is not the last job started. 103 | 104 | ## Version 0.4.0 *(2015-01-12)* 105 | 106 | * Adding support for uploading code coverage 107 | * Adding support for generating and uploading docs 108 | * Refactoring after all feature 109 | 110 | ## Version 0.3.7 *(2014-12-18)* 111 | 112 | * Updating crashlytics deploy 113 | 114 | ## Version 0.3.6 *(2014-12-12)* 115 | 116 | * Adding support for crashlytics deploy 117 | 118 | ## Version 0.3.5 *(2014-11-30)* 119 | 120 | * Adding after all task 121 | 122 | ## Version 0.3.4 *(2014-11-10)* 123 | 124 | * Bug fixes 125 | 126 | ## Version 0.3.3 *(2014-11-10)* 127 | 128 | * Added option to push to another git remote 129 | * Added task onDone that handles successful CI build 130 | * Added task onFailed that handles unsuccessful CI build 131 | 132 | ## Version 0.3.2 *(2014-10-04)* 133 | 134 | * Abstracting deploy tasks 135 | 136 | ## Version 0.3.1 *(2014-10-03)* 137 | 138 | * Adding reading rights to uploaded reports 139 | 140 | ## Version 0.3.0 *(2014-10-02)* 141 | 142 | * Adding HipChat notifications support 143 | 144 | ## Version 0.2.1 *(2014-10-02)* 145 | 146 | * Extending DSL for findbugs plugin 147 | 148 | ## Version 0.2.0 *(2014-09-29)* 149 | 150 | * Adding support for uploading apks. 151 | * Adding support for uploading test reports. 152 | * Adding support for uploading device logs. 153 | 154 | ## Version 0.1.1 *(2015-09-23)* 155 | 156 | * Adding amazon s3 support 157 | 158 | ## Version 0.1.0 *(2014-09-09)* 159 | 160 | * Initial release 161 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/main/groovy/si/kamino/gradle/task/AfterAllTask.groovy: -------------------------------------------------------------------------------- 1 | package si.kamino.gradle.task 2 | 3 | import com.squareup.okhttp.* 4 | import groovy.json.JsonBuilder 5 | import groovy.json.JsonSlurper 6 | import org.gradle.api.DefaultTask 7 | import org.gradle.api.tasks.TaskAction 8 | 9 | import javax.net.ssl.* 10 | import java.security.SecureRandom 11 | import java.security.cert.CertificateException 12 | import java.security.cert.X509Certificate 13 | import java.text.DateFormat 14 | import java.text.SimpleDateFormat 15 | 16 | /** 17 | * Created by blazsolar on 10/11/14. 18 | */ 19 | class AfterAllTask extends DefaultTask { 20 | 21 | private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); 22 | 23 | private final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") 24 | 25 | def isLead 26 | def thisSuccess 27 | 28 | def success 29 | 30 | private def client 31 | private def pollingInterval 32 | 33 | @TaskAction 34 | public void afterAll() { 35 | 36 | client = getClient() 37 | pollingInterval = project.soter.afterAll.pollingInterval 38 | 39 | def token = getToken() 40 | 41 | if(!checkLead(token)) { 42 | System.out.println("Not lead") 43 | return 44 | } else { 45 | System.out.println("Lead") 46 | } 47 | 48 | waitForOthersToFinish(token) 49 | 50 | finish(token) 51 | 52 | } 53 | 54 | private void waitForOthersToFinish(def token) { 55 | 56 | while (true) { 57 | 58 | def finished = otherFinished(token) 59 | if (finished) { 60 | System.out.println("All jobs are finished!") 61 | break 62 | } 63 | 64 | sleep(pollingInterval) 65 | 66 | } 67 | 68 | } 69 | 70 | private String getToken() { 71 | 72 | def json = new JsonBuilder() 73 | json github_token: project.soter.afterAll.ghToken 74 | 75 | RequestBody body = RequestBody.create(JSON, json.toString()); 76 | Request request = new Request.Builder() 77 | .url("https://api.travis-ci.com/auth/github") 78 | .post(body) 79 | .build(); 80 | 81 | Response response = client.newCall(request).execute(); 82 | JsonSlurper slurper = new JsonSlurper(); 83 | def result = slurper.parseText(response.body().string()) 84 | return result.access_token 85 | 86 | } 87 | 88 | private boolean checkLead(String token) { 89 | 90 | def matrix = matrixRaw(token) 91 | 92 | def smallest = new Date(0); 93 | def smallestNumber = null; 94 | 95 | for (def m in matrix) { 96 | if (!m.started_at) { 97 | System.out.println("Not yet started: " + m.number) 98 | return false 99 | } 100 | 101 | def newDate = dateFormat.parse(m.started_at) 102 | 103 | if (newDate.after(smallest)) { 104 | smallest = newDate 105 | smallestNumber = m.number 106 | } 107 | } 108 | 109 | return project.soter.afterAll.jobNumber.equals(String.valueOf(smallestNumber)) 110 | 111 | } 112 | 113 | 114 | private def matrixRaw(def token) { 115 | 116 | Request request = new Request.Builder() 117 | .url(String.format("https://api.travis-ci.com/builds/%s?access_token=%s", project.soter.afterAll.buildID, token)) 118 | .build(); 119 | 120 | Response response = client.newCall(request).execute(); 121 | JsonSlurper slurper = new JsonSlurper(); 122 | def result = slurper.parseText(response.body().string()) 123 | 124 | return result.matrix 125 | 126 | } 127 | 128 | 129 | 130 | private MatrixElement[] matrixSnapshot(def token) { 131 | 132 | def matrix = matrixRaw(token) 133 | 134 | MatrixElement[] elements = new MatrixElement[matrix.size()]; 135 | for (int i = 0; i < matrix.size(); i++) { 136 | elements[i] = new MatrixElement(matrix[i]) 137 | } 138 | 139 | return elements 140 | 141 | 142 | } 143 | 144 | private boolean otherFinished(String token) { 145 | 146 | def snapshot = matrixSnapshot(token) 147 | def finished = true; 148 | 149 | for (def el in snapshot) { 150 | if (!el.isLeader && !el.isFinished) { 151 | finished = false; 152 | break; 153 | } 154 | } 155 | 156 | return finished 157 | 158 | } 159 | 160 | private def getClient() { 161 | 162 | // TODO not ok 163 | final TrustManager[] trustAllCertificates = [ 164 | new X509TrustManager() { 165 | 166 | @Override 167 | void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { 168 | 169 | } 170 | 171 | @Override 172 | void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { 173 | 174 | } 175 | 176 | @Override 177 | X509Certificate[] getAcceptedIssuers() { 178 | return null 179 | } 180 | } 181 | // [ 182 | // getAcceptedIssuers:{ 183 | // return null 184 | // } 185 | // ] as X509TrustManager 186 | ] 187 | 188 | final SSLContext sslContext = SSLContext.getInstance("SSL"); 189 | sslContext.init(null, trustAllCertificates, new SecureRandom()) 190 | final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory() 191 | 192 | OkHttpClient client = new OkHttpClient(); 193 | client.setSslSocketFactory(sslSocketFactory) 194 | client.setHostnameVerifier(new HostnameVerifier() { 195 | @Override 196 | boolean verify(String s, SSLSession sslSession) { 197 | return true; 198 | } 199 | }) 200 | 201 | return client; 202 | 203 | } 204 | 205 | private void finish(def token) { 206 | 207 | def snapshot = matrixSnapshot(token) 208 | 209 | boolean success = thisSuccess 210 | for (s in snapshot) { 211 | if (!s.isLeader && !s.isSucceeded) { 212 | success = false 213 | break 214 | } 215 | } 216 | 217 | this.success = success; 218 | 219 | Properties properties = new Properties(); 220 | properties.setProperty("success", Boolean.toString(success)); 221 | 222 | File propFile = new File("/tmp/ci.properties"); 223 | properties.store(propFile.newWriter(), null); 224 | 225 | } 226 | 227 | private class MatrixElement { 228 | 229 | def isFinished 230 | def isSucceeded 231 | def number 232 | 233 | def isLeader 234 | 235 | MatrixElement(def rawJson) { 236 | isFinished = rawJson.finished_at != null; 237 | isSucceeded = rawJson.result == 0 238 | number = rawJson.number 239 | isLeader = project.soter.afterAll.jobNumber.equals(String.valueOf(rawJson.number)) 240 | } 241 | } 242 | 243 | } 244 | -------------------------------------------------------------------------------- /src/main/resources/config/xsl/checkstyle.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <!DOCTYPE html> 9 | 10 | 11 | CheckStyle Report 12 | 13 | 14 | 15 | 16 | 17 |