use of com.android.ide.common.repository.GradleVersion in project android by JetBrains.
the class AndroidModelFeaturesTest method withPluginVersion2_1_0.
@Test
public void withPluginVersion2_1_0() {
GradleVersion version = GradleVersion.parse("2.1.0");
AndroidModelFeatures features = new AndroidModelFeatures(version);
assertTrue(features.isIssueReportingSupported());
assertTrue(features.isShadersSupported());
assertFalse(features.isTestedTargetVariantsSupported());
assertFalse(features.isProductFlavorVersionSuffixSupported());
assertFalse(features.isExternalBuildSupported());
assertFalse(features.isConstraintLayoutSdkLocationSupported());
assertFalse(features.isLayoutRenderingIssuePresent());
}
use of com.android.ide.common.repository.GradleVersion in project android by JetBrains.
the class AndroidModelFeaturesTest method withPluginVersion1_1_0.
@Test
public void withPluginVersion1_1_0() {
GradleVersion version = GradleVersion.parse("1.1.0");
AndroidModelFeatures features = new AndroidModelFeatures(version);
assertTrue(features.isIssueReportingSupported());
assertFalse(features.isShadersSupported());
assertFalse(features.isTestedTargetVariantsSupported());
assertFalse(features.isProductFlavorVersionSuffixSupported());
assertFalse(features.isExternalBuildSupported());
assertFalse(features.isConstraintLayoutSdkLocationSupported());
assertFalse(features.isLayoutRenderingIssuePresent());
}
use of com.android.ide.common.repository.GradleVersion in project android by JetBrains.
the class GradleModuleSetupTest method testSetUpModule.
public void testSetUpModule() {
when(myModuleModels.getModule()).thenReturn(myModuleModel);
when(myModuleModels.findModel(BuildScriptClasspathModel.class)).thenReturn(myClasspathModel);
String gradleVersion = "2.14.1";
when(myClasspathModel.getGradleVersion()).thenReturn(gradleVersion);
myModuleSetup.setUpModule(myModule, myModelsProvider, myModuleModels);
// Apply changes to verify state.
ApplicationManager.getApplication().runWriteAction(() -> myModelsProvider.commit());
GradleFacet facet = findFacet(myModule, myModelsProvider, GradleFacet.getFacetTypeId());
assertNotNull(facet);
GradleModuleModel gradleModuleModel = facet.getGradleModuleModel();
assertNotNull(gradleModuleModel);
assertEquals(":app", gradleModuleModel.getGradlePath());
assertEquals(gradleVersion, gradleModuleModel.getGradleVersion());
File buildFilePath = myModuleModel.getGradleProject().getBuildScript().getSourceFile();
assertAbout(file()).that(gradleModuleModel.getBuildFilePath()).isEquivalentAccordingToCompareTo(buildFilePath);
GradleVersion actualGradleVersion = mySyncSummary.getGradleVersion();
assertNotNull(actualGradleVersion);
assertEquals(gradleVersion, actualGradleVersion.toString());
}
use of com.android.ide.common.repository.GradleVersion in project android by JetBrains.
the class GradleApkProviderTest method GetApksForTestOnlyModule.
public void GetApksForTestOnlyModule() throws Exception {
loadProject(TEST_ONLY_MODULE, "test");
GradleApkProvider provider = new GradleApkProvider(myAndroidFacet, new GradleApplicationIdProvider(myAndroidFacet), true);
Collection<ApkInfo> apks = provider.getApks(mock(IDevice.class));
ApkInfo testApk = apks.stream().filter(a -> a.getApplicationId().equals("com.example.android.app.test")).findFirst().orElse(null);
assertThat(testApk).isNotNull();
GradleVersion modelVersion = getModel().getModelVersion();
if (modelVersion != null) {
if (modelVersion.compareIgnoringQualifiers("2.2.0") < 0) {
// only the test-module apk should be there
assertThat(apks).hasSize(1);
} else {
// both test-module apk and main apk should be there
assertThat(apks).hasSize(2);
ApkInfo mainApk = apks.stream().filter(a -> a.getApplicationId().equals("com.example.android.app")).findFirst().orElse(null);
assertThat(mainApk).isNotNull();
}
}
}
use of com.android.ide.common.repository.GradleVersion in project android by JetBrains.
the class VersionCompatibilityCheckerTest method testCheckAndReportComponentIncompatibilities.
public void testCheckAndReportComponentIncompatibilities() throws Exception {
loadSimpleApplication();
mySyncMessagesStub.clearReportedMessages();
GradleWrapper gradleWrapper = GradleWrapper.find(getProject());
assertNotNull(gradleWrapper);
String gradleVersion = gradleWrapper.getGradleVersion();
assertNotNull(gradleVersion);
Module appModule = myModules.getAppModule();
AndroidModuleModel androidModel = AndroidModuleModel.get(appModule);
assertNotNull(androidModel);
GradleVersion currentModelVersion = androidModel.getModelVersion();
assertNotNull(currentModelVersion);
String failureMessage = "Please use Android Gradle plugin 1.5.0 or newer.";
@Language("XML") String metadata = "<compatibility version='1'>\n" + " <check failureType='error'>\n" + " <component name='gradle' version='[" + gradleVersion + ", +)'>\n" + " <requires name='android-gradle-plugin' version='[100.0.0, +]'>\n" + " <failureMsg>\n" + " <![CDATA[\n" + failureMessage + "\n" + "]]>\n" + " </failureMsg>\n" + " </requires>\n" + " </component>\n" + " </check>\n" + "</compatibility>";
VersionCompatibilityChecker checker = VersionCompatibilityChecker.getInstance();
checker.reloadMetadataForTesting(metadata);
checker.checkAndReportComponentIncompatibilities(getProject());
SyncMessage message = mySyncMessagesStub.getFirstReportedMessage();
String firstLine = String.format("Gradle %1$s requires Android Gradle plugin 100.0.0 (or newer) but project is using version %2$s.", gradleVersion, currentModelVersion);
// @formatter:off
assertAbout(syncMessage()).that(message).hasGroup("Gradle Sync Issues").hasType(ERROR).hasMessageLine(firstLine, 0).hasMessageLine(failureMessage, 1);
// @formatter:on
}
Aggregations