Search in sources :

Example 1 with PrepareLibraryTask

use of com.android.build.gradle.internal.tasks.PrepareLibraryTask in project atlas by alibaba.

the class TDependencyManager method maybeCreatePrepareLibraryTask.

/**
     * Handles the library and returns a task to "prepare" the library (ie unarchive it). The task
     * will be reused for all projects using the same library.
     *
     * @param library the library.
     * @param project the project
     * @return the prepare task.
     */
private PrepareLibraryTask maybeCreatePrepareLibraryTask(@NonNull AndroidLibrary library, @NonNull Project project) {
    LibraryDependency lib = (LibraryDependency) library;
    // create proper key for the map. library here contains all the dependencies which
    // are not relevant for the task (since the task only extract the aar which does not
    // include the dependencies.
    // However there is a possible case of a rewritten dependencies (with resolution strategy)
    // where the aar here could have different dependencies, in which case we would still
    // need the same task.
    // So we extract a AbstractBundleDependency (no dependencies) from the LibraryDependency to
    // make the map key that doesn't take into account the dependencies.
    String key = library.getResolvedCoordinates().toString();
    PrepareLibraryTask prepareLibraryTask = prepareLibTaskMap.get(key);
    if (prepareLibraryTask == null) {
        String bundleName = GUtil.toCamelCase(lib.getName().replaceAll("\\:", " "));
        prepareLibraryTask = project.getTasks().create("prepare" + bundleName + "Library", PrepareLibraryTask.class);
        prepareLibraryTask.setDescription("Prepare " + lib.getName());
        prepareLibraryTask.setBundle(lib.getBundle());
        prepareLibraryTask.setExplodedDir(lib.getFolder());
        prepareLibraryTask.setVariantName("");
        prepareLibTaskMap.put(key, prepareLibraryTask);
    }
    return prepareLibraryTask;
}
Also used : LibraryDependency(com.android.builder.dependency.LibraryDependency) PrepareLibraryTask(com.android.build.gradle.internal.tasks.PrepareLibraryTask)

Aggregations

PrepareLibraryTask (com.android.build.gradle.internal.tasks.PrepareLibraryTask)1 LibraryDependency (com.android.builder.dependency.LibraryDependency)1