use of org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties in project android by JetBrains.
the class AndroidFacetModuleSetupStep method configureFacet.
private static void configureFacet(@NotNull AndroidFacet facet, @NotNull AndroidModuleModel androidModel) {
JpsAndroidModuleProperties facetProperties = facet.getProperties();
facetProperties.ALLOW_USER_CONFIGURATION = false;
facetProperties.PROJECT_TYPE = androidModel.getProjectType();
File modulePath = androidModel.getRootDirPath();
SourceProvider sourceProvider = androidModel.getDefaultSourceProvider();
facetProperties.MANIFEST_FILE_RELATIVE_PATH = relativePath(modulePath, sourceProvider.getManifestFile());
facetProperties.RES_FOLDER_RELATIVE_PATH = relativePath(modulePath, sourceProvider.getResDirectories());
facetProperties.ASSETS_FOLDER_RELATIVE_PATH = relativePath(modulePath, sourceProvider.getAssetsDirectories());
syncSelectedVariant(facetProperties, androidModel);
facet.setAndroidModel(androidModel);
androidModel.syncSelectedVariantAndTestArtifact(facet);
}
use of org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties in project android by JetBrains.
the class AndroidModuleModel method syncSelectedVariantAndTestArtifact.
public void syncSelectedVariantAndTestArtifact(@NotNull AndroidFacet facet) {
Variant variant = getSelectedVariant();
JpsAndroidModuleProperties state = facet.getProperties();
state.SELECTED_BUILD_VARIANT = variant.getName();
AndroidArtifact mainArtifact = variant.getMainArtifact();
// When multi test artifacts are enabled, test tasks are computed dynamically.
updateGradleTaskNames(state, mainArtifact, null);
}
use of org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties in project android by JetBrains.
the class GradleBuildInvoker method findAndAddGradleBuildTasks.
private static void findAndAddGradleBuildTasks(@NotNull Module module, @NotNull BuildMode buildMode, @NotNull List<String> tasks, @NotNull TestCompileType testCompileType) {
GradleFacet gradleFacet = GradleFacet.getInstance(module);
if (gradleFacet == null) {
return;
}
String gradlePath = gradleFacet.getConfiguration().GRADLE_PROJECT_PATH;
if (isEmpty(gradlePath)) {
// Gradle project path is never, ever null. If the path is empty, it shows as ":". We had reports of this happening. It is likely that
// users manually added the Android-Gradle facet to a project. After all it is likely not to be a Gradle module. Better quit and not
// build the module.
String msg = String.format("Module '%1$s' does not have a Gradle path. It is likely that this module was manually added by the user.", module.getName());
getLogger().info(msg);
return;
}
AndroidFacet androidFacet = AndroidFacet.getInstance(module);
if (androidFacet != null) {
JpsAndroidModuleProperties properties = androidFacet.getProperties();
AndroidModuleModel androidModel = AndroidModuleModel.get(module);
switch(buildMode) {
// Intentional fall-through.
case CLEAN:
case SOURCE_GEN:
addAfterSyncTasks(tasks, gradlePath, properties);
addAfterSyncTasksForTestArtifacts(tasks, gradlePath, testCompileType, androidModel);
break;
case ASSEMBLE:
tasks.add(createBuildTask(gradlePath, properties.ASSEMBLE_TASK_NAME));
// Add assemble tasks for tests.
if (testCompileType != TestCompileType.NONE) {
for (BaseArtifact artifact : getArtifactsForTestCompileType(testCompileType, androidModel)) {
addTaskIfSpecified(tasks, gradlePath, artifact.getAssembleTaskName());
}
}
break;
default:
addAfterSyncTasks(tasks, gradlePath, properties);
addAfterSyncTasksForTestArtifacts(tasks, gradlePath, testCompileType, androidModel);
// no *.class files and would be just a waste of time.
if (testCompileType != TestCompileType.UNIT_TESTS) {
addTaskIfSpecified(tasks, gradlePath, properties.COMPILE_JAVA_TASK_NAME);
}
// Add compile tasks for tests.
for (BaseArtifact artifact : getArtifactsForTestCompileType(testCompileType, androidModel)) {
addTaskIfSpecified(tasks, gradlePath, artifact.getCompileTaskName());
}
break;
}
} else {
JavaFacet javaFacet = JavaFacet.getInstance(module);
if (javaFacet != null && javaFacet.getConfiguration().BUILDABLE) {
String gradleTaskName = javaFacet.getGradleTaskName(buildMode);
if (gradleTaskName != null) {
tasks.add(createBuildTask(gradlePath, gradleTaskName));
}
if (testCompileType == TestCompileType.UNIT_TESTS) {
tasks.add(createBuildTask(gradlePath, JavaFacet.TEST_CLASSES_TASK_NAME));
}
}
}
}
use of org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties in project android by JetBrains.
the class BuildVariantsTest method testSwitchVariantWithFlavor.
@Ignore("failed in http://go/aj/job/studio-ui-test/389 and from IDEA")
@Test
public void testSwitchVariantWithFlavor() throws IOException {
guiTest.importProjectAndWaitForProjectSyncToFinish("Flavoredlib");
BuildVariantsToolWindowFixture buildVariants = guiTest.ideFrame().getBuildVariantsWindow();
buildVariants.selectVariantForModule(MODULE_NAME, "flavor1Release");
String generatedSourceDirPath = MODULE_NAME + "/build/generated/source/";
Collection<String> sourceFolders = guiTest.ideFrame().getSourceFolderRelativePaths(MODULE_NAME, SOURCE);
assertThat(sourceFolders).containsAllOf(generatedSourceDirPath + "r/flavor1/release", generatedSourceDirPath + "aidl/flavor1/release", generatedSourceDirPath + "buildConfig/flavor1/release", generatedSourceDirPath + "rs/flavor1/release", MODULE_NAME + "/src/flavor1Release/aidl", MODULE_NAME + "/src/flavor1Release/java", MODULE_NAME + "/src/flavor1Release/jni", MODULE_NAME + "/src/flavor1Release/rs");
Module appModule = guiTest.ideFrame().getModule(MODULE_NAME);
JpsAndroidModuleProperties androidFacetProperties = AndroidFacet.getInstance(appModule).getProperties();
assertEquals("assembleFlavor1Release", androidFacetProperties.ASSEMBLE_TASK_NAME);
// 'release' variant does not have the _android_test_ artifact.
assertThat(androidFacetProperties.ASSEMBLE_TEST_TASK_NAME).isEmpty();
buildVariants.selectVariantForModule(MODULE_NAME, "flavor1Debug");
sourceFolders = guiTest.ideFrame().getSourceFolderRelativePaths(MODULE_NAME, SOURCE);
assertThat(sourceFolders).containsAllOf(generatedSourceDirPath + "r/flavor1/debug", generatedSourceDirPath + "aidl/flavor1/debug", generatedSourceDirPath + "buildConfig/flavor1/debug", generatedSourceDirPath + "rs/flavor1/debug", MODULE_NAME + "/src/flavor1Debug/aidl", MODULE_NAME + "/src/flavor1Debug/java", MODULE_NAME + "/src/flavor1Debug/jni", MODULE_NAME + "/src/flavor1Debug/rs");
assertEquals("assembleFlavor1Debug", androidFacetProperties.ASSEMBLE_TASK_NAME);
// Verifies that https://code.google.com/p/android/issues/detail?id=83077 is not a bug.
assertEquals("assembleFlavor1DebugAndroidTest", androidFacetProperties.ASSEMBLE_TEST_TASK_NAME);
}
use of org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties in project android by JetBrains.
the class KeystoreUtils method getDebugKeystore.
/**
* Get the debug keystore path.
*
* @return the keystore file.
* @throws Exception if the keystore file could not be obtained.
*/
@NotNull
public static File getDebugKeystore(@NotNull AndroidFacet facet) throws Exception {
File gradleDebugKeystore = getGradleDebugKeystore(facet);
if (gradleDebugKeystore != null) {
return gradleDebugKeystore;
}
JpsAndroidModuleProperties state = facet.getConfiguration().getState();
if (state != null && !Strings.isNullOrEmpty(state.CUSTOM_DEBUG_KEYSTORE_PATH)) {
return new File(state.CUSTOM_DEBUG_KEYSTORE_PATH);
}
return getOrCreateDefaultDebugKeystore();
}
Aggregations