From 2cae6225fe7c618afd5efc6bff9efd69d0e9a724 Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet Date: Mon, 25 Nov 2013 15:35:44 -0800 Subject: Extensible model with extra artifacts per variants. Change-Id: If4c1b8f672c088924ac1738da7887175412cbd1d --- .../main/java/com/android/builder/NdkConfig.java | 54 --------- .../com/android/builder/model/AaptOptions.java | 4 +- .../com/android/builder/model/AndroidArtifact.java | 98 ++++++++++++++++ .../com/android/builder/model/AndroidLibrary.java | 5 +- .../com/android/builder/model/AndroidProject.java | 47 ++++---- .../com/android/builder/model/ArtifactInfo.java | 129 --------------------- .../android/builder/model/ArtifactMetaData.java | 35 ++++++ .../com/android/builder/model/BaseArtifact.java | 87 ++++++++++++++ .../java/com/android/builder/model/BaseConfig.java | 8 +- .../java/com/android/builder/model/BuildType.java | 5 +- .../android/builder/model/BuildTypeContainer.java | 10 ++ .../com/android/builder/model/Dependencies.java | 7 +- .../com/android/builder/model/JavaArtifact.java | 24 ++++ .../java/com/android/builder/model/NdkConfig.java | 54 +++++++++ .../com/android/builder/model/ProductFlavor.java | 7 +- .../builder/model/ProductFlavorContainer.java | 8 +- .../com/android/builder/model/SourceProvider.java | 16 +-- .../builder/model/SourceProviderContainer.java | 37 ++++++ .../java/com/android/builder/model/Variant.java | 26 ++--- 19 files changed, 410 insertions(+), 251 deletions(-) delete mode 100644 builder-model/src/main/java/com/android/builder/NdkConfig.java create mode 100644 builder-model/src/main/java/com/android/builder/model/AndroidArtifact.java delete mode 100644 builder-model/src/main/java/com/android/builder/model/ArtifactInfo.java create mode 100644 builder-model/src/main/java/com/android/builder/model/ArtifactMetaData.java create mode 100644 builder-model/src/main/java/com/android/builder/model/BaseArtifact.java create mode 100644 builder-model/src/main/java/com/android/builder/model/JavaArtifact.java create mode 100644 builder-model/src/main/java/com/android/builder/model/NdkConfig.java create mode 100644 builder-model/src/main/java/com/android/builder/model/SourceProviderContainer.java (limited to 'builder-model/src/main/java') diff --git a/builder-model/src/main/java/com/android/builder/NdkConfig.java b/builder-model/src/main/java/com/android/builder/NdkConfig.java deleted file mode 100644 index fbebf49..0000000 --- a/builder-model/src/main/java/com/android/builder/NdkConfig.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2013 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.builder; - -import com.android.annotations.Nullable; - -import java.util.Set; - -/** - * Base class for NDK config file. - */ -public interface NdkConfig { - - /** - * The module name - */ - @Nullable - public String getModuleName(); - - /** - * The C Flags - */ - @Nullable - public String getcFlags(); - - /** - * The LD Libs - */ - @Nullable - public Set getLdLibs(); - - /** - * The ABI Filters - */ - @Nullable - public Set getAbiFilters(); - - @Nullable - public String getStl(); -} diff --git a/builder-model/src/main/java/com/android/builder/model/AaptOptions.java b/builder-model/src/main/java/com/android/builder/model/AaptOptions.java index 86192e0..4cb9b36 100644 --- a/builder-model/src/main/java/com/android/builder/model/AaptOptions.java +++ b/builder-model/src/main/java/com/android/builder/model/AaptOptions.java @@ -16,7 +16,7 @@ package com.android.builder.model; -import java.util.List; +import java.util.Collection; /** * Options for aapt. @@ -30,5 +30,5 @@ public interface AaptOptions { /** * Returns the list of values for the -0 (disabled compression) option, or null */ - List getNoCompress(); + Collection getNoCompress(); } diff --git a/builder-model/src/main/java/com/android/builder/model/AndroidArtifact.java b/builder-model/src/main/java/com/android/builder/model/AndroidArtifact.java new file mode 100644 index 0000000..3cfd2f2 --- /dev/null +++ b/builder-model/src/main/java/com/android/builder/model/AndroidArtifact.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2013 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.builder.model; + +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; + +import java.io.File; +import java.util.Collection; + +/** + * The information for a generated Android artifact. + */ +public interface AndroidArtifact extends BaseArtifact { + + /** + * Returns the output file for this artifact. Depending on whether the project is an app + * or a library project, this could be an apk or an aar file. + * + * For test artifact for a library project, this would also be an apk. + * + * @return the output file. + */ + @NonNull + File getOutputFile(); + + /** + * Returns whether the output file is signed. This is always false for the main artifact + * of a library project. + * + * @return true if the app is signed. + */ + boolean isSigned(); + + /** + * Returns the name of the {@link SigningConfig} used for the signing. If none are setup or + * if this is the main artifact of a library project, then this is null. + * + * @return the name of the setup signing config. + */ + @Nullable + String getSigningConfigName(); + + /** + * Returns the package name of this artifact. + * + * @return the package name. + */ + @NonNull + String getPackageName(); + + /** + * Returns the name of the task used to generate the source code. The actual value might + * depend on the build system front end. + * + * @return the name of the code generating task. + */ + @NonNull + String getSourceGenTaskName(); + + /** + * The generated manifest for this variant's artifact. + */ + @NonNull + File getGeneratedManifest(); + + /** + * Returns all the source folders that are generated. This is typically folders for the R, + * the aidl classes, and the renderscript classes. + * + * @return a list of folders. + */ + @NonNull + Collection getGeneratedSourceFolders(); + + /** + * Returns all the resource folders that are generated. This is typically the renderscript + * output and the merged resources. + * + * @return a list of folder. + */ + @NonNull + Collection getGeneratedResourceFolders(); +} diff --git a/builder-model/src/main/java/com/android/builder/model/AndroidLibrary.java b/builder-model/src/main/java/com/android/builder/model/AndroidLibrary.java index 7d7a47f..a46cb7e 100644 --- a/builder-model/src/main/java/com/android/builder/model/AndroidLibrary.java +++ b/builder-model/src/main/java/com/android/builder/model/AndroidLibrary.java @@ -20,6 +20,7 @@ import com.android.annotations.NonNull; import com.android.annotations.Nullable; import java.io.File; +import java.util.Collection; import java.util.List; /** @@ -49,7 +50,7 @@ public interface AndroidLibrary { File getFolder(); /** - * Returns the direct dependency of this dependency. + * Returns the direct dependency of this dependency. The order is important. */ @NonNull List getLibraryDependencies(); @@ -74,7 +75,7 @@ public interface AndroidLibrary { * @return a list of File. May be empty but not null. */ @NonNull - List getLocalJars(); + Collection getLocalJars(); /** * Returns the location of the res folder. diff --git a/builder-model/src/main/java/com/android/builder/model/AndroidProject.java b/builder-model/src/main/java/com/android/builder/model/AndroidProject.java index a63f16c..f1118f4 100644 --- a/builder-model/src/main/java/com/android/builder/model/AndroidProject.java +++ b/builder-model/src/main/java/com/android/builder/model/AndroidProject.java @@ -20,8 +20,6 @@ import com.android.annotations.NonNull; import java.io.File; import java.util.Collection; -import java.util.List; -import java.util.Map; /** * Entry point for the model of the Android Projects. This models a single module, whether @@ -30,6 +28,9 @@ import java.util.Map; public interface AndroidProject { String BUILD_MODEL_ONLY_SYSTEM_PROPERTY = "android.build.model.only"; + public static final String ARTIFACT_MAIN = "_main_"; + public static final String ARTIFACT_INSTRUMENT_TEST = "_instrument_test_"; + /** * Returns the model version. This is a string in the format X.Y.Z * @@ -61,34 +62,39 @@ public interface AndroidProject { ProductFlavorContainer getDefaultConfig(); /** - * Returns a map of all the {@link BuildType} in their container. The key is the build type - * name as returned by {@link BuildType#getName()} + * Returns a list of all the {@link BuildType} in their container. * - * @return a map of build type containers. + * @return a list of build type containers. */ @NonNull - Map getBuildTypes(); + Collection getBuildTypes(); /** - * Returns a map of all the {@link ProductFlavor} in their container. The key is the product - * flavor name as returned by {@link ProductFlavor#getName()} + * Returns a list of all the {@link ProductFlavor} in their container. * - * @return a map of product flavor containers. + * @return a list of product flavor containers. */ @NonNull - Map getProductFlavors(); + Collection getProductFlavors(); /** - * Returns a map of all the variants. The key is the variant name as returned by - * {@link Variant#getName()}. + * Returns a list of all the variants. + * + * This does not include test variant. Test variants are additional artifacts in their + * respective variant info. * - * This does not include test variant. Instead the variant and its component each contribute - * their test part. + * @return a list of the variants. + */ + @NonNull + Collection getVariants(); + + /** + * Returns a list of extra artifacts meta data. This does not include the main artifact. * - * @return a map of the variants. + * @return a list of extra artifacts */ @NonNull - Map getVariants(); + Collection getExtraArtifacts(); /** * Returns the compilation target as a string. This is the full extended target hash string. @@ -106,23 +112,22 @@ public interface AndroidProject { * @return a list of jar files. */ @NonNull - List getBootClasspath(); + Collection getBootClasspath(); /** * Returns a list of folders or jar files that contains the framework source code. * @return a list of folders or jar files that contains the framework source code. */ @NonNull - List getFrameworkSource(); + Collection getFrameworkSources(); /** - * Returns a map of {@link SigningConfig}. The key is the signing config name as returned by - * {@link SigningConfig#getName()} + * Returns a list of {@link SigningConfig}. * * @return a map of signing config */ @NonNull - Map getSigningConfigs(); + Collection getSigningConfigs(); /** * Returns the aapt options. diff --git a/builder-model/src/main/java/com/android/builder/model/ArtifactInfo.java b/builder-model/src/main/java/com/android/builder/model/ArtifactInfo.java deleted file mode 100644 index 5d2ba6d..0000000 --- a/builder-model/src/main/java/com/android/builder/model/ArtifactInfo.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2013 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.builder.model; - -import com.android.annotations.NonNull; -import com.android.annotations.Nullable; - -import java.io.File; -import java.util.List; - -/** - * The information for a generated artifact. - */ -public interface ArtifactInfo { - - /** - * Returns the output file for this artifact. Depending on whether the project is an app - * or a library project, this could be an apk or an aar file. - * - * For test artifact for a library project, this would also be an apk. - * - * @return the output file. - */ - @NonNull - File getOutputFile(); - - /** - * Returns whether the output file is signed. This is always false for the main artifact - * of a library project. - * - * @return true if the app is signed. - */ - boolean isSigned(); - - /** - * Returns the name of the {@link SigningConfig} used for the signing. If none are setup or - * if this is the main artifact of a library project, then this is null. - * - * @return the name of the setup signing config. - */ - @Nullable - String getSigningConfigName(); - - /** - * Returns the package name of this artifact. - * - * @return the package name. - */ - @NonNull - String getPackageName(); - - /** - * Returns the name of the task used to generate the source code. The actual value might - * depend on the build system front end. - * - * @return the name of the code generating task. - */ - @NonNull - String getSourceGenTaskName(); - - /** - * @return the name of the task used to compile Java code. - */ - @NonNull - String getJavaCompileTaskName(); - - /** - * Returns the name of the task used to generate the artifact. - * - * @return the name of the task. - */ - @NonNull - String getAssembleTaskName(); - - /** - * The generated manifest for this variant's artifact. - */ - @NonNull - File getGeneratedManifest(); - - /** - * Returns all the source folders that are generated. This is typically folders for the R, - * the aidl classes, and the renderscript classes. - * - * @return a list of folders. - */ - @NonNull - List getGeneratedSourceFolders(); - - /** - * Returns all the resource folders that are generated. This is typically the renderscript - * output and the merged resources. - * - * @return a list of folder. - */ - @NonNull - List getGeneratedResourceFolders(); - - /** - * Returns the folder containing the class files. This is the output of the java compilation. - * - * @return a folder. - */ - @NonNull - File getClassesFolder(); - - /** - * Returns the resolved dependencies for this artifact. This is a composite of all the - * dependencies for that artifact: default config + build type + flavor(s).s - * - * @return The dependencies. - */ - @NonNull - Dependencies getDependencies(); -} diff --git a/builder-model/src/main/java/com/android/builder/model/ArtifactMetaData.java b/builder-model/src/main/java/com/android/builder/model/ArtifactMetaData.java new file mode 100644 index 0000000..f1af029 --- /dev/null +++ b/builder-model/src/main/java/com/android/builder/model/ArtifactMetaData.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2013 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.builder.model; + +import com.android.annotations.NonNull; + +/** + * Meta Data for an Artifact. + */ +public interface ArtifactMetaData { + + public final static int TYPE_ANDROID = 1; + public final static int TYPE_JAVA = 2; + + @NonNull + String getName(); + + boolean isTest(); + + int getType(); +} diff --git a/builder-model/src/main/java/com/android/builder/model/BaseArtifact.java b/builder-model/src/main/java/com/android/builder/model/BaseArtifact.java new file mode 100644 index 0000000..fd1a7b7 --- /dev/null +++ b/builder-model/src/main/java/com/android/builder/model/BaseArtifact.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2013 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.builder.model; + +import com.android.annotations.NonNull; +import com.android.annotations.Nullable; + +import java.io.File; + +/** + * The base information for all generated artifacts + */ +public interface BaseArtifact { + + /** + * Name of the artifact. This should match {@link ArtifactMetaData#getName()}. + */ + @NonNull + String getName(); + + /** + * @return the name of the task used to compile Java code. + */ + @NonNull + String getJavaCompileTaskName(); + + /** + * Returns the name of the task used to generate the artifact. + * + * @return the name of the task. + */ + @NonNull + String getAssembleTaskName(); + + /** + * Returns the folder containing the class files. This is the output of the java compilation. + * + * @return a folder. + */ + @NonNull + File getClassesFolder(); + + /** + * Returns the resolved dependencies for this artifact. This is a composite of all the + * dependencies for that artifact: default config + build type + flavor(s).s + * + * @return The dependencies. + */ + @NonNull + Dependencies getDependencies(); + + /** + * A SourceProvider specific to the variant. This can be null if there is no flavors as + * the "variant" is equal to the build type. + * + * @return the variant specific source provider + */ + @Nullable + SourceProvider getVariantSourceProvider(); + + /** + * A SourceProvider specific to the flavor combination. + * + * For instance if there are 2 dimensions, then this would be Flavor1Flavor2, and would be + * common to all variant using these two flavors and any of the build type. + * + * This can be null if there is less than 2 flavors. + * + * @return the multi flavor specific source provider + */ + @Nullable + SourceProvider getMultiFlavorSourceProvider(); +} diff --git a/builder-model/src/main/java/com/android/builder/model/BaseConfig.java b/builder-model/src/main/java/com/android/builder/model/BaseConfig.java index 713b344..d4e22c1 100644 --- a/builder-model/src/main/java/com/android/builder/model/BaseConfig.java +++ b/builder-model/src/main/java/com/android/builder/model/BaseConfig.java @@ -19,7 +19,7 @@ package com.android.builder.model; import com.android.annotations.NonNull; import java.io.File; -import java.util.List; +import java.util.Collection; /** * Base config object for Build Type and Product flavor. @@ -31,7 +31,7 @@ public interface BaseConfig { * @return a non-null list of class fields (possibly empty) */ @NonNull - List getBuildConfigFields(); + Collection getBuildConfigFields(); /** * Returns the list of proguard rule files. @@ -39,7 +39,7 @@ public interface BaseConfig { * @return a non-null list of files. */ @NonNull - List getProguardFiles(); + Collection getProguardFiles(); /** * Returns the list of proguard rule files for consumers of the library to use. @@ -47,5 +47,5 @@ public interface BaseConfig { * @return a non-null list of files. */ @NonNull - List getConsumerProguardFiles(); + Collection getConsumerProguardFiles(); } diff --git a/builder-model/src/main/java/com/android/builder/model/BuildType.java b/builder-model/src/main/java/com/android/builder/model/BuildType.java index d846a90..9bdc6dc 100644 --- a/builder-model/src/main/java/com/android/builder/model/BuildType.java +++ b/builder-model/src/main/java/com/android/builder/model/BuildType.java @@ -18,7 +18,6 @@ package com.android.builder.model; import com.android.annotations.NonNull; import com.android.annotations.Nullable; -import com.android.builder.NdkConfig; /** * a Build Type. This is only the configuration of the build type. @@ -27,7 +26,7 @@ import com.android.builder.NdkConfig; * or in the artifact info. * * @see BuildTypeContainer - * @see ArtifactInfo#getDependencies() + * @see AndroidArtifact#getDependencies() */ public interface BuildType extends BaseConfig { @@ -70,7 +69,7 @@ public interface BuildType extends BaseConfig { /** * Returns the package name suffix applied to this build type. - * To get the final package name, use {@link ArtifactInfo#getPackageName()}. + * To get the final package name, use {@link AndroidArtifact#getPackageName()}. * * @return the package name suffix. */ diff --git a/builder-model/src/main/java/com/android/builder/model/BuildTypeContainer.java b/builder-model/src/main/java/com/android/builder/model/BuildTypeContainer.java index 4a0170d..87765f1 100644 --- a/builder-model/src/main/java/com/android/builder/model/BuildTypeContainer.java +++ b/builder-model/src/main/java/com/android/builder/model/BuildTypeContainer.java @@ -18,6 +18,8 @@ package com.android.builder.model; import com.android.annotations.NonNull; +import java.util.Collection; + /** * A Container of all the data related to {@link BuildType}. */ @@ -38,4 +40,12 @@ public interface BuildTypeContainer { */ @NonNull SourceProvider getSourceProvider(); + + /** + * Returns a list of ArtifactMetaData/SourceProvider association. + * + * @return a list of ArtifactMetaData/SourceProvider association. + */ + @NonNull + Collection getExtraSourceProviders(); } diff --git a/builder-model/src/main/java/com/android/builder/model/Dependencies.java b/builder-model/src/main/java/com/android/builder/model/Dependencies.java index b5a27d1..f28b648 100644 --- a/builder-model/src/main/java/com/android/builder/model/Dependencies.java +++ b/builder-model/src/main/java/com/android/builder/model/Dependencies.java @@ -19,10 +19,11 @@ package com.android.builder.model; import com.android.annotations.NonNull; import java.io.File; +import java.util.Collection; import java.util.List; /** - * A set of dependencies for an {@link ArtifactInfo}. + * A set of dependencies for an {@link AndroidArtifact}. */ public interface Dependencies { @@ -41,7 +42,7 @@ public interface Dependencies { * @return the list of jar files. */ @NonNull - List getJars(); + Collection getJars(); /** * The list of project dependencies. This is only for non Android module dependencies (which @@ -50,5 +51,5 @@ public interface Dependencies { * @return the list of projects. */ @NonNull - List getProjects(); + Collection getProjects(); } diff --git a/builder-model/src/main/java/com/android/builder/model/JavaArtifact.java b/builder-model/src/main/java/com/android/builder/model/JavaArtifact.java new file mode 100644 index 0000000..02cba55 --- /dev/null +++ b/builder-model/src/main/java/com/android/builder/model/JavaArtifact.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2013 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.builder.model; + +/** + * The information for a generated Java artifact. + */ +public interface JavaArtifact extends BaseArtifact { + +} diff --git a/builder-model/src/main/java/com/android/builder/model/NdkConfig.java b/builder-model/src/main/java/com/android/builder/model/NdkConfig.java new file mode 100644 index 0000000..c750001 --- /dev/null +++ b/builder-model/src/main/java/com/android/builder/model/NdkConfig.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2013 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.builder.model; + +import com.android.annotations.Nullable; + +import java.util.Collection; + +/** + * Base class for NDK config file. + */ +public interface NdkConfig { + + /** + * The module name + */ + @Nullable + public String getModuleName(); + + /** + * The C Flags + */ + @Nullable + public String getcFlags(); + + /** + * The LD Libs + */ + @Nullable + public Collection getLdLibs(); + + /** + * The ABI Filters + */ + @Nullable + public Collection getAbiFilters(); + + @Nullable + public String getStl(); +} diff --git a/builder-model/src/main/java/com/android/builder/model/ProductFlavor.java b/builder-model/src/main/java/com/android/builder/model/ProductFlavor.java index 9563136..6f8d4af 100644 --- a/builder-model/src/main/java/com/android/builder/model/ProductFlavor.java +++ b/builder-model/src/main/java/com/android/builder/model/ProductFlavor.java @@ -18,7 +18,6 @@ package com.android.builder.model; import com.android.annotations.NonNull; import com.android.annotations.Nullable; -import com.android.builder.NdkConfig; /** * a Product Flavor. This is only the configuration of the flavor. @@ -27,7 +26,7 @@ import com.android.builder.NdkConfig; * or in the artifact info. * * @see ProductFlavorContainer - * @see ArtifactInfo#getDependencies() + * @see BaseArtifact#getDependencies() */ public interface ProductFlavor extends BaseConfig { @@ -41,7 +40,7 @@ public interface ProductFlavor extends BaseConfig { /** * Returns the name of the product flavor. This is only the value set on this product flavor. - * To get the final package name, use {@link ArtifactInfo#getPackageName()}. + * To get the final package name, use {@link AndroidArtifact#getPackageName()}. * * @return the package name. */ @@ -95,7 +94,7 @@ public interface ProductFlavor extends BaseConfig { /** * Returns the test package name. This is only the value set on this product flavor. * To get the final value, use {@link Variant#getTestArtifactInfo()} and - * {@link ArtifactInfo#getPackageName()} + * {@link AndroidArtifact#getPackageName()} * * @return the test package name. */ diff --git a/builder-model/src/main/java/com/android/builder/model/ProductFlavorContainer.java b/builder-model/src/main/java/com/android/builder/model/ProductFlavorContainer.java index f8cc7ed..8643f9d 100644 --- a/builder-model/src/main/java/com/android/builder/model/ProductFlavorContainer.java +++ b/builder-model/src/main/java/com/android/builder/model/ProductFlavorContainer.java @@ -18,6 +18,8 @@ package com.android.builder.model; import com.android.annotations.NonNull; +import java.util.Collection; + /** * A Container of all the data related to {@link ProductFlavor}. */ @@ -40,10 +42,10 @@ public interface ProductFlavorContainer { SourceProvider getSourceProvider(); /** - * The associated test sources of the product flavor + * Returns a list of ArtifactMetaData/SourceProvider association. * - * @return the test source provider. + * @return a list of ArtifactMetaData/SourceProvider association. */ @NonNull - SourceProvider getTestSourceProvider(); + Collection getExtraSourceProviders(); } diff --git a/builder-model/src/main/java/com/android/builder/model/SourceProvider.java b/builder-model/src/main/java/com/android/builder/model/SourceProvider.java index 7ed06ef..6d58e64 100644 --- a/builder-model/src/main/java/com/android/builder/model/SourceProvider.java +++ b/builder-model/src/main/java/com/android/builder/model/SourceProvider.java @@ -18,7 +18,7 @@ package com.android.builder.model; import com.android.annotations.NonNull; import java.io.File; -import java.util.Set; +import java.util.Collection; /** * Represent a SourceProvider for a given configuration. @@ -41,7 +41,7 @@ public interface SourceProvider { * @return a list of folders. They may not all exist. */ @NonNull - Set getJavaDirectories(); + Collection getJavaDirectories(); /** * Returns the java resources folders. @@ -49,7 +49,7 @@ public interface SourceProvider { * @return a list of folders. They may not all exist. */ @NonNull - Set getResourcesDirectories(); + Collection getResourcesDirectories(); /** * Returns the aidl source folders. @@ -57,7 +57,7 @@ public interface SourceProvider { * @return a list of folders. They may not all exist. */ @NonNull - Set getAidlDirectories(); + Collection getAidlDirectories(); /** * Returns the renderscript source folders. @@ -65,7 +65,7 @@ public interface SourceProvider { * @return a list of folders. They may not all exist. */ @NonNull - Set getRenderscriptDirectories(); + Collection getRenderscriptDirectories(); /** * Returns the jni source folders. @@ -73,7 +73,7 @@ public interface SourceProvider { * @return a list of folders. They may not all exist. */ @NonNull - Set getJniDirectories(); + Collection getJniDirectories(); /** * Returns the android resources folders. @@ -81,7 +81,7 @@ public interface SourceProvider { * @return a list of folders. They may not all exist. */ @NonNull - Set getResDirectories(); + Collection getResDirectories(); /** * Returns the android assets folders. @@ -89,5 +89,5 @@ public interface SourceProvider { * @return a list of folders. They may not all exist. */ @NonNull - Set getAssetsDirectories(); + Collection getAssetsDirectories(); } diff --git a/builder-model/src/main/java/com/android/builder/model/SourceProviderContainer.java b/builder-model/src/main/java/com/android/builder/model/SourceProviderContainer.java new file mode 100644 index 0000000..0ac8387 --- /dev/null +++ b/builder-model/src/main/java/com/android/builder/model/SourceProviderContainer.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2013 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.builder.model; + +import com.android.annotations.NonNull; + +/** + * An association of an {@link ArtifactMetaData}'s name and a {@link SourceProvider}. + */ +public interface SourceProviderContainer { + + /** + * Returns the name matching {@link ArtifactMetaData#getName()} + */ + @NonNull + String getArtifactName(); + + /** + * Returns the source provider + */ + @NonNull + SourceProvider getSourceProvider(); +} diff --git a/builder-model/src/main/java/com/android/builder/model/Variant.java b/builder-model/src/main/java/com/android/builder/model/Variant.java index 2f32c66..532901e 100644 --- a/builder-model/src/main/java/com/android/builder/model/Variant.java +++ b/builder-model/src/main/java/com/android/builder/model/Variant.java @@ -17,8 +17,8 @@ package com.android.builder.model; import com.android.annotations.NonNull; -import com.android.annotations.Nullable; +import java.util.Collection; import java.util.List; /** @@ -49,16 +49,13 @@ public interface Variant { * @return the artifact. */ @NonNull - ArtifactInfo getMainArtifactInfo(); + AndroidArtifact getMainArtifact(); - /** - * Returns the test artifact for this variant. This may be null if this particular variant - * is not configured to be tested. - * - * @return the test artifact. - */ - @Nullable - ArtifactInfo getTestArtifactInfo(); + @NonNull + Collection getExtraAndroidArtifacts(); + + @NonNull + Collection getExtraJavaArtifacts(); /** * Returns the build type. All variants have a build type, so this is never null. @@ -90,13 +87,6 @@ public interface Variant { @NonNull ProductFlavor getMergedFlavor(); - /** - * The variant specific SourceProvider. - * @return a source provider or null - */ - @Nullable - SourceProvider getSourceProvider(); - /** * Returns the resource configuration for this variant. * TODO implement this. @@ -106,5 +96,5 @@ public interface Variant { * @return the resource configuration options. */ @NonNull - List getResourceConfigurations(); + Collection getResourceConfigurations(); } -- cgit v1.2.3