use of com.android.builder.model.AndroidLibrary in project android by JetBrains.
the class BuildVariantUpdater method updateSelectedVariant.
private boolean updateSelectedVariant(@NotNull AndroidFacet androidFacet, @NotNull AndroidModuleModel androidModel, @NotNull String variantToSelect, @NotNull List<AndroidFacet> affectedFacets) {
Variant selectedVariant = androidModel.getSelectedVariant();
if (variantToSelect.equals(selectedVariant.getName())) {
return false;
}
androidModel.setSelectedVariantName(variantToSelect);
androidModel.syncSelectedVariantAndTestArtifact(androidFacet);
Module module = setUpModule(androidFacet.getModule(), androidModel);
for (AndroidLibrary library : androidModel.getSelectedMainCompileDependencies().getLibraries()) {
String gradlePath = library.getProject();
if (isEmpty(gradlePath)) {
continue;
}
String projectVariant = library.getProjectVariant();
if (isNotEmpty(projectVariant)) {
ensureVariantIsSelected(module.getProject(), gradlePath, projectVariant, affectedFacets);
}
}
return true;
}
use of com.android.builder.model.AndroidLibrary in project android by JetBrains.
the class GeneratedCodeMatchTest method findViewDataBindingClass.
@NotNull
private ClassReader findViewDataBindingClass() throws IOException {
File classes = null;
AndroidModuleModel model = AndroidModuleModel.get(myAndroidFacet);
for (AndroidLibrary lib : model.getMainArtifact().getDependencies().getLibraries()) {
if (lib.getName().startsWith("com.android.databinding:library")) {
classes = lib.getJarFile();
}
}
assert classes != null;
assertTrue(classes.exists());
try (JarFile classesJar = new JarFile(classes, true)) {
ZipEntry entry = classesJar.getEntry(SdkConstants.CLASS_DATA_BINDING_BASE_BINDING.replace(".", "/") + ".class");
assertNotNull(entry);
return new ClassReader(classesJar.getInputStream(entry));
}
}
use of com.android.builder.model.AndroidLibrary 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.AndroidLibrary 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);
}
}
}
use of com.android.builder.model.AndroidLibrary in project atlas by alibaba.
the class AtlasDataBindingMergeArtifactsTransform method processAwbsDataBindings.
private void processAwbsDataBindings() throws IOException {
AtlasDependencyTree atlasDependencyTree = AtlasBuildContext.androidDependencyTrees.get(variantContext.getVariantName());
for (AwbBundle awbBundle : atlasDependencyTree.getAwbBundles()) {
File awbDataBindDepsOutDir = variantContext.getAwbDataBindingMergeArtifacts(awbBundle);
for (AndroidLibrary androidLibrary : awbBundle.getAndroidLibraries()) {
File artifactFolder = new File(androidLibrary.getFolder(), DataBindingBuilder.DATA_BINDING_ROOT_FOLDER_IN_AAR + "/" + DataBindingBuilder.INCREMENTAL_BIN_AAR_DIR);
if (artifactFolder.exists() && artifactFolder.listFiles() != null) {
for (String artifactName : artifactFolder.list()) {
if (isResource(artifactName)) {
FileUtils.copyFile(new File(artifactFolder, artifactName), new File(awbDataBindDepsOutDir, artifactName));
}
}
}
}
File awbDataBindDir = new File(awbBundle.getAndroidLibrary().getFolder(), DataBindingBuilder.DATA_BINDING_ROOT_FOLDER_IN_AAR + "/" + DataBindingBuilder.INCREMENTAL_BIN_AAR_DIR);
if (awbDataBindDir.exists() && awbDataBindDir.listFiles() != null) {
for (String artifactName : awbDataBindDir.list()) {
if (isResource(artifactName)) {
FileUtils.copyFile(new File(awbDataBindDir, artifactName), new File(awbDataBindDepsOutDir, artifactName));
}
}
}
}
}
Aggregations