use of com.android.ide.common.util.PathString in project intellij by bazelbuild.
the class BlazeSampleDataDirectoryProvider method getOrCreateSampleDataDirectory.
@Override
@Nullable
public PathString getOrCreateSampleDataDirectory() throws IOException {
PathString sampleDataDirectory = getSampleDataDirectory();
if (sampleDataDirectory == null) {
return null;
}
PathString rootPath = sampleDataDirectory.getRoot();
VirtualFile root = rootPath != null ? toVirtualFile(rootPath) : null;
if (root == null) {
return sampleDataDirectory;
}
createDirectoryIfMissing(root, sampleDataDirectory.getPortablePath());
// We want to make sure that the sample data directory is associated with this resource module
// instead of just being lumped into the workspace module because it sits outside the res
// folder.
ModuleRootModificationUtil.addContentRoot(module, sampleDataDirectory.getPortablePath());
return sampleDataDirectory;
}
use of com.android.ide.common.util.PathString 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);
}
use of com.android.ide.common.util.PathString in project intellij by bazelbuild.
the class BlazeSampleDataDirectoryProviderTest method getOrCreateSampleDataDirectory_doesNothingIfNotResourceModule.
@Test
public void getOrCreateSampleDataDirectory_doesNothingIfNotResourceModule() throws IOException {
BlazeSampleDataDirectoryProvider provider = new BlazeSampleDataDirectoryProvider(workspaceModule);
PathString sampleDataDirPath = WriteAction.computeAndWait(() -> provider.getOrCreateSampleDataDirectory());
assertThat(sampleDataDirPath).isNull();
assertThat(workspaceDir.getParent().findChild(FD_SAMPLE_DATA)).isNull();
}
use of com.android.ide.common.util.PathString in project intellij by bazelbuild.
the class BlazeSampleDataDirectoryProviderTest method getOrCreateSampleDataDirectory_createsDirectoryParallelToResFolderIfMissing.
@Test
public void getOrCreateSampleDataDirectory_createsDirectoryParallelToResFolderIfMissing() throws IOException {
BlazeSampleDataDirectoryProvider provider = new BlazeSampleDataDirectoryProvider(resModule);
PathString sampleDataDirPath = WriteAction.computeAndWait(() -> provider.getOrCreateSampleDataDirectory());
VirtualFile sampleDataDir = sampleDataDirPath != null ? toVirtualFile(sampleDataDirPath) : null;
assertThat(sampleDataDir).isNotNull();
assertThat(sampleDataDir.getParent()).isEqualTo(resDir.getParent());
assertThat(sampleDataDir.exists()).isTrue();
}
use of com.android.ide.common.util.PathString in project intellij by bazelbuild.
the class BlazeSampleDataDirectoryProviderTest method getSampleDataDirectory_parallelToResFolder.
@Test
public void getSampleDataDirectory_parallelToResFolder() {
BlazeSampleDataDirectoryProvider provider = new BlazeSampleDataDirectoryProvider(resModule);
PathString expectedPath = toPathString(resDir).getParentOrRoot().resolve(FD_SAMPLE_DATA);
assertThat(provider.getSampleDataDirectory()).isEqualTo(expectedPath);
}
Aggregations