use of com.android.builder.model.JavaCompileOptions in project meghanada-server by mopemope.
the class AndroidSupport method parseAndroidProject.
void parseAndroidProject(AndroidProject androidProject) throws IOException {
JavaCompileOptions javaCompileOptions = androidProject.getJavaCompileOptions();
this.project.setCompileSource(javaCompileOptions.getSourceCompatibility());
this.project.setCompileTarget(javaCompileOptions.getTargetCompatibility());
ProductFlavorContainer defaultConfig = androidProject.getDefaultConfig();
if (isNull(this.project.getOutput())) {
File buildDir = androidProject.getBuildFolder().getCanonicalFile();
String build = Joiner.on(File.separator).join(buildDir, INTERMEDIATE_DIR, CLASSES_DIR, DEBUG_DIR);
this.project.setOutput(project.normalize(build));
}
if (isNull(this.project.getTestOutput())) {
File buildDir = androidProject.getBuildFolder().getCanonicalFile();
String build = Joiner.on(File.separator).join(buildDir, INTERMEDIATE_DIR, CLASSES_DIR, TEST_DIR, DEBUG_DIR);
this.project.setTestOutput(this.project.normalize(build));
}
Map<String, Set<File>> androidSources = this.getAndroidSources(defaultConfig);
Set<ProjectDependency> dependencies = this.getAndroidDependencies(androidProject);
this.project.getSources().addAll(androidSources.getOrDefault(SOURCES_KEY, new HashSet<>()));
this.project.getResources().addAll(androidSources.getOrDefault(RESOURCES_KEY, new HashSet<>()));
this.project.getTestSources().addAll(androidSources.getOrDefault(TEST_SOURCES_KEY, new HashSet<>()));
this.project.getTestResources().addAll(androidSources.getOrDefault(AndroidSupport.TEST_RESOURCES_KEY, new HashSet<>()));
this.project.getDependencies().addAll(dependencies);
// merge other project
if (this.project.getSources().isEmpty()) {
File file = new File(Joiner.on(File.separator).join(SRC_DIR, MAIN_DIR, JAVA_DIR)).getCanonicalFile();
this.project.getSources().add(file);
}
if (this.project.getTestSources().isEmpty()) {
File file = new File(Joiner.on(File.separator).join(SRC_DIR, TEST_DIR, JAVA_DIR)).getCanonicalFile();
this.project.getTestSources().add(file);
}
if (isNull(this.project.getOutput())) {
String buildDir = new File(this.project.getProjectRoot(), BUILD_DIR).getCanonicalPath();
String build = Joiner.on(File.separator).join(buildDir, INTERMEDIATE_DIR, CLASSES_DIR, DEBUG_DIR);
this.project.setOutput(this.project.normalize(build));
}
if (isNull(this.project.getTestOutput())) {
String buildDir = new File(this.project.getProjectRoot(), BUILD_DIR).getCanonicalPath();
String build = Joiner.on(File.separator).join(buildDir, INTERMEDIATE_DIR, CLASSES_DIR, TEST_DIR, DEBUG_DIR);
this.project.setTestOutput(this.project.normalize(build));
}
// load exists aar
String aar = Joiner.on(File.separator).join(this.project.getProjectRoot(), BUILD_DIR, INTERMEDIATE_DIR, EXPLODED_DIR);
FileUtils.collectFiles(new File(aar), EXT_JAR).forEach(wrapIOConsumer(this::addAAR));
log.debug("sources {}", this.project.getSources());
log.debug("resources {}", this.project.getResources());
log.debug("output {}", this.project.getOutput());
log.debug("test sources {}", this.project.getTestSources());
log.debug("test resources {}", this.project.getTestResources());
log.debug("test output {}", this.project.getTestOutput());
for (ProjectDependency projectDependency : this.project.getDependencies()) {
log.debug("dependency {}", projectDependency);
}
}
Aggregations