use of com.android.tools.idea.gradle.project.facet.ndk.NdkFacet 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.facet.ndk.NdkFacet in project android by JetBrains.
the class NdkModuleNode method getChildren.
@NotNull
@Override
public Collection<AbstractTreeNode> getChildren() {
Module module = getValue();
if (module == null) {
return ImmutableList.of();
}
NdkFacet facet = NdkFacet.getInstance(module);
if (facet == null || facet.getNdkModuleModel() == null) {
return ImmutableList.of();
}
return getNativeSourceNodes(myProject, facet.getNdkModuleModel(), getSettings());
}
use of com.android.tools.idea.gradle.project.facet.ndk.NdkFacet in project android by JetBrains.
the class NdkFacetModuleSetupStep method doSetUpModule.
@Override
protected void doSetUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull NdkModuleModel ndkModuleModel, @Nullable SyncAction.ModuleModels gradleModels, @Nullable ProgressIndicator indicator) {
NdkFacet facet = findFacet(module, ideModelsProvider, NdkFacet.getFacetTypeId());
if (facet != null) {
configureFacet(facet, ndkModuleModel);
} else {
// Module does not have Native Android facet. Create one and add it.
ModifiableFacetModel model = ideModelsProvider.getModifiableFacetModel(module);
NdkFacetType facetType = NdkFacet.getFacetType();
facet = facetType.createFacet(module, NdkFacet.getFacetName(), facetType.createDefaultConfiguration(), null);
model.addFacet(facet);
configureFacet(facet, ndkModuleModel);
}
}
use of com.android.tools.idea.gradle.project.facet.ndk.NdkFacet in project android by JetBrains.
the class BuildVariantUpdater method updateSelectedVariant.
/**
* Updates a module's structure when the user selects a build variant from the tool window.
*
* @param project the module's project.
* @param moduleName the module's name.
* @param buildVariantName the name of the selected build variant.
* @return {@code true} if the module update was successful, {@code false} otherwise.
*/
boolean updateSelectedVariant(@NotNull Project project, @NotNull String moduleName, @NotNull String buildVariantName) {
List<AndroidFacet> affectedAndroidFacets = new ArrayList<>();
List<NdkFacet> affectedNdkFacets = new ArrayList<>();
executeProjectChanges(project, () -> {
Module updatedModule = doUpdate(project, moduleName, buildVariantName, affectedAndroidFacets, affectedNdkFacets);
if (updatedModule != null) {
ConflictSet conflicts = findConflicts(project);
conflicts.showSelectionConflicts();
}
PostSyncProjectSetup.Request setupRequest = new PostSyncProjectSetup.Request();
setupRequest.setGenerateSourcesAfterSync(false).setCleanProjectAfterSync(false);
PostSyncProjectSetup.getInstance(project).setUpProject(setupRequest, null);
generateSourcesIfNeeded(affectedAndroidFacets);
});
return !affectedAndroidFacets.isEmpty() || !affectedNdkFacets.isEmpty();
}
use of com.android.tools.idea.gradle.project.facet.ndk.NdkFacet in project android by JetBrains.
the class BuildVariantView method updateContents.
public void updateContents() {
GradleSyncState syncState = GradleSyncState.getInstance(myProject);
if (syncState.isSyncInProgress() && !syncState.isSyncSkipped()) {
projectImportStarted();
return;
}
final List<Object[]> rows = Lists.newArrayList();
final List<BuildVariantItem[]> variantNamesPerRow = Lists.newArrayList();
for (Module module : getGradleModulesWithAndroidProjects()) {
AndroidFacet androidFacet = AndroidFacet.getInstance(module);
NdkFacet ndkFacet = NdkFacet.getInstance(module);
// getGradleModules() returns only relevant modules.
assert androidFacet != null || ndkFacet != null;
String variantName = null;
if (androidFacet != null) {
JpsAndroidModuleProperties facetProperties = androidFacet.getProperties();
variantName = facetProperties.SELECTED_BUILD_VARIANT;
}
BuildVariantItem[] variantNames = getVariantItems(module);
if (variantNames != null) {
if (androidFacet != null) {
AndroidModuleModel androidModel = AndroidModuleModel.get(module);
// AndroidModel may be null when applying a quick fix (e.g. "Fix Gradle version")
if (androidModel != null) {
variantName = androidModel.getSelectedVariant().getName();
}
} else {
// As only the modules backed by either AndroidGradleModel or NativeAndroidGradleModel are shown in the Build Variants View,
// when a module is not backed by AndroidGradleModel, it surely contains a valid NativeAndroidGradleModel.
NdkModuleModel ndkModuleModel = NdkModuleModel.get(module);
if (ndkModuleModel != null) {
variantName = ndkModuleModel.getSelectedVariant().getName();
}
}
variantNamesPerRow.add(variantNames);
}
if (variantName != null) {
Object[] row = { module, variantName };
rows.add(row);
}
}
Runnable setModelTask = () -> getVariantsTable().setModel(rows, variantNamesPerRow);
Application application = ApplicationManager.getApplication();
if (application.isDispatchThread()) {
setModelTask.run();
} else {
application.invokeLater(setModelTask);
}
}
Aggregations