use of com.android.builder.model.Dependencies in project meghanada-server by mopemope.
the class AndroidSupport method getAndroidDependencies.
private Set<ProjectDependency> getAndroidDependencies(AndroidProject androidProject) {
Set<ProjectDependency> dependencies = new HashSet<>(16);
Collection<String> bootClasspath = androidProject.getBootClasspath();
for (String cp : bootClasspath) {
File file = new File(cp);
addDependencies(dependencies, file);
}
Collection<Variant> variants = androidProject.getVariants();
for (Variant variant : variants) {
String buildType = variant.getBuildType();
boolean debugBuild = buildType.equals(DEBUG_BUILD);
AndroidArtifact mainArtifact = variant.getMainArtifact();
if (debugBuild) {
Collection<File> generatedSourceFolders = mainArtifact.getGeneratedSourceFolders();
for (File src : generatedSourceFolders) {
this.project.getSources().add(src);
}
Collection<File> generatedResourceFolders = mainArtifact.getGeneratedResourceFolders();
for (File src : generatedResourceFolders) {
this.project.getResources().add(src);
}
}
Dependencies compileDependencies = mainArtifact.getDependencies();
Collection<AndroidLibrary> libraries = compileDependencies.getLibraries();
for (AndroidLibrary androidLibrary : libraries) {
String project = androidLibrary.getProject();
if (nonNull(project) && !androidLibrary.isProvided()) {
if (project.startsWith(":")) {
project = project.substring(1);
}
if (this.project.allModules.containsKey(project)) {
File root = this.project.allModules.get(project);
final ProjectDependency projectDependency = new ProjectDependency(project, "COMPILE", "1.0.0", root, ProjectDependency.Type.PROJECT);
dependencies.add(projectDependency);
}
}
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);
}
parseExtraAndroidArtifacts(dependencies, variant);
parseExtraJavaArtifacts(dependencies, variant);
}
return dependencies;
}
use of com.android.builder.model.Dependencies in project meghanada-server by mopemope.
the class AndroidSupport method parseExtraJavaArtifacts.
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);
}
}
}
use of com.android.builder.model.Dependencies in project meghanada-server by mopemope.
the class AndroidSupport method parseExtraAndroidArtifacts.
private void parseExtraAndroidArtifacts(Set<ProjectDependency> dependencies, Variant variant) {
String buildType = variant.getBuildType();
boolean debugBuild = buildType.equals(DEBUG_BUILD);
Collection<AndroidArtifact> extraAndroidArtifacts = variant.getExtraAndroidArtifacts();
for (AndroidArtifact androidArtifact : extraAndroidArtifacts) {
String name = androidArtifact.getName();
boolean isTest = name.contains(TEST_SUFFIX);
if (debugBuild) {
Collection<File> generatedSourceFolders = androidArtifact.getGeneratedSourceFolders();
for (File src : generatedSourceFolders) {
if (isTest) {
this.project.getTestSources().add(src);
} else {
this.project.getSources().add(src);
}
}
Collection<File> generatedResourceFolders = androidArtifact.getGeneratedResourceFolders();
for (File src : generatedResourceFolders) {
if (isTest) {
this.project.getTestResources().add(src);
} else {
this.project.getResources().add(src);
}
}
}
Dependencies compileDependencies = androidArtifact.getDependencies();
// getLibraries
Collection<AndroidLibrary> libraries = compileDependencies.getLibraries();
for (AndroidLibrary androidLibrary : libraries) {
Collection<File> localJars = androidLibrary.getLocalJars();
if (localJars.isEmpty()) {
File jar = androidLibrary.getJarFile();
addDependencies(dependencies, jar);
} else {
for (File jar : localJars) {
addDependencies(dependencies, jar);
}
}
}
// getJavaLibraries
Collection<JavaLibrary> javaLibraries = compileDependencies.getJavaLibraries();
for (JavaLibrary javaLibrary : javaLibraries) {
File file = javaLibrary.getJarFile();
addDependencies(dependencies, file);
}
}
}
Aggregations