mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-113581 Gradle: New Project Wizard: it could be possible to enable "Use default gradle wrapper" option
This commit is contained in:
+18
-16
@@ -18,6 +18,7 @@ package com.intellij.openapi.externalSystem.service.project.wizard;
|
||||
import com.intellij.ide.fileTemplates.FileTemplate;
|
||||
import com.intellij.ide.fileTemplates.FileTemplateManager;
|
||||
import com.intellij.ide.util.projectWizard.ModuleBuilder;
|
||||
import com.intellij.ide.util.projectWizard.ModuleBuilderListener;
|
||||
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
|
||||
import com.intellij.ide.util.projectWizard.WizardContext;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -56,14 +57,11 @@ public abstract class AbstractExternalModuleBuilder<S extends ExternalProjectSet
|
||||
@NotNull private final ProjectSystemId myExternalSystemId;
|
||||
|
||||
@Nullable private final AbstractExternalProjectSettingsControl<S> myExternalProjectSettingsControl;
|
||||
@Nullable private final String myTemplateConfigName;
|
||||
|
||||
protected AbstractExternalModuleBuilder(@NotNull ProjectSystemId externalSystemId,
|
||||
@Nullable AbstractExternalProjectSettingsControl<S> externalProjectSettingsControl,
|
||||
@Nullable String templateConfigName)
|
||||
@Nullable AbstractExternalProjectSettingsControl<S> externalProjectSettingsControl)
|
||||
{
|
||||
myExternalSystemId = externalSystemId;
|
||||
myTemplateConfigName = templateConfigName;
|
||||
myExternalProjectSettingsControl = externalProjectSettingsControl;
|
||||
Icon icon = ExternalSystemUiUtil.getUiAware(externalSystemId).getProjectIcon();
|
||||
myIcon = icon == null ? super.getNodeIcon() : icon;
|
||||
@@ -95,7 +93,7 @@ public abstract class AbstractExternalModuleBuilder<S extends ExternalProjectSet
|
||||
String contentPath = getContentEntryPath();
|
||||
if (myExternalProjectSettingsControl != null && contentPath != null) {
|
||||
myExternalProjectSettingsControl.getInitialSettings().setExternalProjectPath(contentPath);
|
||||
myExternalProjectSettingsControl.reset();
|
||||
myExternalProjectSettingsControl.reset(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,11 +121,21 @@ public abstract class AbstractExternalModuleBuilder<S extends ExternalProjectSet
|
||||
model.addContentEntry(vContentRootDir);
|
||||
model.inheritSdk();
|
||||
|
||||
AbstractExternalSystemSettings settings = ExternalSystemApiUtil.getSettings(model.getProject(), myExternalSystemId);
|
||||
S externalProjectSettings = createSettings();
|
||||
if (myExternalProjectSettingsControl != null) {
|
||||
String errorMessage = myExternalProjectSettingsControl.apply(externalProjectSettings);
|
||||
myExternalProjectSettingsControl.disposeUIResources();
|
||||
if (errorMessage != null) {
|
||||
throw new ConfigurationException(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
VirtualFile configFile = getExternalProjectConfigFile(vContentRootDir);
|
||||
if (configFile != null && myTemplateConfigName != null) {
|
||||
final String templateConfigName = getTemplateConfigName(externalProjectSettings);
|
||||
if (configFile != null && templateConfigName != null) {
|
||||
FileTemplateManager manager = FileTemplateManager.getInstance();
|
||||
FileTemplate template = manager.getInternalTemplate(myTemplateConfigName);
|
||||
FileTemplate template = manager.getInternalTemplate(templateConfigName);
|
||||
try {
|
||||
VfsUtil.saveText(configFile, template.getText());
|
||||
}
|
||||
@@ -140,15 +148,6 @@ public abstract class AbstractExternalModuleBuilder<S extends ExternalProjectSet
|
||||
}
|
||||
}
|
||||
|
||||
AbstractExternalSystemSettings settings = ExternalSystemApiUtil.getSettings(model.getProject(), myExternalSystemId);
|
||||
S externalProjectSettings = createSettings();
|
||||
if (myExternalProjectSettingsControl != null) {
|
||||
String errorMessage = myExternalProjectSettingsControl.apply(externalProjectSettings);
|
||||
myExternalProjectSettingsControl.disposeUIResources();
|
||||
if (errorMessage != null) {
|
||||
throw new ConfigurationException(errorMessage);
|
||||
}
|
||||
}
|
||||
//noinspection unchecked
|
||||
settings.linkProject(externalProjectSettings);
|
||||
}
|
||||
@@ -165,4 +164,7 @@ public abstract class AbstractExternalModuleBuilder<S extends ExternalProjectSet
|
||||
*/
|
||||
@Nullable
|
||||
protected abstract VirtualFile getExternalProjectConfigFile(@NotNull VirtualFile contentRootDir);
|
||||
|
||||
@Nullable
|
||||
protected abstract String getTemplateConfigName(@NotNull S settings);
|
||||
}
|
||||
|
||||
+7
-3
@@ -64,11 +64,15 @@ public abstract class AbstractExternalProjectSettingsControl<S extends ExternalP
|
||||
protected abstract boolean isExtraSettingModified();
|
||||
|
||||
public void reset() {
|
||||
myUseAutoImportBox.setSelected(getInitialSettings().isUseAutoImport());
|
||||
resetExtraSettings();
|
||||
reset(false);
|
||||
}
|
||||
|
||||
protected abstract void resetExtraSettings();
|
||||
public void reset(boolean isDefaultModuleCreation) {
|
||||
myUseAutoImportBox.setSelected(getInitialSettings().isUseAutoImport());
|
||||
resetExtraSettings(isDefaultModuleCreation);
|
||||
}
|
||||
|
||||
protected abstract void resetExtraSettings(boolean isDefaultModuleCreation);
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
|
||||
+15
-2
@@ -164,6 +164,19 @@ public class ExternalSystemUtil {
|
||||
* @param force flag which defines if external project refresh should be performed if it's config is up-to-date
|
||||
*/
|
||||
public static void refreshProjects(@NotNull final Project project, @NotNull final ProjectSystemId externalSystemId, boolean force) {
|
||||
refreshProjects(project, externalSystemId, force, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks to refresh all external projects of the target external system linked to the given ide project.
|
||||
* <p/>
|
||||
* 'Refresh' here means 'obtain the most up-to-date version and apply it to the ide'.
|
||||
*
|
||||
* @param project target ide project
|
||||
* @param externalSystemId target external system which projects should be refreshed
|
||||
* @param force flag which defines if external project refresh should be performed if it's config is up-to-date
|
||||
*/
|
||||
public static void refreshProjects(@NotNull final Project project, @NotNull final ProjectSystemId externalSystemId, boolean force, boolean modal) {
|
||||
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
|
||||
if (manager == null) {
|
||||
return;
|
||||
@@ -175,7 +188,7 @@ public class ExternalSystemUtil {
|
||||
}
|
||||
|
||||
final ProjectDataManager projectDataManager = ServiceManager.getService(ProjectDataManager.class);
|
||||
final int[] counter = new int[1];
|
||||
final int[] counter = new int[1];
|
||||
|
||||
ExternalProjectRefreshCallback callback = new ExternalProjectRefreshCallback() {
|
||||
|
||||
@@ -244,7 +257,7 @@ public class ExternalSystemUtil {
|
||||
if (!toRefresh.isEmpty()) {
|
||||
counter[0] = toRefresh.size();
|
||||
for (String path : toRefresh) {
|
||||
refreshProject(project, externalSystemId, path, callback, true, false);
|
||||
refreshProject(project, externalSystemId, path, callback, true, modal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
apply plugin: 'java'
|
||||
|
||||
sourceCompatibility = 1.5
|
||||
version = '1.0'
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = '1.8-rc-1'
|
||||
distributionUrl = 'http://services.gradle.org/distributions/gradle-1.8-rc-1-all.zip'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile group: 'junit', name: 'junit', version: '4.11'
|
||||
}
|
||||
@@ -19,18 +19,23 @@ import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.configurations.SimpleJavaParameters;
|
||||
import com.intellij.externalSystem.JavaProjectData;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemAutoImportAware;
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemConfigurableAware;
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemManager;
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemUiAware;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo;
|
||||
import com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo;
|
||||
import com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo;
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData;
|
||||
import com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback;
|
||||
import com.intellij.openapi.externalSystem.service.project.ExternalSystemProjectResolver;
|
||||
import com.intellij.openapi.externalSystem.service.project.autoimport.CachingExternalSystemAutoImportAware;
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager;
|
||||
import com.intellij.openapi.externalSystem.service.ui.DefaultExternalSystemUiAware;
|
||||
import com.intellij.openapi.externalSystem.task.ExternalSystemTaskManager;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
@@ -42,6 +47,7 @@ import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.module.StdModuleTypes;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
|
||||
import com.intellij.openapi.startup.StartupActivity;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -84,13 +90,12 @@ import java.util.Map;
|
||||
* @since 4/10/13 1:19 PM
|
||||
*/
|
||||
public class GradleManager
|
||||
implements ExternalSystemConfigurableAware, ExternalSystemUiAware, ExternalSystemAutoImportAware, StartupActivity, ExternalSystemManager<
|
||||
implements ExternalSystemConfigurableAware, ExternalSystemUiAware, ExternalSystemAutoImportAware, StartupActivity, ExternalSystemManager<
|
||||
GradleProjectSettings,
|
||||
GradleSettingsListener,
|
||||
GradleSettings,
|
||||
GradleLocalSettings,
|
||||
GradleExecutionSettings>
|
||||
{
|
||||
GradleExecutionSettings> {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#" + GradleManager.class.getName());
|
||||
|
||||
@@ -173,7 +178,8 @@ implements ExternalSystemConfigurableAware, ExternalSystemUiAware, ExternalSyste
|
||||
GradleUtil.isGradleDefaultWrapperFilesExist(pair.second) ? DistributionType.DEFAULT_WRAPPED : DistributionType.LOCAL;
|
||||
}
|
||||
else {
|
||||
distributionType = projectLevelSettings.getDistributionType() == null ? DistributionType.LOCAL : projectLevelSettings.getDistributionType();
|
||||
distributionType =
|
||||
projectLevelSettings.getDistributionType() == null ? DistributionType.LOCAL : projectLevelSettings.getDistributionType();
|
||||
}
|
||||
|
||||
GradleExecutionSettings result = new GradleExecutionSettings(localGradlePath,
|
||||
@@ -304,6 +310,38 @@ implements ExternalSystemConfigurableAware, ExternalSystemUiAware, ExternalSyste
|
||||
public void onServiceDirectoryPathChange(@Nullable String oldPath, @Nullable String newPath) {
|
||||
ExternalSystemUtil.refreshProjects(project, GradleConstants.SYSTEM_ID, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProjectsLinked(@NotNull Collection<GradleProjectSettings> settings) {
|
||||
final ProjectDataManager projectDataManager = ServiceManager.getService(ProjectDataManager.class);
|
||||
for (GradleProjectSettings gradleProjectSettings : settings) {
|
||||
ExternalSystemUtil.refreshProject(
|
||||
project, GradleConstants.SYSTEM_ID, gradleProjectSettings.getExternalProjectPath(),
|
||||
new ExternalProjectRefreshCallback() {
|
||||
@Override
|
||||
public void onSuccess(@Nullable final DataNode<ProjectData> externalProject) {
|
||||
if (externalProject == null) {
|
||||
return;
|
||||
}
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(true, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
projectDataManager.importData(externalProject.getKey(), Collections.singleton(externalProject), project, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
|
||||
}
|
||||
}, true, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// We used to assume that gradle scripts are always named 'build.gradle' and kept path to that build.gradle file at ide settings.
|
||||
|
||||
+37
-3
@@ -16,8 +16,15 @@
|
||||
package org.jetbrains.plugins.gradle.codeInsight;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData;
|
||||
import com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback;
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
@@ -26,6 +33,7 @@ import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootAdapter;
|
||||
import com.intellij.openapi.roots.ModuleRootEvent;
|
||||
import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
@@ -107,8 +115,34 @@ public class UseDistributionWithSourcesNotificationProvider extends EditorNotifi
|
||||
panel.createActionLabel(GradleBundle.message("gradle.notifications.apply.suggestion"), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateWrapperConfiguration(rootProjectPath);
|
||||
updateDefaultWrapperConfiguration(rootProjectPath);
|
||||
EditorNotifications.getInstance(module.getProject()).updateAllNotifications();
|
||||
final ProjectDataManager projectDataManager = ServiceManager.getService(ProjectDataManager.class);
|
||||
ExternalSystemUtil.refreshProject(
|
||||
module.getProject(), GradleConstants.SYSTEM_ID, settings.getExternalProjectPath(),
|
||||
new ExternalProjectRefreshCallback() {
|
||||
@Override
|
||||
public void onSuccess(@Nullable final DataNode<ProjectData> externalProject) {
|
||||
if (externalProject == null) {
|
||||
return;
|
||||
}
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(true, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ProjectRootManagerEx.getInstanceEx(module.getProject()).mergeRootsChangesDuring(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
projectDataManager.importData(externalProject.getKey(), Collections.singleton(externalProject), module.getProject(), true);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
|
||||
}
|
||||
}, true, true);
|
||||
}
|
||||
});
|
||||
return panel;
|
||||
@@ -122,9 +156,9 @@ public class UseDistributionWithSourcesNotificationProvider extends EditorNotifi
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void updateWrapperConfiguration(@NotNull String linkedProjectPath) {
|
||||
private static void updateDefaultWrapperConfiguration(@NotNull String linkedProjectPath) {
|
||||
try {
|
||||
final VirtualFile wrapperPropertiesFile = GradleUtil.findWrapperPropertiesFile(linkedProjectPath);
|
||||
final VirtualFile wrapperPropertiesFile = GradleUtil.findDefaultWrapperPropertiesFile(linkedProjectPath);
|
||||
if (wrapperPropertiesFile == null) return;
|
||||
final WrapperConfiguration wrapperConfiguration = GradleUtil.getWrapperConfiguration(linkedProjectPath);
|
||||
if (wrapperConfiguration == null) return;
|
||||
|
||||
+18
-8
@@ -37,6 +37,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.settings.DistributionType;
|
||||
import org.jetbrains.plugins.gradle.settings.GradleExecutionSettings;
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants;
|
||||
import org.jetbrains.plugins.gradle.util.GradleUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -181,6 +182,13 @@ public class GradleExecutionHelper {
|
||||
@NotNull String projectPath,
|
||||
@NotNull GradleExecutionSettings settings,
|
||||
@NotNull ExternalSystemTaskNotificationListener listener) {
|
||||
|
||||
if (!settings.getDistributionType().isWrapped()) return;
|
||||
|
||||
if (settings.getDistributionType() == DistributionType.DEFAULT_WRAPPED &&
|
||||
GradleUtil.findDefaultWrapperPropertiesFile(projectPath) != null) {
|
||||
return;
|
||||
}
|
||||
ProjectConnection connection = getConnection(projectPath, settings);
|
||||
try {
|
||||
BuildLauncher launcher = getBuildLauncher(id, connection, settings, listener);
|
||||
@@ -253,15 +261,17 @@ public class GradleExecutionHelper {
|
||||
}
|
||||
break;
|
||||
case WRAPPED:
|
||||
if(settings.getWrapperPropertyFile() != null) {
|
||||
if (settings.getWrapperPropertyFile() != null) {
|
||||
File propertiesFile = new File(settings.getWrapperPropertyFile());
|
||||
Distribution distribution =
|
||||
new DistributionFactoryExt(StartParameter.DEFAULT_GRADLE_USER_HOME).getWrappedDistribution(propertiesFile);
|
||||
try {
|
||||
setField(connector, "distribution", distribution);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ExternalSystemException(e);
|
||||
if (propertiesFile.exists()) {
|
||||
Distribution distribution =
|
||||
new DistributionFactoryExt(StartParameter.DEFAULT_GRADLE_USER_HOME).getWrappedDistribution(propertiesFile);
|
||||
try {
|
||||
setField(connector, "distribution", distribution);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ExternalSystemException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
+1
-3
@@ -62,9 +62,7 @@ public class GradleProjectResolver implements ExternalSystemProjectResolver<Grad
|
||||
throws ExternalSystemException, IllegalArgumentException, IllegalStateException
|
||||
{
|
||||
if (settings != null) {
|
||||
if(settings.getDistributionType() == DistributionType.WRAPPED) {
|
||||
myHelper.ensureInstalledWrapper(id, projectPath, settings, listener);
|
||||
}
|
||||
myHelper.ensureInstalledWrapper(id, projectPath, settings, listener);
|
||||
List<ClassHolder<? extends GradleProjectResolverExtension>> extensionClasses = settings.getResolverExtensions();
|
||||
if (myCachedExtensions == null || !myCachedExtensions.first.equals(extensionClasses)) {
|
||||
List<GradleProjectResolverExtension> extensions = ContainerUtilRt.newArrayList();
|
||||
|
||||
+17
-3
@@ -27,6 +27,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.gradle.service.settings.GradleProjectSettingsControl;
|
||||
import org.jetbrains.plugins.gradle.settings.DistributionType;
|
||||
import org.jetbrains.plugins.gradle.settings.GradleProjectSettings;
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants;
|
||||
|
||||
@@ -39,7 +40,7 @@ import java.io.File;
|
||||
public class GradleModuleBuilder extends AbstractExternalModuleBuilder<GradleProjectSettings> {
|
||||
|
||||
public GradleModuleBuilder() {
|
||||
super(GradleConstants.SYSTEM_ID, new GradleProjectSettingsControl(new GradleProjectSettings()), "Gradle File.gradle");
|
||||
super(GradleConstants.SYSTEM_ID, new GradleProjectSettingsControl(new GradleProjectSettings()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -50,16 +51,29 @@ public class GradleModuleBuilder extends AbstractExternalModuleBuilder<GradlePro
|
||||
return LocalFileSystem.getInstance().refreshAndFindFileByIoFile(gradleScript);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected String getTemplateConfigName(@NotNull GradleProjectSettings settings) {
|
||||
final String templateName;
|
||||
if (settings.getDistributionType() == DistributionType.WRAPPED) {
|
||||
templateName = "Gradle_with_custom_wrapper.gradle";
|
||||
}
|
||||
else {
|
||||
templateName = "Gradle_default.gradle";
|
||||
}
|
||||
return templateName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuitableSdkType(SdkTypeId sdk) {
|
||||
return sdk == JavaSdk.getInstance();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getGroupName() {
|
||||
return JavaModuleType.JAVA_GROUP;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ModuleType getModuleType() {
|
||||
return StdModuleTypes.JAVA;
|
||||
|
||||
+4
-4
@@ -272,13 +272,13 @@ public class GradleProjectSettingsControl extends AbstractExternalProjectSetting
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void resetExtraSettings() {
|
||||
protected void resetExtraSettings(boolean isDefaultModuleCreation) {
|
||||
myGradleHomeModifiedByUser = false;
|
||||
String gradleHome = getInitialSettings().getGradleHome();
|
||||
myGradleHomePathField.setText(gradleHome == null ? "" : gradleHome);
|
||||
myGradleHomePathField.getTextField().setForeground(LocationSettingType.EXPLICIT_CORRECT.getColor());
|
||||
|
||||
updateWrapperControls(getInitialSettings().getExternalProjectPath());
|
||||
updateWrapperControls(getInitialSettings().getExternalProjectPath(), isDefaultModuleCreation);
|
||||
if (!myUseLocalDistributionButton.isSelected()) {
|
||||
myGradleHomePathField.setEnabled(false);
|
||||
return;
|
||||
@@ -300,7 +300,7 @@ public class GradleProjectSettingsControl extends AbstractExternalProjectSetting
|
||||
}
|
||||
}
|
||||
|
||||
public void updateWrapperControls(@Nullable String linkedProjectPath) {
|
||||
public void updateWrapperControls(@Nullable String linkedProjectPath, boolean isDefaultModuleCreation) {
|
||||
if(StringUtil.isEmpty(linkedProjectPath)) {
|
||||
myUseLocalDistributionButton.setSelected(true);
|
||||
myGradleHomePathField.setEnabled(true);
|
||||
@@ -308,7 +308,7 @@ public class GradleProjectSettingsControl extends AbstractExternalProjectSetting
|
||||
}
|
||||
|
||||
final boolean isGradleDefaultWrapperFilesExist = GradleUtil.isGradleDefaultWrapperFilesExist(linkedProjectPath);
|
||||
if (isGradleDefaultWrapperFilesExist) {
|
||||
if (isGradleDefaultWrapperFilesExist || isDefaultModuleCreation) {
|
||||
myUseWrapperButton.setEnabled(true);
|
||||
myUseWrapperButton.setSelected(true);
|
||||
myGradleHomePathField.setEnabled(false);
|
||||
|
||||
+1
-1
@@ -62,6 +62,6 @@ public class ImportFromGradleControl
|
||||
|
||||
@Override
|
||||
protected void onLinkedProjectPathChange(@NotNull String path) {
|
||||
((GradleProjectSettingsControl)getProjectSettingsControl()).updateWrapperControls(path);
|
||||
((GradleProjectSettingsControl)getProjectSettingsControl()).updateWrapperControls(path, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ public class GradleTaskManager implements ExternalSystemTaskManager<GradleExecut
|
||||
@Nullable final String debuggerSetup,
|
||||
@NotNull final ExternalSystemTaskNotificationListener listener) throws ExternalSystemException {
|
||||
|
||||
if(settings != null && settings.getDistributionType() == DistributionType.WRAPPED) {
|
||||
//if(settings != null && settings.getDistributionType() == DistributionType.WRAPPED) {
|
||||
myHelper.ensureInstalledWrapper(id, projectPath, settings, listener);
|
||||
}
|
||||
//}
|
||||
|
||||
Function<ProjectConnection, Void> f = new Function<ProjectConnection, Void>() {
|
||||
@Override
|
||||
|
||||
@@ -45,5 +45,13 @@ public enum DistributionType {
|
||||
/**
|
||||
* Locally installed gradle to be used
|
||||
*/
|
||||
LOCAL
|
||||
LOCAL;
|
||||
|
||||
/**
|
||||
* Check for wrapped mode
|
||||
* @return true in case of DEFAULT_WRAPPED or WRAPPED mode
|
||||
*/
|
||||
public boolean isWrapped() {
|
||||
return this == DEFAULT_WRAPPED || this == WRAPPED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class GradleUtil {
|
||||
*/
|
||||
@Nullable
|
||||
public static WrapperConfiguration getWrapperConfiguration(@Nullable String gradleProjectPath) {
|
||||
final VirtualFile wrapperPropertiesFile = findWrapperPropertiesFile(gradleProjectPath);
|
||||
final VirtualFile wrapperPropertiesFile = findDefaultWrapperPropertiesFile(gradleProjectPath);
|
||||
if (wrapperPropertiesFile == null) return null;
|
||||
|
||||
final WrapperConfiguration wrapperConfiguration = new WrapperConfiguration();
|
||||
@@ -190,7 +190,7 @@ public class GradleUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VirtualFile findWrapperPropertiesFile(@Nullable String gradleProjectPath) {
|
||||
public static VirtualFile findDefaultWrapperPropertiesFile(@Nullable String gradleProjectPath) {
|
||||
if (gradleProjectPath == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user