aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@google.com>2013-11-25 22:18:04 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-11-25 22:18:05 +0000
commitc2de5275272e8ce51f09fc7dc805c9223f076586 (patch)
treed7a3360205ff451ad1565552fb560448f9b56d66
parent6a39b03bb738ea32426b98de64ca171ebefa50a4 (diff)
parentb002f4a0506e158fa6aeb8fc0f0ec74f10a0097b (diff)
downloadbuild-c2de5275272e8ce51f09fc7dc805c9223f076586.tar.gz
Merge "Tweak generated source folder API."
-rw-r--r--changelog.txt7
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/api/BaseVariant.java35
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/internal/api/BaseVariantImpl.java19
-rw-r--r--gradle/src/main/groovy/com/android/build/gradle/internal/variant/BaseVariantData.java20
-rw-r--r--tests/genFolderApi/build.gradle2
5 files changed, 68 insertions, 15 deletions
diff --git a/changelog.txt b/changelog.txt
index 6525120..b5809d6 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -14,13 +14,16 @@
buildConfigField "<type>", "<name>", "<value>"
This allows override a field (see 'basic' sample)
Also, BuildConfig now automatically contains constants for
- PACKAGE_NAME, VERSION_CODE, VERSION_NAME, BUILD_TYPE, FLAVOR s well as FLAVOR1, FLAVOR2, etc... if there are several flavor dimensions.
+ PACKAGE_NAME, VERSION_CODE, VERSION_NAME, BUILD_TYPE, FLAVOR as well as FLAVOR1, FLAVOR2, etc... if there are several flavor dimensions.
- Switch to ProGuard 4.10
- Added ability to test proguarded (obfuscated) apps.
- Jar files are now pre-dexed for faster dexing.
- First pass at NDK integration
- API to add new generated source folders:
- variant.addGeneratedSourceFolders(generatingTask, sourceFolder1, sourceFolders2,...)
+ variant.addJavaSourceFoldersToModel(sourceFolder1, sourceFolders2,...)
+ This adds the source folder to the model (for IDE support).
+ Another API:
+ variant.registerJavaGeneratingTask(task, sourceFolder1, sourceFolders2,...)
This automatically adds the dependency on the task, sets up the JavaCompile task inputs and propagates
the folders to the model for IDE integration.
diff --git a/gradle/src/main/groovy/com/android/build/gradle/api/BaseVariant.java b/gradle/src/main/groovy/com/android/build/gradle/api/BaseVariant.java
index 854f4a5..297121d 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/api/BaseVariant.java
+++ b/gradle/src/main/groovy/com/android/build/gradle/api/BaseVariant.java
@@ -32,6 +32,7 @@ import org.gradle.api.tasks.Copy;
import org.gradle.api.tasks.compile.JavaCompile;
import java.io.File;
+import java.util.Collection;
/**
* A Build variant and all its public data. This is the base class for items common to apps,
@@ -154,24 +155,50 @@ public interface BaseVariant {
Task getAssemble();
/**
- * Adds to the variant a task that generates Java source Code.
+ * Adds new Java source folders to the model.
+ *
+ * These source folders will not be used for the default build
+ * system, but will be passed along the default Java source folders
+ * to whoever queries the model.
+ *
+ * @param sourceFolders the source folders where the generated source code is.
+ */
+ void addJavaSourceFoldersToModel(@NonNull File... sourceFolders);
+
+ /**
+ * Adds new Java source folders to the model.
+ *
+ * These source folders will not be used for the default build
+ * system, but will be passed along the default Java source folders
+ * to whoever queries the model.
+ *
+ * @param sourceFolders the source folders where the generated source code is.
+ */
+ void addJavaSourceFoldersToModel(@NonNull Collection<File> sourceFolders);
+
+ /**
+ * Adds to the variant a task that generates Java source code.
*
* This will make the compileJava task depend on this task and add the
* new source folders as compilation inputs.
*
+ * The new source folders are also added to the model.
+ *
* @param task the task
* @param sourceFolders the source folders where the generated source code is.
*/
- void addGeneratedSourceFolders(@NonNull Task task, @NonNull File... sourceFolders);
+ void registerJavaGeneratingTask(@NonNull Task task, @NonNull File... sourceFolders);
/**
- * Adds to the variant a task that generates Java source Code.
+ * Adds to the variant a task that generates Java source code.
*
* This will make the compileJava task depend on this task and add the
* new source folders as compilation inputs.
*
+ * The new source folders are also added to the model.
+ *
* @param task the task
* @param sourceFolders the source folders where the generated source code is.
*/
- void addGeneratedSourceFolders(@NonNull Task task, @NonNull Iterable<File> sourceFolders);
+ void registerJavaGeneratingTask(@NonNull Task task, @NonNull Collection<File> sourceFolders);
}
diff --git a/gradle/src/main/groovy/com/android/build/gradle/internal/api/BaseVariantImpl.java b/gradle/src/main/groovy/com/android/build/gradle/internal/api/BaseVariantImpl.java
index 94ee0ab..1e99d91 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/internal/api/BaseVariantImpl.java
+++ b/gradle/src/main/groovy/com/android/build/gradle/internal/api/BaseVariantImpl.java
@@ -34,6 +34,7 @@ import org.gradle.api.tasks.Copy;
import org.gradle.api.tasks.compile.JavaCompile;
import java.io.File;
+import java.util.Collection;
abstract class BaseVariantImpl implements BaseVariant {
@@ -139,12 +140,22 @@ abstract class BaseVariantImpl implements BaseVariant {
}
@Override
- public void addGeneratedSourceFolders(@NonNull Task task, @NonNull File... sourceFolders) {
- getVariantData().addGeneratedSourceFolders(task, sourceFolders);
+ public void addJavaSourceFoldersToModel(@NonNull File... generatedSourceFolders) {
+ getVariantData().addJavaSourceFoldersToModel(generatedSourceFolders);
}
@Override
- public void addGeneratedSourceFolders(@NonNull Task task, @NonNull Iterable<File> sourceFolders) {
- getVariantData().addGeneratedSourceFolders(task, sourceFolders);
+ public void addJavaSourceFoldersToModel(@NonNull Collection<File> generatedSourceFolders) {
+ getVariantData().addJavaSourceFoldersToModel(generatedSourceFolders);
+ }
+
+ @Override
+ public void registerJavaGeneratingTask(@NonNull Task task, @NonNull File... sourceFolders) {
+ getVariantData().registerJavaGeneratingTask(task, sourceFolders);
+ }
+
+ @Override
+ public void registerJavaGeneratingTask(@NonNull Task task, @NonNull Collection<File> sourceFolders) {
+ getVariantData().registerJavaGeneratingTask(task, sourceFolders);
}
}
diff --git a/gradle/src/main/groovy/com/android/build/gradle/internal/variant/BaseVariantData.java b/gradle/src/main/groovy/com/android/build/gradle/internal/variant/BaseVariantData.java
index 6c68201..83794e8 100644
--- a/gradle/src/main/groovy/com/android/build/gradle/internal/variant/BaseVariantData.java
+++ b/gradle/src/main/groovy/com/android/build/gradle/internal/variant/BaseVariantData.java
@@ -38,6 +38,8 @@ import org.gradle.api.tasks.compile.JavaCompile;
import proguard.gradle.ProGuardTask;
import java.io.File;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
/**
@@ -134,7 +136,15 @@ public abstract class BaseVariantData {
return extraGeneratedSourceFolders;
}
- public void addGeneratedSourceFolders(@NonNull Task task, @NonNull File... generatedSourceFolders) {
+ public void addJavaSourceFoldersToModel(@NonNull File... generatedSourceFolders) {
+ Collections.addAll(extraGeneratedSourceFolders, generatedSourceFolders);
+ }
+
+ public void addJavaSourceFoldersToModel(@NonNull Collection<File> generatedSourceFolders) {
+ extraGeneratedSourceFolders.addAll(generatedSourceFolders);
+ }
+
+ public void registerJavaGeneratingTask(@NonNull Task task, @NonNull File... generatedSourceFolders) {
if (extraGeneratedSourceFolders == null) {
extraGeneratedSourceFolders = Lists.newArrayList();
}
@@ -142,12 +152,13 @@ public abstract class BaseVariantData {
javaCompileTask.dependsOn(task);
for (File f : generatedSourceFolders) {
- extraGeneratedSourceFolders.add(f);
javaCompileTask.source(f);
}
+
+ addJavaSourceFoldersToModel(generatedSourceFolders);
}
- public void addGeneratedSourceFolders(@NonNull Task task, @NonNull Iterable<File> generatedSourceFolders) {
+ public void registerJavaGeneratingTask(@NonNull Task task, @NonNull Collection<File> generatedSourceFolders) {
if (extraGeneratedSourceFolders == null) {
extraGeneratedSourceFolders = Lists.newArrayList();
}
@@ -155,8 +166,9 @@ public abstract class BaseVariantData {
javaCompileTask.dependsOn(task);
for (File f : generatedSourceFolders) {
- extraGeneratedSourceFolders.add(f);
javaCompileTask.source(f);
}
+
+ addJavaSourceFoldersToModel(generatedSourceFolders);
}
}
diff --git a/tests/genFolderApi/build.gradle b/tests/genFolderApi/build.gradle
index 542d956..3f35366 100644
--- a/tests/genFolderApi/build.gradle
+++ b/tests/genFolderApi/build.gradle
@@ -41,5 +41,5 @@ android.applicationVariants.all { variant ->
outputFile file("${sourceFolder.absolutePath}/com/custom/Foo.java")
}
- variant.addGeneratedSourceFolders(javaGenerationTask, sourceFolder)
+ variant.registerJavaGeneratingTask(javaGenerationTask, sourceFolder)
} \ No newline at end of file