use of com.android.tools.idea.gradle.project.facet.java.JavaFacet in project android by JetBrains.
the class JavaFacetModuleSetupStep method setAndGetJavaGradleFacet.
@NotNull
private static JavaFacet setAndGetJavaGradleFacet(@NotNull Module module, @NotNull IdeModifiableModelsProvider modelsProvider) {
JavaFacet facet = findFacet(module, modelsProvider, JavaFacet.getFacetTypeId());
if (facet != null) {
return facet;
}
FacetManager facetManager = FacetManager.getInstance(module);
ModifiableFacetModel model = modelsProvider.getModifiableFacetModel(module);
facet = facetManager.createFacet(JavaFacet.getFacetType(), JavaFacet.getFacetName(), null);
model.addFacet(facet);
return facet;
}
use of com.android.tools.idea.gradle.project.facet.java.JavaFacet in project android by JetBrains.
the class DependencySetupTest method testWithLocalJarsArModules.
public void testWithLocalJarsArModules() throws Exception {
loadProject(LOCAL_JARS_AS_MODULES);
Module localJarModule = myModules.getModule("localJarAsModule");
// Module should be a Java module, not buildable (since it doesn't have source code).
JavaFacet javaFacet = JavaFacet.getInstance(localJarModule);
assertNotNull(javaFacet);
assertFalse(javaFacet.getConfiguration().BUILDABLE);
assertAbout(libraryDependencies()).that(localJarModule).contains("localJarAsModule.local");
}
use of com.android.tools.idea.gradle.project.facet.java.JavaFacet 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);
}
use of com.android.tools.idea.gradle.project.facet.java.JavaFacet in project android by JetBrains.
the class JavaFacetModuleSetupStepTest method testDoSetUpModuleWithoutGradleFacet.
public void testDoSetUpModuleWithoutGradleFacet() throws IOException {
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);
assertNull(facet.getJavaModuleModel());
}
use of com.android.tools.idea.gradle.project.facet.java.JavaFacet in project android by JetBrains.
the class JavaFacetModuleSetupStepTest method testDoSetUpModuleWithExistingJavaFacet.
public void testDoSetUpModuleWithExistingJavaFacet() throws IOException {
createAndAddGradleFacet(getModule());
JavaFacet facet = createAndAddJavaFacet(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 should be reused.
assertSame(facet, findJavaFacet(module));
verifyFacetConfiguration(facet, javaModel, buildFolderPath, buildable);
}
Aggregations