use of com.android.tools.idea.gradle.stubs.android.AndroidLibraryStub in project android by JetBrains.
the class DependenciesExtractorTest method testExtractFromWithLibraryAar.
public void testExtractFromWithLibraryAar() {
String rootDirPath = myAndroidProject.getRootDir().getPath();
File bundle = new File(rootDirPath, "bundle.aar");
File libJar = new File(rootDirPath, FileUtil.join("bundle_aar", "library.jar"));
AndroidLibraryStub library = new AndroidLibraryStub(bundle, libJar);
myVariant.getMainArtifact().getDependencies().addLibrary(library);
myVariant.getInstrumentTestArtifact().getDependencies().addLibrary(library);
Collection<LibraryDependency> dependencies = myDependenciesExtractor.extractFrom(myAndroidModel).onLibraries();
assertEquals(1, dependencies.size());
LibraryDependency dependency = ContainerUtil.getFirstItem(dependencies);
assertNotNull(dependency);
assertEquals("bundle", dependency.getName());
// Make sure that is a "compile" dependency, even if specified as "test".
assertEquals(DependencyScope.COMPILE, dependency.getScope());
File[] binaryPaths = dependency.getPaths(LibraryDependency.PathType.BINARY);
assertThat(binaryPaths).hasLength(2);
assertThat(binaryPaths).asList().contains(libJar);
}
use of com.android.tools.idea.gradle.stubs.android.AndroidLibraryStub in project android by JetBrains.
the class DependenciesExtractorTest method testExtractFromWithLibraryLocalJar.
public void testExtractFromWithLibraryLocalJar() {
String rootDirPath = myAndroidProject.getRootDir().getPath();
File bundle = new File(rootDirPath, "bundle.aar");
File libJar = new File(rootDirPath, FileUtil.join("bundle_aar", "library.jar"));
File resFolder = new File(rootDirPath, FileUtil.join("bundle_aar", "res"));
AndroidLibraryStub library = new AndroidLibraryStub(bundle, libJar);
File localJar = new File(rootDirPath, "local.jar");
library.addLocalJar(localJar);
myVariant.getMainArtifact().getDependencies().addLibrary(library);
myVariant.getInstrumentTestArtifact().getDependencies().addLibrary(library);
List<LibraryDependency> dependencies = Lists.newArrayList(myDependenciesExtractor.extractFrom(myAndroidModel).onLibraries());
assertEquals(1, dependencies.size());
LibraryDependency dependency = dependencies.get(0);
assertNotNull(dependency);
assertEquals("bundle", dependency.getName());
File[] binaryPaths = dependency.getPaths(LibraryDependency.PathType.BINARY);
assertThat(binaryPaths).hasLength(3);
assertThat(binaryPaths).asList().containsAllOf(localJar, libJar, resFolder);
}
use of com.android.tools.idea.gradle.stubs.android.AndroidLibraryStub in project android by JetBrains.
the class DependenciesExtractorTest method testExtractFromWithLibraryProject.
public void testExtractFromWithLibraryProject() {
String rootDirPath = myAndroidProject.getRootDir().getPath();
File bundle = new File(rootDirPath, "bundle.aar");
File libJar = new File(rootDirPath, FileUtil.join("bundle_aar", "library.jar"));
File resFolder = new File(rootDirPath, FileUtil.join("bundle_aar", "res"));
String gradlePath = "abc:xyz:library";
AndroidLibraryStub library = new AndroidLibraryStub(bundle, libJar, gradlePath);
myVariant.getMainArtifact().getDependencies().addLibrary(library);
myVariant.getInstrumentTestArtifact().getDependencies().addLibrary(library);
Collection<ModuleDependency> dependencies = myDependenciesExtractor.extractFrom(myAndroidModel).onModules();
assertEquals(1, dependencies.size());
ModuleDependency dependency = ContainerUtil.getFirstItem(dependencies);
assertNotNull(dependency);
assertEquals(gradlePath, dependency.getGradlePath());
// Make sure that is a "compile" dependency, even if specified as "test".
assertEquals(DependencyScope.COMPILE, dependency.getScope());
LibraryDependency backup = dependency.getBackupDependency();
assertNotNull(backup);
assertEquals("bundle", backup.getName());
assertEquals(DependencyScope.COMPILE, backup.getScope());
File[] backupBinaryPaths = backup.getPaths(LibraryDependency.PathType.BINARY);
assertThat(backupBinaryPaths).hasLength(2);
assertThat(backupBinaryPaths).asList().containsAllOf(libJar, resFolder);
}
use of com.android.tools.idea.gradle.stubs.android.AndroidLibraryStub in project android by JetBrains.
the class ProjectResourceRepositoryTest method addArchiveLibraries.
private void addArchiveLibraries() {
// Add in some Android projects too
// make it a Gradle project
myFacet.getProperties().ALLOW_USER_CONFIGURATION = false;
AndroidProjectStub androidProject = TestProjects.createFlavorsProject();
VariantStub variant = androidProject.getFirstVariant();
assertNotNull(variant);
File rootDir = androidProject.getRootDir();
AndroidModuleModel androidModel = new AndroidModuleModel(androidProject.getName(), rootDir, androidProject, variant.getName());
myFacet.setAndroidModel(androidModel);
File bundle = new File(rootDir, "bundle.aar");
File libJar = new File(rootDir, "bundle_aar" + File.separatorChar + "library.jar");
AndroidLibraryStub library = new AndroidLibraryStub(bundle, libJar);
variant.getMainArtifact().getDependencies().addLibrary(library);
}
Aggregations