From 25ca3490325efef7735d7b434f2a0e4b52d02a97 Mon Sep 17 00:00:00 2001 From: Jeroen van Erp Date: Mon, 6 Jun 2016 11:20:34 +0200 Subject: [PATCH] Upgraded Gradle and Android Tools --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../plugins/license/LicensePlugin.groovy | 28 +++++++-------- .../license/AndroidLicensePluginTest.groovy | 34 +++++++++---------- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/build.gradle b/build.gradle index 55ae2ec..15b4195 100644 --- a/build.gradle +++ b/build.gradle @@ -53,7 +53,7 @@ dependencies { exclude group: 'org.apache.maven', module: 'maven-plugin-api' exclude group: 'org.apache.maven', module: 'maven-project' } - compile 'com.android.tools.build:gradle:1.0.+', optional + compile 'com.android.tools.build:gradle:2.0.+', optional compile gradleApi() testCompile 'junit:junit:4.11' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d5e6376..8c6f3aa 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip diff --git a/src/main/groovy/nl/javadude/gradle/plugins/license/LicensePlugin.groovy b/src/main/groovy/nl/javadude/gradle/plugins/license/LicensePlugin.groovy index 11eba7a..acce80d 100644 --- a/src/main/groovy/nl/javadude/gradle/plugins/license/LicensePlugin.groovy +++ b/src/main/groovy/nl/javadude/gradle/plugins/license/LicensePlugin.groovy @@ -1,13 +1,13 @@ /* License added by: GRADLE-LICENSE-PLUGIN * * Copyright (C)2011 - Jeroen van Erp - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,7 +34,7 @@ class LicensePlugin implements Plugin { static final String DEFAULT_FILE_NAME_FOR_REPORTS_BY_DEPENDENCY = "dependency-license" static final String DEFAULT_FILE_NAME_FOR_REPORTS_BY_LICENSE = "license-dependency" static final String DEFAULT_DEPENDENCY_CONFIGURATION_TO_HANDLE = "runtime" - + protected Project project protected LicenseExtension extension protected DownloadLicensesExtension downloadLicensesExtension @@ -45,7 +45,7 @@ class LicensePlugin implements Plugin { protected Task baseCheckTask protected Task baseFormatTask protected Task downloadLicenseTask - + void apply(Project project) { this.project = project project.plugins.apply(ReportingBasePlugin) @@ -107,7 +107,7 @@ class LicensePlugin implements Plugin { sourceSets = { [] } } } - + logger.info("Adding license extension"); return extension @@ -157,7 +157,7 @@ class LicensePlugin implements Plugin { /** * We'll be creating the tasks by default based on the source sets, but users could define their - * own, and we'd still want it configured. + * own, and we'd still want it configured. * TODO: Confirm that user defined tasks will get this configuration, it'd have to be lazily evaluated * @param task */ @@ -281,7 +281,7 @@ class LicensePlugin implements Plugin { // This follows the other check task pattern project.plugins.withType(pluginType) { extension.sourceSets.all { sourceSet -> - def sourceSetTaskName = (taskBaseName + 'Android' + sourceSet.name.capitalize()) + def sourceSetTaskName = "${taskBaseName}Android${sourceSet.name.capitalize()}" logger.info("[AndroidLicensePlugin] Adding license tasks for sourceSet ${sourceSetTaskName}"); License checkTask = project.tasks.create(sourceSetTaskName, License) @@ -290,7 +290,7 @@ class LicensePlugin implements Plugin { baseCheckTask.dependsOn checkTask // Add independent license task, which will perform format - def sourceSetFormatTaskName = (taskBaseName + 'FormatAndroid'+ sourceSet.name.capitalize()) + def sourceSetFormatTaskName = "${taskBaseName}FormatAndroid${sourceSet.name.capitalize()}" License formatTask = project.tasks.create(sourceSetFormatTaskName, License) formatTask.check = false configureForAndroidSourceSet(sourceSet, formatTask) @@ -301,7 +301,7 @@ class LicensePlugin implements Plugin { } // Add license checking into check lifecycle, since its a type of code quality plugin - + project.tasks['check'].dependsOn baseCheckTask } @@ -316,17 +316,17 @@ class LicensePlugin implements Plugin { sourceSet.properties.each { key, val -> logger.debug("[AndroidLicensePlugin] sourceSet.$key:$val"); } - + ArrayList androidSource = new ArrayList(); - + for (File file : sourceSet.java.sourceFiles) { androidSource.add(file); } - + for (File file : sourceSet.res.sourceFiles) { androidSource.add(file); } - + task.source = project.files(androidSource) } diff --git a/src/test/groovy/nl/javadude/gradle/plugins/license/AndroidLicensePluginTest.groovy b/src/test/groovy/nl/javadude/gradle/plugins/license/AndroidLicensePluginTest.groovy index 386de9f..5ad5647 100644 --- a/src/test/groovy/nl/javadude/gradle/plugins/license/AndroidLicensePluginTest.groovy +++ b/src/test/groovy/nl/javadude/gradle/plugins/license/AndroidLicensePluginTest.groovy @@ -1,13 +1,13 @@ /* License added by: GRADLE-LICENSE-PLUGIN * * Copyright (C)2011 - Jeroen van Erp - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -92,12 +92,12 @@ class AndroidLicensePluginTest { project.license.header = project.file("OTHERLICENSE") assertThat(project.license.header.name, is("OTHERLICENSE")) } - - + + @Test public void shouldFindTwoLicenseTaskPerSourceSet() { def tasks = project.tasks.withType(License.class).findAll { true } - assertThat tasks.size(), is(8) // [main,androidTest, release, debug].count * 2 + assertThat tasks.size(), is(14) // [androidTest, debug, main, release, test, testDebug, testRelease].count * 2 } @Test @@ -105,41 +105,41 @@ class AndroidLicensePluginTest { def task = project.tasks.getByName("licenseAndroidMain") assertThat task, instanceOf(License.class) } - + @Test public void shouldFindDebugLicenseTask() { def task = project.tasks.getByName("licenseAndroidDebug") assertThat task, instanceOf(License.class) } - + @Test public void shouldFindReleaseLicenseTask() { def task = project.tasks.getByName("licenseAndroidRelease") assertThat task, instanceOf(License.class) } - + @Test public void shouldFindTestLicenseTask() { def task = project.tasks.getByName("licenseAndroidAndroidTest") assertThat task, instanceOf(License.class) } - + @Test public void extensionShouldHaveSourceSetsWithJava() { assertThat project.license.sourceSets.size(), equalTo(project.sourceSets.size()) } - + @Test public void shouldConfigureLicenseForTasks() { def task = project.tasks['licenseAndroidMain'] - + assertThat task.header.name, is("LICENSE") } @Test public void shouldConfigureManuallyConfiguredTask() { def task = project.tasks.create('licenseManual', License) - + assertThat task.header.name, is("LICENSE") } @@ -149,7 +149,7 @@ class AndroidLicensePluginTest { assertThat project.license.ignoreFailures, is(false) // Default assertThat task.ignoreFailures, is(false) - + project.license.ignoreFailures = true assertThat task.isIgnoreFailures(), is(true) //assertThat task.getIgnoreFailures(), is(true) // GRADLE-2163, fixed in 1.0-rc1 @@ -174,7 +174,7 @@ class AndroidLicensePluginTest { Set dependsOn = project.tasks['license'].getDependsOn() assertThat dependsOn, hasItem(project.tasks['licenseAndroidMain']) assertThat dependsOn, hasItem(project.tasks['licenseAndroidAndroidTest']) - + // Manual tests don't get registered with check assertThat dependsOn, not(hasItem(task)) @@ -185,7 +185,7 @@ class AndroidLicensePluginTest { // Manual tests don't get registered with check assertThat dependsOnFormat, not(hasItem(task)) } - + @Test public void canAddMappingsAtMultipleLevels() { def task = project.tasks['licenseAndroidMain'] @@ -200,4 +200,4 @@ class AndroidLicensePluginTest { assert mappings.containsKey('map1') assert mappings.containsKey('map2') } -} \ No newline at end of file +}