diff options
Diffstat (limited to 'builder-model/src/main')
17 files changed, 267 insertions, 108 deletions
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<String> getNoCompress(); + Collection<String> getNoCompress(); } diff --git a/builder-model/src/main/java/com/android/builder/model/ArtifactInfo.java b/builder-model/src/main/java/com/android/builder/model/AndroidArtifact.java index 5d2ba6d..3cfd2f2 100644 --- a/builder-model/src/main/java/com/android/builder/model/ArtifactInfo.java +++ b/builder-model/src/main/java/com/android/builder/model/AndroidArtifact.java @@ -20,12 +20,12 @@ import com.android.annotations.NonNull; import com.android.annotations.Nullable; import java.io.File; -import java.util.List; +import java.util.Collection; /** - * The information for a generated artifact. + * The information for a generated Android artifact. */ -public interface ArtifactInfo { +public interface AndroidArtifact extends BaseArtifact { /** * Returns the output file for this artifact. Depending on whether the project is an app @@ -73,20 +73,6 @@ public interface ArtifactInfo { 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 @@ -99,7 +85,7 @@ public interface ArtifactInfo { * @return a list of folders. */ @NonNull - List<File> getGeneratedSourceFolders(); + Collection<File> getGeneratedSourceFolders(); /** * Returns all the resource folders that are generated. This is typically the renderscript @@ -108,22 +94,5 @@ public interface ArtifactInfo { * @return a list of folder. */ @NonNull - List<File> 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(); + Collection<File> 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<? extends AndroidLibrary> getLibraryDependencies(); @@ -74,7 +75,7 @@ public interface AndroidLibrary { * @return a list of File. May be empty but not null. */ @NonNull - List<File> getLocalJars(); + Collection<File> 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<String, BuildTypeContainer> getBuildTypes(); + Collection<BuildTypeContainer> 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<String, ProductFlavorContainer> getProductFlavors(); + Collection<ProductFlavorContainer> 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<Variant> 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<String, Variant> getVariants(); + Collection<ArtifactMetaData> 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<String> getBootClasspath(); + Collection<String> 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<File> getFrameworkSource(); + Collection<File> 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<String, SigningConfig> getSigningConfigs(); + Collection<SigningConfig> getSigningConfigs(); /** * Returns the aapt options. 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<ClassField> getBuildConfigFields(); + Collection<ClassField> getBuildConfigFields(); /** * Returns the list of proguard rule files. @@ -39,7 +39,7 @@ public interface BaseConfig { * @return a non-null list of files. */ @NonNull - List<File> getProguardFiles(); + Collection<File> 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<File> getConsumerProguardFiles(); + Collection<File> 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<SourceProviderContainer> 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<File> getJars(); + Collection<File> 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<String> getProjects(); + Collection<String> 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/NdkConfig.java b/builder-model/src/main/java/com/android/builder/model/NdkConfig.java index fbebf49..c750001 100644 --- a/builder-model/src/main/java/com/android/builder/NdkConfig.java +++ b/builder-model/src/main/java/com/android/builder/model/NdkConfig.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package com.android.builder; +package com.android.builder.model; import com.android.annotations.Nullable; -import java.util.Set; +import java.util.Collection; /** * Base class for NDK config file. @@ -41,13 +41,13 @@ public interface NdkConfig { * The LD Libs */ @Nullable - public Set<String> getLdLibs(); + public Collection<String> getLdLibs(); /** * The ABI Filters */ @Nullable - public Set<String> getAbiFilters(); + public Collection<String> 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<SourceProviderContainer> 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<File> getJavaDirectories(); + Collection<File> 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<File> getResourcesDirectories(); + Collection<File> 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<File> getAidlDirectories(); + Collection<File> 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<File> getRenderscriptDirectories(); + Collection<File> 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<File> getJniDirectories(); + Collection<File> 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<File> getResDirectories(); + Collection<File> 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<File> getAssetsDirectories(); + Collection<File> 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<AndroidArtifact> getExtraAndroidArtifacts(); + + @NonNull + Collection<JavaArtifact> getExtraJavaArtifacts(); /** * Returns the build type. All variants have a build type, so this is never null. @@ -91,13 +88,6 @@ public interface Variant { 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<String> getResourceConfigurations(); + Collection<String> getResourceConfigurations(); } |