aboutsummaryrefslogtreecommitdiff
path: root/gradle/src
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2012-12-20 17:46:16 -0800
committerXavier Ducrohet <xav@android.com>2012-12-21 16:18:36 -0800
commit22c43d4c07e37923954fe5d8c8fbe7794b326d9f (patch)
tree17cb7fe7cea9e858b088c6fb8bc82db759809269 /gradle/src
parent2983358e6d84e943688b47fe87698e6a42aed8f8 (diff)
downloadbuild-22c43d4c07e37923954fe5d8c8fbe7794b326d9f.tar.gz
Add task on gradle plugin to run android tests on a device.
This is not final as the on-device errors are not properly processed. When it's final it'll get added to the check task. This also fixes some issue with installing/uninstalling due to the incremental changes that went in today. Change-Id: I280a1b8c4cfd4daae99fd68e4c93e52f9b3a9c0e
Diffstat (limited to 'gradle/src')
-rw-r--r--gradle/src/build-test/groovy/com/android/build/gradle/BuildTest.groovy44
-rw-r--r--gradle/src/device-test/groovy/com/android/build/gradle/DeviceTest.groovy94
-rw-r--r--gradle/src/device-test/groovy/com/android/build/gradle/DeviceTest.java36
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/BasePlugin.groovy4
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/internal/tasks/BaseTask.groovy123
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/internal/tasks/IncrementalTask.groovy140
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/internal/tasks/InstallTask.groovy4
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/internal/tasks/PrepareDependenciesTask.groovy6
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/internal/tasks/RunTestsTask.groovy6
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/internal/tasks/UninstallTask.groovy7
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/tasks/AidlCompile.groovy4
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/tasks/Dex.groovy4
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/tasks/GenerateBuildConfig.groovy4
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/tasks/MergeResources.groovy4
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/tasks/PackageApplication.groovy4
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/tasks/ProcessManifest.groovy5
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/tasks/ProcessResources.groovy4
-rwxr-xr-xgradle/src/test/groovy/com/android/build/gradle/internal/BaseTest.groovy33
18 files changed, 299 insertions, 227 deletions
diff --git a/gradle/src/build-test/groovy/com/android/build/gradle/BuildTest.groovy b/gradle/src/build-test/groovy/com/android/build/gradle/BuildTest.groovy
index c04c652..587f408 100644
--- a/gradle/src/build-test/groovy/com/android/build/gradle/BuildTest.groovy
+++ b/gradle/src/build-test/groovy/com/android/build/gradle/BuildTest.groovy
@@ -15,17 +15,11 @@
*/
package com.android.build.gradle
-
import com.android.build.gradle.internal.BaseTest
-import com.android.sdklib.internal.project.ProjectProperties
-import com.android.sdklib.internal.project.ProjectPropertiesWorkingCopy
import com.google.common.collect.Sets
-import org.gradle.tooling.GradleConnector
-import org.gradle.tooling.ProjectConnection
import javax.imageio.ImageIO
import java.awt.image.BufferedImage
-
/**
* Build tests.
*
@@ -118,10 +112,10 @@ class BuildTest extends BaseTest {
File repo = new File(testDir, "repo")
try {
- buildProject(new File(repo, "util"), "clean", "uploadArchives")
- buildProject(new File(repo, "baseLibrary"), "clean", "uploadArchives")
- buildProject(new File(repo, "library"), "clean", "uploadArchives")
- buildProject(new File(repo, "app"), "clean", "assemble")
+ runGradleTasks(sdkDir, new File(repo, "util"), "clean", "uploadArchives")
+ runGradleTasks(sdkDir, new File(repo, "baseLibrary"), "clean", "uploadArchives")
+ runGradleTasks(sdkDir, new File(repo, "library"), "clean", "uploadArchives")
+ runGradleTasks(sdkDir, new File(repo, "app"), "clean", "assemble")
} finally {
// clean up the test repository.
File testRepo = new File(repo, "testrepo")
@@ -150,39 +144,11 @@ class BuildTest extends BaseTest {
File project = new File(testDir, name)
builtProjects.add(name)
- buildProject(project, "clean", "assembleDebug")
+ runGradleTasks(sdkDir, project, "clean", "assembleDebug")
return project;
}
- private void buildProject(File project, String... tasks) {
- File localProp = createLocalProp(project)
-
- try {
-
- GradleConnector connector = GradleConnector.newConnector()
-
- ProjectConnection connection = connector
- .useGradleVersion(BasePlugin.GRADLE_VERSION)
- .forProjectDirectory(project)
- .connect()
-
- connection.newBuild().forTasks(tasks).run()
- } finally {
- localProp.delete()
- }
- }
-
-
- private File createLocalProp(File project) {
- ProjectPropertiesWorkingCopy localProp = ProjectProperties.create(
- project.absolutePath, ProjectProperties.PropertyType.LOCAL)
- localProp.setProperty(ProjectProperties.PROPERTY_SDK, sdkDir.absolutePath)
- localProp.save()
-
- return (File) localProp.file
- }
-
private static void checkImageColor(File folder, String fileName, int expectedColor) {
File f = new File(folder, fileName)
assertTrue("File '" + f.getAbsolutePath() + "' does not exist.", f.isFile())
diff --git a/gradle/src/device-test/groovy/com/android/build/gradle/DeviceTest.groovy b/gradle/src/device-test/groovy/com/android/build/gradle/DeviceTest.groovy
new file mode 100644
index 0000000..72edd89
--- /dev/null
+++ b/gradle/src/device-test/groovy/com/android/build/gradle/DeviceTest.groovy
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.build.gradle
+import com.android.build.gradle.internal.BaseTest
+/**
+ * Device tests.
+ *
+ * This build relies on the {@link BuildTest} to have been run, so that all that there
+ * is left to do is deploy the tested and test apps to the device and run the tests (and gather
+ * the result).
+ *
+ * The dependency on the build tests is ensured by the gradle tasks definition.
+ *
+ * This does not test every projects under tests, instead it's a selection that actually has
+ * tests.
+ *
+ */
+public class DeviceTest extends BaseTest {
+
+ private File testDir
+ private File sdkDir
+
+ @Override
+ protected void setUp() throws Exception {
+ testDir = getTestDir()
+ sdkDir = getSdkDir()
+ }
+
+ void testApi() {
+ runTestsOn("api")
+ }
+
+ void testAppLibTest() {
+ runTestsOn("applibtest")
+ }
+
+ void testBasic() {
+ runTestsOn("basic")
+ }
+
+ void testFlavored() {
+ runTestsOn("flavored")
+ }
+
+ void testFlavorLib() {
+ runTestsOn("flavorlib")
+ }
+
+ void testFlavors() {
+ runTestsOn("flavors")
+ }
+
+ void testLibsTest() {
+ runTestsOn("libsTest")
+ }
+
+ void testMigrated() {
+ runTestsOn("migrated")
+ }
+
+ void testMultiRes() {
+ runTestsOn("multires")
+ }
+
+ void testOverlay1() {
+ runTestsOn("overlay1")
+ }
+
+ void testOverlay2() {
+ runTestsOn("overlay2")
+ }
+
+ private File runTestsOn(String name) {
+ File project = new File(testDir, name)
+
+ runGradleTasks(sdkDir, project, "check")
+
+ return project;
+ }
+} \ No newline at end of file
diff --git a/gradle/src/device-test/groovy/com/android/build/gradle/DeviceTest.java b/gradle/src/device-test/groovy/com/android/build/gradle/DeviceTest.java
deleted file mode 100644
index 3d0da29..0000000
--- a/gradle/src/device-test/groovy/com/android/build/gradle/DeviceTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.build.gradle;
-
-import junit.framework.TestCase;
-
-/**
- * Device tests.
- *
- * This build relies on the {@link BuildTest} to have been run, so that all that there
- * is left to do is deploy the tested and test apps to the device and run the tests (and gather
- * the result).
- *
- * The dependency on the build tests is ensured by the gradle tasks definition.
- *
- */
-public class DeviceTest extends TestCase {
-
- public void testFoo() throws Exception {
- assertTrue(true);
- }
-}
diff --git a/gradle/src/main/groovy/com/android/build/gradle/BasePlugin.groovy b/gradle/src/main/groovy/com/android/build/gradle/BasePlugin.groovy
index b4654e6..3d5be53 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/BasePlugin.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/BasePlugin.groovy
@@ -28,9 +28,9 @@ import com.android.build.gradle.internal.SymbolFileProviderImpl
import com.android.build.gradle.internal.TestAppVariant
import com.android.build.gradle.internal.tasks.AidlCompileTask
import com.android.build.gradle.internal.tasks.AndroidDependencyTask
-import com.android.build.gradle.internal.tasks.BaseTask
import com.android.build.gradle.internal.tasks.DexTask
import com.android.build.gradle.internal.tasks.GenerateBuildConfigTask
+import com.android.build.gradle.internal.tasks.IncrementalTask
import com.android.build.gradle.internal.tasks.InstallTask
import com.android.build.gradle.internal.tasks.MergeResourcesTask
import com.android.build.gradle.internal.tasks.PackageApplicationTask
@@ -331,7 +331,7 @@ public abstract class BasePlugin {
mergeResourcesTask.conventionMapping.inputResourceSets = { variant.config.resourceSets }
mergeResourcesTask.conventionMapping.rawInputFolders = {
- BaseTask.flattenSourceSets(variant.config.resourceSets)
+ IncrementalTask.flattenSourceSets(variant.config.resourceSets)
}
mergeResourcesTask.conventionMapping.outputDir = {
diff --git a/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/BaseTask.groovy b/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/BaseTask.groovy
index d6146c4..89e0a0b 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/BaseTask.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/BaseTask.groovy
@@ -14,140 +14,17 @@
* limitations under the License.
*/
package com.android.build.gradle.internal.tasks
-
import com.android.build.gradle.BasePlugin
import com.android.build.gradle.internal.ApplicationVariant
import com.android.builder.AndroidBuilder
-import com.android.builder.internal.incremental.ChangeManager
-import com.android.builder.resources.FileStatus
-import com.android.builder.resources.SourceSet
-import com.google.common.collect.Lists
import org.gradle.api.DefaultTask
-import org.gradle.api.file.FileCollection
-import org.gradle.api.tasks.Optional
-import org.gradle.api.tasks.OutputDirectory
-import org.gradle.api.tasks.TaskAction
-import org.gradle.api.tasks.TaskInputs
public abstract class BaseTask extends DefaultTask {
BasePlugin plugin
ApplicationVariant variant
- @OutputDirectory @Optional
- File incrementalFolder
-
- private Map<File, FileStatus> sEmptyMap = Collections.emptyMap()
-
protected AndroidBuilder getBuilder() {
return plugin.getAndroidBuilder(variant)
}
-
- /**
- * Whether this task can support incremental update using the {@link ChangeManager}
- *
- * @return whether this task can support incremental update.
- */
- protected boolean isIncremental() {
- return false
- }
-
- /**
- * Actual task action. This is called when a full run is needed, which is always the case if
- * {@link #isIncremental()} returns false.
- *
- */
- protected abstract void doFullTaskAction();
-
- /**
- * Optional incremental task action.
- * Only used if {@link #isIncremental()} returns true.
- *
- * @param changedInputs the changed input files.
- * @param changedOutputs the changed output files.
- */
- protected void doIncrementalTaskAction(Map<File, FileStatus> changedInputs,
- Map<File, FileStatus> changedOutputs) {
- // do nothing.
- }
-
- protected Collection<File> getOutputForIncrementalBuild() {
- return Collections.emptyList();
- }
-
- /**
- * Actual entry point for the action.
- * Calls out to the doTaskAction as needed.
- */
- @TaskAction
- void taskAction() {
- if (!isIncremental() || incrementalFolder == null) {
- doFullTaskAction()
- return;
- }
-
- // load known state.
- ChangeManager changeManager = new ChangeManager()
- boolean fullBuild = !changeManager.load(incrementalFolder)
-
- // update with current files.
- TaskInputs inputs = getInputs()
- FileCollection inputCollection = inputs.getFiles()
-
- for (File f : inputCollection.files) {
- changeManager.addInput(f)
- }
-
- for (File f : getOutputForIncrementalBuild()) {
- changeManager.addOutput(f);
- }
-
- try {
- // force full build if output changed somehow.
- Map<File, FileStatus> changedOutputs = changeManager.getChangedOutputs()
- Map<File, FileStatus> changedInputs = changeManager.getChangedInputs()
- if (fullBuild) {
- project.logger.info("No incremental data: full task run")
- doFullTaskAction();
- } else if (!changedOutputs.isEmpty()) {
- for (File f : changedOutputs.keySet()) {
- project.logger.info(">> " + f)
- }
- project.logger.info("Changed output: full task run")
-
- doFullTaskAction();
- } else if (changedInputs.isEmpty() && changedOutputs.isEmpty()) {
- // both input and output are empty, this is something we don't control
- // through files, just do a full run
- project.logger.info("Changed non file input/output: full task run")
- doFullTaskAction()
- } else {
- doIncrementalTaskAction(
- changeManager.getChangedInputs(), changeManager.getChangedOutputs())
- }
-
- // update the outputs post task-action, to record their state
- // for the next run
- changeManager.updateOutputs(getOutputForIncrementalBuild())
-
- // write the result down to be used next time the task is run.
- changeManager.write(incrementalFolder)
- } catch (Exception e) {
- // Easiest to do here, is to delete the incremental Data so that
- // next run is full.
- ChangeManager.delete(incrementalFolder)
-
- throw e
- }
- }
-
- public static List<File> flattenSourceSets(List<? extends SourceSet> resourceSets) {
- List<File> list = Lists.newArrayList();
-
- for (SourceSet sourceSet : resourceSets) {
- list.addAll(sourceSet.sourceFiles)
- }
-
- return list;
- }
}
diff --git a/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/IncrementalTask.groovy b/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/IncrementalTask.groovy
new file mode 100644
index 0000000..c398439
--- /dev/null
+++ b/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/IncrementalTask.groovy
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.build.gradle.internal.tasks
+
+import com.android.builder.internal.incremental.ChangeManager
+import com.android.builder.resources.FileStatus
+import com.android.builder.resources.SourceSet
+import com.google.common.collect.Lists
+import org.gradle.api.file.FileCollection
+import org.gradle.api.tasks.Optional
+import org.gradle.api.tasks.OutputDirectory
+import org.gradle.api.tasks.TaskAction
+import org.gradle.api.tasks.TaskInputs
+
+public abstract class IncrementalTask extends BaseTask {
+
+ @OutputDirectory @Optional
+ File incrementalFolder
+
+ /**
+ * Whether this task can support incremental update using the {@link ChangeManager}
+ *
+ * @return whether this task can support incremental update.
+ */
+ protected boolean isIncremental() {
+ return false
+ }
+
+ /**
+ * Actual task action. This is called when a full run is needed, which is always the case if
+ * {@link #isIncremental()} returns false.
+ *
+ */
+ protected abstract void doFullTaskAction();
+
+ /**
+ * Optional incremental task action.
+ * Only used if {@link #isIncremental()} returns true.
+ *
+ * @param changedInputs the changed input files.
+ * @param changedOutputs the changed output files.
+ */
+ protected void doIncrementalTaskAction(Map<File, FileStatus> changedInputs,
+ Map<File, FileStatus> changedOutputs) {
+ // do nothing.
+ }
+
+ protected Collection<File> getOutputForIncrementalBuild() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Actual entry point for the action.
+ * Calls out to the doTaskAction as needed.
+ */
+ @TaskAction
+ void taskAction() {
+ if (!isIncremental() || incrementalFolder == null) {
+ doFullTaskAction()
+ return;
+ }
+
+ // load known state.
+ ChangeManager changeManager = new ChangeManager()
+ boolean fullBuild = !changeManager.load(incrementalFolder)
+
+ // update with current files.
+ TaskInputs inputs = getInputs()
+ FileCollection inputCollection = inputs.getFiles()
+
+ for (File f : inputCollection.files) {
+ changeManager.addInput(f)
+ }
+
+ for (File f : getOutputForIncrementalBuild()) {
+ changeManager.addOutput(f);
+ }
+
+ try {
+ // force full build if output changed somehow.
+ Map<File, FileStatus> changedOutputs = changeManager.getChangedOutputs()
+ Map<File, FileStatus> changedInputs = changeManager.getChangedInputs()
+ if (fullBuild) {
+ project.logger.info("No incremental data: full task run")
+ doFullTaskAction();
+ } else if (!changedOutputs.isEmpty()) {
+ for (File f : changedOutputs.keySet()) {
+ project.logger.info(">> " + f)
+ }
+ project.logger.info("Changed output: full task run")
+
+ doFullTaskAction();
+ } else if (changedInputs.isEmpty() && changedOutputs.isEmpty()) {
+ // both input and output are empty, this is something we don't control
+ // through files, just do a full run
+ project.logger.info("Changed non file input/output: full task run")
+ doFullTaskAction()
+ } else {
+ doIncrementalTaskAction(
+ changeManager.getChangedInputs(), changeManager.getChangedOutputs())
+ }
+
+ // update the outputs post task-action, to record their state
+ // for the next run
+ changeManager.updateOutputs(getOutputForIncrementalBuild())
+
+ // write the result down to be used next time the task is run.
+ changeManager.write(incrementalFolder)
+ } catch (Exception e) {
+ // Easiest to do here, is to delete the incremental Data so that
+ // next run is full.
+ ChangeManager.delete(incrementalFolder)
+
+ throw e
+ }
+ }
+
+ public static List<File> flattenSourceSets(List<? extends SourceSet> resourceSets) {
+ List<File> list = Lists.newArrayList();
+
+ for (SourceSet sourceSet : resourceSets) {
+ list.addAll(sourceSet.sourceFiles)
+ }
+
+ return list;
+ }
+}
diff --git a/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/InstallTask.groovy b/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/InstallTask.groovy
index ec30f98..840c037 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/InstallTask.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/InstallTask.groovy
@@ -14,17 +14,13 @@
* limitations under the License.
*/
package com.android.build.gradle.internal.tasks
-
import org.gradle.api.DefaultTask
-import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.TaskAction
-
/**
* Task installing an app.
*/
public class InstallTask extends DefaultTask {
- @Input
File sdkDir
@InputFile
diff --git a/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/PrepareDependenciesTask.groovy b/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/PrepareDependenciesTask.groovy
index 7d0f7e4..811347f 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/PrepareDependenciesTask.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/PrepareDependenciesTask.groovy
@@ -14,8 +14,10 @@
* limitations under the License.
*/
package com.android.build.gradle.internal.tasks
+
import com.android.build.gradle.internal.DependencyChecker
import com.android.utils.Pair
+import org.gradle.api.tasks.TaskAction
public class PrepareDependenciesTask extends BaseTask {
final List<DependencyChecker> checkers = []
@@ -25,8 +27,8 @@ public class PrepareDependenciesTask extends BaseTask {
androidDependencies.add(api)
}
- @Override
- protected void doFullTaskAction() {
+ @TaskAction
+ protected void prepare() {
def minSdkVersion = variant.config.minSdkVersion
for (DependencyChecker checker : checkers) {
diff --git a/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/RunTestsTask.groovy b/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/RunTestsTask.groovy
index ec0873c..d822d1f 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/RunTestsTask.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/RunTestsTask.groovy
@@ -16,6 +16,8 @@
package com.android.build.gradle.internal.tasks
import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.TaskAction
+
/**
* Run tests for a given variant
*/
@@ -24,8 +26,8 @@ public class RunTestsTask extends BaseTask {
@Input
File sdkDir
- @Override
- protected void doFullTaskAction() {
+ @TaskAction
+ protected void runTests() {
List<String> command = variant.runCommand
logger.info("Running tests with command: " + command)
diff --git a/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/UninstallTask.groovy b/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/UninstallTask.groovy
index 2410fca..ae1dc9b 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/UninstallTask.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/internal/tasks/UninstallTask.groovy
@@ -15,14 +15,13 @@
*/
package com.android.build.gradle.internal.tasks
-import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.TaskAction
public class UninstallTask extends BaseTask {
- @Input
File sdkDir
- @Override
- protected void doFullTaskAction() {
+ @TaskAction
+ public void uninstall() {
String packageName = variant.package
logger.info("Uninstalling app: " + packageName)
project.exec {
diff --git a/gradle/src/main/groovy/com/android/build/gradle/tasks/AidlCompile.groovy b/gradle/src/main/groovy/com/android/build/gradle/tasks/AidlCompile.groovy
index 8e597d2..ad3363c 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/tasks/AidlCompile.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/tasks/AidlCompile.groovy
@@ -16,12 +16,12 @@
package com.android.build.gradle.tasks
-import com.android.build.gradle.internal.tasks.BaseTask
+import com.android.build.gradle.internal.tasks.IncrementalTask
import org.gradle.api.tasks.OutputDirectory
/**
*/
-public abstract class AidlCompile extends BaseTask {
+public abstract class AidlCompile extends IncrementalTask {
@OutputDirectory
File sourceOutputDir
diff --git a/gradle/src/main/groovy/com/android/build/gradle/tasks/Dex.groovy b/gradle/src/main/groovy/com/android/build/gradle/tasks/Dex.groovy
index c1b1daf..ba29e41 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/tasks/Dex.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/tasks/Dex.groovy
@@ -15,10 +15,10 @@
*/
package com.android.build.gradle.tasks
-import com.android.build.gradle.internal.tasks.BaseTask
+import com.android.build.gradle.internal.tasks.IncrementalTask
import org.gradle.api.tasks.OutputFile
-public abstract class Dex extends BaseTask {
+public abstract class Dex extends IncrementalTask {
@OutputFile
File outputFile
diff --git a/gradle/src/main/groovy/com/android/build/gradle/tasks/GenerateBuildConfig.groovy b/gradle/src/main/groovy/com/android/build/gradle/tasks/GenerateBuildConfig.groovy
index 9c75214..9fe69f4 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/tasks/GenerateBuildConfig.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/tasks/GenerateBuildConfig.groovy
@@ -15,10 +15,10 @@
*/
package com.android.build.gradle.tasks
-import com.android.build.gradle.internal.tasks.BaseTask
+import com.android.build.gradle.internal.tasks.IncrementalTask
import org.gradle.api.tasks.OutputDirectory
-public abstract class GenerateBuildConfig extends BaseTask {
+public abstract class GenerateBuildConfig extends IncrementalTask {
@OutputDirectory
File sourceOutputDir
diff --git a/gradle/src/main/groovy/com/android/build/gradle/tasks/MergeResources.groovy b/gradle/src/main/groovy/com/android/build/gradle/tasks/MergeResources.groovy
index c824d3d..eb94662 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/tasks/MergeResources.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/tasks/MergeResources.groovy
@@ -15,10 +15,10 @@
*/
package com.android.build.gradle.tasks
-import com.android.build.gradle.internal.tasks.BaseTask
+import com.android.build.gradle.internal.tasks.IncrementalTask
import org.gradle.api.tasks.OutputDirectory
-abstract class MergeResources extends BaseTask {
+abstract class MergeResources extends IncrementalTask {
@OutputDirectory
File outputDir
diff --git a/gradle/src/main/groovy/com/android/build/gradle/tasks/PackageApplication.groovy b/gradle/src/main/groovy/com/android/build/gradle/tasks/PackageApplication.groovy
index 07ee2db..d7a761a 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/tasks/PackageApplication.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/tasks/PackageApplication.groovy
@@ -15,13 +15,13 @@
*/
package com.android.build.gradle.tasks
-import com.android.build.gradle.internal.tasks.BaseTask
+import com.android.build.gradle.internal.tasks.IncrementalTask
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputFile
-public abstract class PackageApplication extends BaseTask {
+public abstract class PackageApplication extends IncrementalTask {
@InputFile
File resourceFile
diff --git a/gradle/src/main/groovy/com/android/build/gradle/tasks/ProcessManifest.groovy b/gradle/src/main/groovy/com/android/build/gradle/tasks/ProcessManifest.groovy
index e58cf7e..6c97233 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/tasks/ProcessManifest.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/tasks/ProcessManifest.groovy
@@ -15,13 +15,12 @@
*/
package com.android.build.gradle.tasks
-import com.android.build.gradle.internal.tasks.BaseTask
+import com.android.build.gradle.internal.tasks.IncrementalTask
import org.gradle.api.tasks.OutputFile
-
/**
* A task that processes the manifest
*/
-public abstract class ProcessManifest extends BaseTask {
+public abstract class ProcessManifest extends IncrementalTask {
/**
* The processed Manifest.
diff --git a/gradle/src/main/groovy/com/android/build/gradle/tasks/ProcessResources.groovy b/gradle/src/main/groovy/com/android/build/gradle/tasks/ProcessResources.groovy
index c2355aa..e1a3024 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/tasks/ProcessResources.groovy
+++ b/gradle/src/main/groovy/com/android/build/gradle/tasks/ProcessResources.groovy
@@ -15,14 +15,14 @@
*/
package com.android.build.gradle.tasks
-import com.android.build.gradle.internal.tasks.BaseTask
+import com.android.build.gradle.internal.tasks.IncrementalTask
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.OutputFile
-public abstract class ProcessResources extends BaseTask {
+public abstract class ProcessResources extends IncrementalTask {
@InputFile
File manifestFile
diff --git a/gradle/src/test/groovy/com/android/build/gradle/internal/BaseTest.groovy b/gradle/src/test/groovy/com/android/build/gradle/internal/BaseTest.groovy
index 61302dc..febd5e3 100755
--- a/gradle/src/test/groovy/com/android/build/gradle/internal/BaseTest.groovy
+++ b/gradle/src/test/groovy/com/android/build/gradle/internal/BaseTest.groovy
@@ -16,7 +16,12 @@
package com.android.build.gradle.internal
+import com.android.build.gradle.BasePlugin
+import com.android.sdklib.internal.project.ProjectProperties
+import com.android.sdklib.internal.project.ProjectPropertiesWorkingCopy
import junit.framework.TestCase
+import org.gradle.tooling.GradleConnector
+import org.gradle.tooling.ProjectConnection
import java.security.CodeSource
@@ -95,4 +100,32 @@ public abstract class BaseTest extends TestCase {
outFolder))
return null
}
+
+ protected static File createLocalProp(File project, File sdkDir) {
+ ProjectPropertiesWorkingCopy localProp = ProjectProperties.create(
+ project.absolutePath, ProjectProperties.PropertyType.LOCAL)
+ localProp.setProperty(ProjectProperties.PROPERTY_SDK, sdkDir.absolutePath)
+ localProp.save()
+
+ return (File) localProp.file
+ }
+
+ protected static void runGradleTasks(File sdkDir, File project, String... tasks) {
+ File localProp = createLocalProp(project, sdkDir)
+
+ try {
+
+ GradleConnector connector = GradleConnector.newConnector()
+
+ ProjectConnection connection = connector
+ .useGradleVersion(BasePlugin.GRADLE_VERSION)
+ .forProjectDirectory(project)
+ .connect()
+
+ connection.newBuild().forTasks(tasks).run()
+ } finally {
+ localProp.delete()
+ }
+ }
+
}