use of com.android.tools.idea.gradle.project.model.JavaModuleModel in project android by JetBrains.
the class DataNodeCaches method isCacheMissingModels.
private static boolean isCacheMissingModels(@NotNull DataNode<ModuleData> cache, @NotNull Module module) {
GradleFacet gradleFacet = GradleFacet.getInstance(module);
if (gradleFacet != null) {
DataNode<GradleModuleModel> gradleDataNode = find(cache, GRADLE_MODULE_MODEL);
if (gradleDataNode == null) {
return true;
}
AndroidFacet androidFacet = AndroidFacet.getInstance(module);
if (androidFacet != null) {
DataNode<AndroidModuleModel> androidDataNode = find(cache, ANDROID_MODEL);
if (androidDataNode == null || !isValidProxyObject(androidDataNode.getData().getAndroidProject())) {
return true;
}
} else {
JavaFacet javaFacet = JavaFacet.getInstance(module);
if (javaFacet != null) {
DataNode<JavaModuleModel> javaProjectDataNode = find(cache, JAVA_MODULE_MODEL);
if (javaProjectDataNode == null) {
return true;
}
}
}
}
NdkFacet ndkFacet = NdkFacet.getInstance(module);
if (ndkFacet != null) {
DataNode<NdkModuleModel> ndkModuleModelDataNode = find(cache, NDK_MODEL);
if (ndkModuleModelDataNode == null || !isValidProxyObject(ndkModuleModelDataNode.getData().getAndroidProject())) {
return true;
}
}
return false;
}
use of com.android.tools.idea.gradle.project.model.JavaModuleModel in project android by JetBrains.
the class PsJavaDependencyCollection method addDependencies.
private void addDependencies() {
PsParsedDependencies parsedDependencies = myParent.getParsedDependencies();
JavaModuleModel gradleModel = myParent.getGradleModel();
for (JarLibraryDependency libraryDependency : gradleModel.getJarLibraryDependencies()) {
GradleModuleVersion moduleVersion = libraryDependency.getModuleVersion();
if (moduleVersion != null) {
PsArtifactDependencySpec spec = PsArtifactDependencySpec.create(moduleVersion);
ArtifactDependencyModel parsed = parsedDependencies.findLibraryDependency(moduleVersion);
PsLibraryJavaDependency dependency = new PsLibraryJavaDependency(myParent, spec, libraryDependency, parsed);
myLibraryDependenciesBySpec.put(spec.toString(), dependency);
}
}
}
use of com.android.tools.idea.gradle.project.model.JavaModuleModel in project android by JetBrains.
the class ArtifactsByConfigurationModuleSetupStepTest method testDoSetUpModuleWithCompiledJar.
public void testDoSetUpModuleWithCompiledJar() throws IOException {
Module module = getModule();
String moduleName = module.getName();
File buildFolderPath = createTempDir("build");
File jarFilePath = new File(buildFolderPath, moduleName + ".jar");
createIfDoesntExist(jarFilePath);
Project project = getProject();
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(project);
Map<String, Set<File>> artifactsByConfiguration = new HashMap<>();
artifactsByConfiguration.put("default", Collections.singleton(jarFilePath));
JavaModuleModel model = new JavaModuleModel(moduleName, Collections.emptyList(), Collections.emptyList(), artifactsByConfiguration, null, buildFolderPath, null, true, false);
mySetupStep.doSetUpModule(module, modelsProvider, model, null, null);
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
LibraryTable libraryTable = ProjectLibraryTable.getInstance(project);
Library[] libraries = libraryTable.getLibraries();
assertThat(libraries).isEmpty();
assertAbout(libraryDependencies()).that(module).isEmpty();
// No libraries were created, nothing should be marked as "used".
verify(myLibraryRegistry, never()).markAsUsed(any(), any());
}
use of com.android.tools.idea.gradle.project.model.JavaModuleModel in project android by JetBrains.
the class ProjectSubset method containsSourceFile.
/**
* Checks in the Android and Java models to see if the module contains the given file.
*
* @param moduleInfos represents the module that is not included yet in the IDE.
* @param file the given file.
* @param selected indicates whether the module is included in the project.
* @return the result of the search, or {@code null} if this module does not contain the given file.
*/
@Nullable
private static ModuleSearchResult containsSourceFile(@NotNull DataNode<ModuleData> moduleInfos, @NotNull File file, boolean selected) {
DataNode<AndroidModuleModel> androidProjectNode = find(moduleInfos, ANDROID_MODEL);
if (androidProjectNode != null) {
AndroidModuleModel androidModel = androidProjectNode.getData();
SourceFileContainerInfo result = androidModel.containsSourceFile(file);
if (result != null) {
return new ModuleSearchResult(moduleInfos, result, selected);
}
}
DataNode<JavaModuleModel> javaProjectNode = find(moduleInfos, JAVA_MODULE_MODEL);
if (javaProjectNode != null) {
JavaModuleModel javaModuleModel = javaProjectNode.getData();
if (javaModuleModel.containsSourceFile(file)) {
return new ModuleSearchResult(moduleInfos, null, selected);
}
}
return null;
}
use of com.android.tools.idea.gradle.project.model.JavaModuleModel in project android by JetBrains.
the class ModuleSetup method setUpJavaModule.
private void setUpJavaModule(@NotNull Module module, @NotNull SyncAction.ModuleModels models, @NotNull ProgressIndicator indicator, boolean androidProjectWithoutVariants) {
ModuleExtendedModel javaModel = models.findModel(ModuleExtendedModel.class);
JavaModuleModel javaModuleModel = new JavaModuleModel(models.getModule(), javaModel, androidProjectWithoutVariants);
myJavaModuleSetup.setUpModule(module, myIdeModelsProvider, javaModuleModel, models, indicator);
}
Aggregations