Search in sources :

Example 6 with PathString

use of com.android.ide.common.util.PathString in project intellij by bazelbuild.

the class BlazeModuleSystem method toExternalLibrary.

@Nullable
static ExternalAndroidLibrary toExternalLibrary(Project project, @Nullable AarLibrary library, ArtifactLocationDecoder decoder) {
    if (library == null) {
        return null;
    }
    UnpackedAars unpackedAars = UnpackedAars.getInstance(project);
    File aarFile = unpackedAars.getAarDir(decoder, library);
    if (aarFile == null) {
        logger.warn(String.format("Fail to locate AAR file %s. Re-sync the project may solve the problem", library.aarArtifact));
        return null;
    }
    File resFolder = unpackedAars.getResourceDirectory(decoder, library);
    PathString resFolderPathString = resFolder == null ? null : new PathString(resFolder);
    return new ExternalLibraryImpl(library.key.toString()).withLocation(new PathString(aarFile)).withManifestFile(resFolderPathString == null ? null : resFolderPathString.getParentOrRoot().resolve("AndroidManifest.xml")).withResFolder(resFolderPathString == null ? null : new SelectiveResourceFolder(resFolderPathString, null)).withSymbolFile(resFolderPathString == null ? null : resFolderPathString.getParentOrRoot().resolve("R.txt")).withPackageName(library.resourcePackage);
}
Also used : SelectiveResourceFolder(com.android.projectmodel.SelectiveResourceFolder) PathString(com.android.ide.common.util.PathString) ExternalLibraryImpl(com.android.projectmodel.ExternalLibraryImpl) UnpackedAars(com.google.idea.blaze.android.libraries.UnpackedAars) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with PathString

use of com.android.ide.common.util.PathString in project intellij by bazelbuild.

the class BlazeModuleSystemDependentLibrariesIntegrationTest method getDependencies_workspaceModule.

@Test
public void getDependencies_workspaceModule() {
    PathString rootPath = new PathString(workspaceRoot.directory());
    Collection<ExternalAndroidLibrary> libraries = workspaceModuleSystem.getDependentLibraries();
    assertThat(new ArrayList<>(libraries)).containsExactly(getAarLibrary(rootPath, "third_party/quantum/values-third_party-quantum-res.aar", "third_party.quantum"), getAarLibrary(rootPath, "java/com/google/app-third_party-shared-res.aar", "com.google"), getAarLibrary(rootPath, "third_party/constraint_layout/constraint_layout-third_party-constraint_layout-res.aar", "third_party.constraint_layout"), getAarLibrary(rootPath, "third_party/aar/lib_aar.aar", "third_party.aar"));
}
Also used : ExternalAndroidLibrary(com.android.projectmodel.ExternalAndroidLibrary) ArrayList(java.util.ArrayList) PathString(com.android.ide.common.util.PathString) Test(org.junit.Test)

Example 8 with PathString

use of com.android.ide.common.util.PathString in project intellij by bazelbuild.

the class BlazeModuleSystemDependentLibrariesIntegrationTest method getDependencies_appModule.

@Test
public void getDependencies_appModule() {
    PathString rootPath = new PathString(workspaceRoot.directory());
    Collection<ExternalAndroidLibrary> libraries = appModuleSystem.getDependentLibraries();
    assertThat(new ArrayList<>(libraries)).containsExactly(getAarLibrary(rootPath, "third_party/aar/lib_aar.aar", "third_party.aar"), getAarLibrary(rootPath, "java/com/google/app-third_party-shared-res.aar", "com.google"), getAarLibrary(rootPath, "third_party/constraint_layout/constraint_layout-third_party-constraint_layout-res.aar", "third_party.constraint_layout"), getAarLibrary(rootPath, "third_party/quantum/values-third_party-quantum-res.aar", "third_party.quantum"));
}
Also used : ExternalAndroidLibrary(com.android.projectmodel.ExternalAndroidLibrary) ArrayList(java.util.ArrayList) PathString(com.android.ide.common.util.PathString) Test(org.junit.Test)

Aggregations

PathString (com.android.ide.common.util.PathString)8 Test (org.junit.Test)5 FileExtensions.toPathString (com.android.tools.idea.util.FileExtensions.toPathString)4 ExternalAndroidLibrary (com.android.projectmodel.ExternalAndroidLibrary)2 ExternalLibraryImpl (com.android.projectmodel.ExternalLibraryImpl)2 SelectiveResourceFolder (com.android.projectmodel.SelectiveResourceFolder)2 FileExtensions.toVirtualFile (com.android.tools.idea.util.FileExtensions.toVirtualFile)2 UnpackedAars (com.google.idea.blaze.android.libraries.UnpackedAars)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Nullable (org.jetbrains.annotations.Nullable)2