use of com.android.tools.idea.gradle.project.sync.setup.module.dependency.LibraryDependency in project android by JetBrains.
the class DependenciesModuleSetupStep method updateModuleDependency.
private void updateModuleDependency(@NotNull Module module, @NotNull IdeModifiableModelsProvider modelsProvider, @NotNull ModuleDependency dependency, @NotNull AndroidProject androidProject) {
Module moduleDependency = dependency.getModule(modelsProvider);
LibraryDependency compiledArtifact = dependency.getBackupDependency();
if (moduleDependency != null) {
ModuleOrderEntry orderEntry = modelsProvider.getModifiableRootModel(module).addModuleOrderEntry(moduleDependency);
orderEntry.setScope(dependency.getScope());
orderEntry.setExported(true);
if (compiledArtifact != null) {
setModuleCompiledArtifact(moduleDependency, compiledArtifact);
}
return;
}
DependencySetupErrors dependencySetupErrors = DependencySetupErrors.getInstance(module.getProject());
String backupName = compiledArtifact != null ? compiledArtifact.getName() : null;
dependencySetupErrors.addMissingModule(dependency.getGradlePath(), module.getName(), backupName);
// fall back to library dependency, if available.
if (compiledArtifact != null) {
updateLibraryDependency(module, modelsProvider, compiledArtifact, androidProject);
}
}
use of com.android.tools.idea.gradle.project.sync.setup.module.dependency.LibraryDependency in project android by JetBrains.
the class DependenciesModuleSetupStepTest method createFakeLibraryDependency.
@NotNull
private static LibraryDependency createFakeLibraryDependency(@NotNull File jarsFolderPath) {
LibraryDependency dependency = new LibraryDependency(new File(jarsFolderPath, "myLibrary.jar"), COMPILE);
dependency.addPath(DOCUMENTATION, new File(jarsFolderPath, "myLibrary-javadoc.jar"));
return dependency;
}
use of com.android.tools.idea.gradle.project.sync.setup.module.dependency.LibraryDependency in project android by JetBrains.
the class DependenciesModuleSetupStep method doSetUpModule.
@Override
protected void doSetUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull AndroidModuleModel androidModel, @Nullable SyncAction.ModuleModels gradleModels, @Nullable ProgressIndicator indicator) {
AndroidProject androidProject = androidModel.getAndroidProject();
DependencySet dependencies = myDependenciesExtractor.extractFrom(androidModel);
for (LibraryDependency dependency : dependencies.onLibraries()) {
updateLibraryDependency(module, ideModelsProvider, dependency, androidProject);
}
for (ModuleDependency dependency : dependencies.onModules()) {
updateModuleDependency(module, ideModelsProvider, dependency, androidProject);
}
addExtraSdkLibrariesAsDependencies(module, ideModelsProvider, androidProject);
Collection<SyncIssue> syncIssues = androidModel.getSyncIssues();
if (syncIssues != null) {
SyncIssuesReporter.getInstance().report(syncIssues, module);
} else {
//noinspection deprecation
Collection<String> unresolvedDependencies = androidProject.getUnresolvedDependencies();
UnresolvedDependenciesReporter.getInstance().report(unresolvedDependencies, module);
}
}
use of com.android.tools.idea.gradle.project.sync.setup.module.dependency.LibraryDependency in project android by JetBrains.
the class DependenciesModuleSetupStepTest method testUpdateLibraryDependencyWithLibraryInModule.
public void testUpdateLibraryDependencyWithLibraryInModule() throws IOException {
Module module = getModule();
createContentRoot(module);
VirtualFile moduleFolder = getModuleFolder(module);
// Create "build" folder inside the module.
String name = "build";
VirtualFile buildFolder = createFolder(moduleFolder, name);
AndroidProject androidProject = mock(AndroidProject.class);
when(androidProject.getBuildFolder()).thenReturn(virtualToIoFile(buildFolder));
// Create "jars" folder inside the module's "build" folder.
VirtualFile jarsFolder = createFolder(buildFolder, "jars");
File jarsFolderPath = virtualToIoFile(jarsFolder);
// We simulate the dependency to set up being inside the "jars" folder. We expect the "jars" folder to be excluded to avoid unnecessary
// indexing of the jar files.
LibraryDependency dependency = createFakeLibraryDependency(jarsFolderPath);
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(getProject());
mySetupStep.updateLibraryDependency(module, modelsProvider, dependency, androidProject);
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
// Make sure DependenciesSetup#setUpLibraryDependency was invoked.
verify(myDependenciesSetup).setUpLibraryDependency(module, modelsProvider, "myLibrary", COMPILE, dependency.getArtifactPath(), dependency.getPaths(BINARY), dependency.getPaths(DOCUMENTATION));
}
Aggregations