use of com.android.tools.idea.gradle.project.model.JavaModuleModel in project android by JetBrains.
the class AndroidGradleProjectResolver method createJavaProject.
private void createJavaProject(@NotNull IdeaModule gradleModule, @NotNull DataNode<ModuleData> ideModule, boolean androidProjectWithoutVariants) {
//noinspection deprecation
ModuleExtendedModel model = resolverCtx.getExtraProject(gradleModule, ModuleExtendedModel.class);
JavaModuleModel javaModuleModel = new JavaModuleModel(gradleModule, model, androidProjectWithoutVariants);
ideModule.createChild(JAVA_MODULE_MODEL, javaModuleModel);
}
use of com.android.tools.idea.gradle.project.model.JavaModuleModel in project android by JetBrains.
the class JavaModuleModelDataServiceTest method testImportData.
public void testImportData() {
String appModuleName = "app";
Module appModule = createModule(appModuleName);
JavaModuleModel model = mock(JavaModuleModel.class);
when(model.getModuleName()).thenReturn(appModuleName);
DataNode<JavaModuleModel> dataNode = new DataNode<>(JAVA_MODULE_MODEL, model, null);
Collection<DataNode<JavaModuleModel>> dataNodes = Collections.singleton(dataNode);
myDataService.importData(dataNodes, null, getProject(), myModelsProvider);
verify(myModuleSetup).setUpModule(appModule, myModelsProvider, model, null, null);
}
use of com.android.tools.idea.gradle.project.model.JavaModuleModel in project android by JetBrains.
the class ArtifactsByConfigurationModuleSetupStepTest method testDoSetUpModule.
public void testDoSetUpModule() throws IOException {
Module module = getModule();
Project project = getProject();
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(project);
File jarFilePath = createTempFile("fake.jar", "");
Map<String, Set<File>> artifactsByConfiguration = new HashMap<>();
artifactsByConfiguration.put("default", Collections.singleton(jarFilePath));
JavaModuleModel model = new JavaModuleModel(module.getName(), Collections.emptyList(), Collections.emptyList(), artifactsByConfiguration, null, null, null, true, false);
mySetupStep.doSetUpModule(module, modelsProvider, model, null, null);
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
assertJarIsLibrary(jarFilePath);
// This is the first time we create the library, it shouldn't 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 ArtifactsByConfigurationModuleSetupStepTest method testDoSetUpModuleWithExistingLibrary.
public void testDoSetUpModuleWithExistingLibrary() throws IOException {
File jarFilePath = createTempFile("fake.jar", "");
// Create the library, to ensure that is marked as "used".
Library library = createLibrary(jarFilePath);
Project project = getProject();
IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(project);
Map<String, Set<File>> artifactsByConfiguration = new HashMap<>();
artifactsByConfiguration.put("default", Collections.singleton(jarFilePath));
Module module = getModule();
JavaModuleModel model = new JavaModuleModel(module.getName(), Collections.emptyList(), Collections.emptyList(), artifactsByConfiguration, null, null, null, true, false);
mySetupStep.doSetUpModule(module, modelsProvider, model, null, null);
ApplicationManager.getApplication().runWriteAction(modelsProvider::commit);
assertJarIsLibrary(jarFilePath);
// This is an existing library, it should be marked as "used".
verify(myLibraryRegistry, times(1)).markAsUsed(library, jarFilePath);
}
use of com.android.tools.idea.gradle.project.model.JavaModuleModel in project android by JetBrains.
the class JavaFacetModuleSetupStepTest method testDoSetUpModuleWithNewJavaFacet.
public void testDoSetUpModuleWithNewJavaFacet() throws IOException {
createAndAddGradleFacet(getModule());
File buildFolderPath = createTempDir("build", true);
boolean buildable = true;
JavaModuleModel javaModel = mock(JavaModuleModel.class);
when(javaModel.getBuildFolderPath()).thenReturn(buildFolderPath);
when(javaModel.isBuildable()).thenReturn(buildable);
Module module = getModule();
mySetupStep.doSetUpModule(module, myModelsProvider, javaModel, null, null);
ApplicationManager.getApplication().runWriteAction(() -> myModelsProvider.commit());
JavaFacet facet = findJavaFacet(module);
assertNotNull(facet);
verifyFacetConfiguration(facet, javaModel, buildFolderPath, buildable);
}
Aggregations