Search in sources :

Example 1 with SelectiveResourceFolder

use of com.android.projectmodel.SelectiveResourceFolder in project intellij by bazelbuild.

the class BlazeModuleSystemDependentLibrariesIntegrationTest method getAarLibrary.

private ExternalAndroidLibrary getAarLibrary(PathString rootPath, String aarPath, @Nullable String resourcePackage) {
    String path = rootPath.resolve(aarPath).getNativePath();
    String name = FileUtil.getNameWithoutExtension(PathUtil.getFileName(path));
    String aarDirName = UnpackedAarUtils.generateAarDirectoryName(name, path.hashCode()) + SdkConstants.DOT_AAR;
    UnpackedAars unpackedAars = UnpackedAars.getInstance(getProject());
    File aarDir = new File(unpackedAars.getCacheDir(), aarDirName);
    PathString aarFile = new PathString(aarDir);
    PathString resFolder = new PathString(UnpackedAarUtils.getResDir(aarDir));
    return new ExternalLibraryImpl(LibraryKey.libraryNameFromArtifactLocation(source(aarPath))).withLocation(aarFile).withManifestFile(resFolder == null ? null : resFolder.getParentOrRoot().resolve("AndroidManifest.xml")).withResFolder(resFolder == null ? null : new SelectiveResourceFolder(resFolder, null)).withSymbolFile(resFolder == null ? null : resFolder.getParentOrRoot().resolve("R.txt")).withPackageName(resourcePackage);
}
Also used : SelectiveResourceFolder(com.android.projectmodel.SelectiveResourceFolder) PathString(com.android.ide.common.util.PathString) ExternalLibraryImpl(com.android.projectmodel.ExternalLibraryImpl) PathString(com.android.ide.common.util.PathString) UnpackedAars(com.google.idea.blaze.android.libraries.UnpackedAars) File(java.io.File)

Example 2 with SelectiveResourceFolder

use of com.android.projectmodel.SelectiveResourceFolder 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)

Aggregations

PathString (com.android.ide.common.util.PathString)2 ExternalLibraryImpl (com.android.projectmodel.ExternalLibraryImpl)2 SelectiveResourceFolder (com.android.projectmodel.SelectiveResourceFolder)2 UnpackedAars (com.google.idea.blaze.android.libraries.UnpackedAars)2 File (java.io.File)2 Nullable (org.jetbrains.annotations.Nullable)1