Java Code Examples for com.android.builder.model.Dependencies#getLibraries()

The following examples show how to use com.android.builder.model.Dependencies#getLibraries() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LintGradleProject.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a {@link LintGradleProject} from
 * the given {@link com.android.builder.model.AndroidProject} definition for
 * a given {@link com.android.builder.model.Variant}, and returns it along with
 * a set of lint custom rule jars applicable for the given model project.
 *
 * @param client        the client
 * @param project       the model project
 * @param variant       the variant
 * @param gradleProject the gradle project
 * @return a pair of new project and list of custom rule jars
 */
@NonNull
public static Pair<LintGradleProject, List<File>> create(
        @NonNull LintGradleClient client,
        @NonNull AndroidProject project,
        @NonNull Variant variant,
        @NonNull org.gradle.api.Project gradleProject) {
    File dir = gradleProject.getProjectDir();
    AppGradleProject lintProject = new AppGradleProject(client, dir,
            dir, project, variant);

    List<File> customRules = Lists.newArrayList();
    File appLintJar = new File(gradleProject.getBuildDir(),
            "lint" + separatorChar + "lint.jar");
    if (appLintJar.exists()) {
        customRules.add(appLintJar);
    }

    Set<AndroidLibrary> libraries = Sets.newHashSet();
    Dependencies dependencies = variant.getMainArtifact().getDependencies();
    for (AndroidLibrary library : dependencies.getLibraries()) {
        lintProject.addDirectLibrary(createLibrary(client, library, libraries, customRules));
    }

    return Pair.<LintGradleProject, List<File>>of(lintProject, customRules);
}
 
Example 2
Source File: LintGradleProject.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
protected static boolean dependsOn(@NonNull Dependencies dependencies,
                                   @NonNull String artifact) {
    for (AndroidLibrary library : dependencies.getLibraries()) {
        if (dependsOn(library, artifact)) {
            return true;
        }
    }
    return false;
}
 
Example 3
Source File: AndroidSupport.java    From meghanada-server with GNU General Public License v3.0 5 votes vote down vote up
private void parseExtraJavaArtifacts(Set<ProjectDependency> dependencies, Variant variant) {
  String buildType = variant.getBuildType();
  boolean debugBuild = buildType.equals(DEBUG_BUILD);
  Collection<JavaArtifact> extraJavaArtifacts = variant.getExtraJavaArtifacts();
  for (JavaArtifact javaArtifact : extraJavaArtifacts) {
    if (debugBuild) {
      Collection<File> generatedSourceFolders = javaArtifact.getGeneratedSourceFolders();
      for (File src : generatedSourceFolders) {
        this.project.getSources().add(src);
      }
    }

    Dependencies compileDependencies = javaArtifact.getDependencies();
    Collection<AndroidLibrary> libraries = compileDependencies.getLibraries();
    for (AndroidLibrary androidLibrary : libraries) {
      Collection<File> localJars = androidLibrary.getLocalJars();
      for (File jar : localJars) {
        addDependencies(dependencies, jar);
      }
    }
    Collection<JavaLibrary> javaLibraries = compileDependencies.getJavaLibraries();
    for (JavaLibrary javaLibrary : javaLibraries) {
      File file = javaLibrary.getJarFile();
      addDependencies(dependencies, file);
    }
  }
}