IDEA-114534 Gradle: cancelation of gradle tasks for "out-of-process" mode

This commit is contained in:
Vladislav.Soroka
2013-10-07 17:16:33 +04:00
parent 4684ba71e0
commit 14cc2d580d
23 changed files with 246 additions and 26 deletions
@@ -37,6 +37,21 @@ public interface ExternalSystemTask {
*/
void execute(@NotNull ExternalSystemTaskNotificationListener... listeners);
/**
* Cancels current task and updates given indicator's {@link ProgressIndicator#setText2(String) status} during that.
*
* @param indicator target progress indicator
* @param listeners callbacks to be notified on task execution update
*/
void cancel(@NotNull ProgressIndicator indicator, @NotNull ExternalSystemTaskNotificationListener... listeners);
/**
* Cancels current task at the calling thread, i.e. the call to this method blocks.
*
* @param listeners callbacks to be notified about the task execution update
*/
void cancel(@NotNull ExternalSystemTaskNotificationListener... listeners);
/**
* Forces current task to refresh {@link #getState() its state}.
*/
@@ -21,5 +21,5 @@ package com.intellij.openapi.externalSystem.model.task;
*/
public enum ExternalSystemTaskState {
NOT_STARTED, IN_PROGRESS, FINISHED, FAILED
NOT_STARTED, IN_PROGRESS, FINISHED, FAILED, CANCELING, CANCELED
}
@@ -1,7 +1,7 @@
package com.intellij.openapi.externalSystem.model.task;
/**
* Enumerates interested types of tasks that may be enqueued to Gradle API.
* Enumerates interested types of tasks that may be enqueued to external systems API.
*
* @author Denis Zhdanov
* @since 11/10/11 9:07 AM
@@ -40,4 +40,8 @@ public interface ExternalSystemTaskManager<S extends ExternalSystemExecutionSett
@Nullable String debuggerSetup,
@NotNull ExternalSystemTaskNotificationListener listener)
throws ExternalSystemException;
void cancelTask(@NotNull ExternalSystemTaskId id,
@NotNull ExternalSystemTaskNotificationListener listener)
throws ExternalSystemException;
}
@@ -187,7 +187,16 @@ public abstract class AbstractExternalSystemFacadeImpl<S extends ExternalSystemE
myProjectResolver.setNotificationListener(listener);
myTaskManager.setNotificationListener(listener);
}
@Override
public void cancelTask(@NotNull ExternalSystemTaskId id) throws RemoteException {
if(id.getType() == ExternalSystemTaskType.RESOLVE_PROJECT) {
myProjectResolver.cancelTask(id);
} else{
myTaskManager.cancelTask(id);
}
}
private static class SwallowingNotificationListener implements ExternalSystemTaskNotificationListener {
@NotNull private final RemoteExternalSystemProgressNotificationManager myManager;
@@ -1,12 +1,12 @@
package com.intellij.openapi.externalSystem.service;
import com.intellij.openapi.externalSystem.service.internal.ExternalSystemTaskAware;
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType;
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemTaskManager;
import com.intellij.openapi.externalSystem.service.internal.ExternalSystemTaskAware;
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProgressNotificationManager;
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver;
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemTaskManager;
import org.jetbrains.annotations.NotNull;
import java.rmi.Remote;
@@ -56,6 +56,10 @@ public interface RemoteExternalSystemFacade<S extends ExternalSystemExecutionSet
return false;
}
@Override
public void cancelTask(@NotNull ExternalSystemTaskId id) throws RemoteException {
}
@NotNull
@Override
public Map<ExternalSystemTaskType, Set<ExternalSystemTaskId>> getTasksInProgress() throws RemoteException {
@@ -18,6 +18,8 @@ package com.intellij.openapi.externalSystem.service;
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
import com.intellij.openapi.externalSystem.service.project.ExternalSystemProjectResolver;
import com.intellij.openapi.externalSystem.task.ExternalSystemTaskManager;
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.util.Alarm;
import org.jetbrains.annotations.NotNull;
@@ -82,6 +84,11 @@ public class RemoteExternalSystemFacadeImpl<S extends ExternalSystemExecutionSet
));
}
// running the code indicates remote communication mode with external system
Registry.get(
System.getProperty(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY) +
ExternalSystemConstants.USE_IN_PROCESS_COMMUNICATION_REGISTRY_KEY_SUFFIX).setValue(false);
RemoteExternalSystemFacadeImpl facade = new RemoteExternalSystemFacadeImpl(resolverClass, buildManagerClass);
facade.init();
start(facade);
@@ -4,7 +4,10 @@ import com.intellij.execution.DefaultExecutionResult;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.ExecutionResult;
import com.intellij.execution.Executor;
import com.intellij.execution.configurations.*;
import com.intellij.execution.configurations.ConfigurationFactory;
import com.intellij.execution.configurations.LocatableConfigurationBase;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.execution.configurations.RunProfileState;
import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.filters.TextConsoleBuilderImpl;
import com.intellij.execution.process.ProcessHandler;
@@ -137,8 +140,6 @@ public class ExternalSystemRunConfiguration extends LocatableConfigurationBase {
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
ExternalSystemUtil.updateRecentTasks(new ExternalTaskExecutionInfo(mySettings.clone(), executor.getId()), myProject);
ConsoleView console = new TextConsoleBuilderImpl(myProject).getConsole();
final MyProcessHandler processHandler = new MyProcessHandler();
console.attachToProcess(processHandler);
final List<ExternalTaskPojo> tasks = ContainerUtilRt.newArrayList();
for (String taskName : mySettings.getTaskNames()) {
tasks.add(new ExternalTaskPojo(taskName, mySettings.getExternalProjectPath(), null));
@@ -156,6 +157,10 @@ public class ExternalSystemRunConfiguration extends LocatableConfigurationBase {
tasks,
mySettings.getVmOptions(),
debuggerSetup);
final MyProcessHandler processHandler = new MyProcessHandler(task);
console.attachToProcess(processHandler);
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@Override
public void run() {
@@ -190,14 +195,37 @@ public class ExternalSystemRunConfiguration extends LocatableConfigurationBase {
return new DefaultExecutionResult(console, processHandler);
}
}
private static class MyProcessHandler extends ProcessHandler {
private final ExternalSystemExecuteTaskTask myTask;
public MyProcessHandler(ExternalSystemExecuteTaskTask task) {
myTask = task;
}
@Override
protected void destroyProcessImpl() {
}
@Override
protected void detachProcessImpl() {
myTask.cancel(new ExternalSystemTaskNotificationListenerAdapter() {
private boolean myResetGreeting = true;
@Override
public void onTaskOutput(@NotNull ExternalSystemTaskId id, @NotNull String text, boolean stdOut) {
if (myResetGreeting) {
notifyTextAvailable("\r", ProcessOutputTypes.SYSTEM);
myResetGreeting = false;
}
notifyTextAvailable(text, stdOut ? ProcessOutputTypes.STDOUT : ProcessOutputTypes.STDERR);
}
@Override
public void onEnd(@NotNull ExternalSystemTaskId id) {
}
});
notifyProcessDetached();
}
@@ -143,6 +143,50 @@ public abstract class AbstractExternalSystemTask implements ExternalSystemTask {
protected abstract void doExecute() throws Exception;
@Override
public void cancel(@NotNull final ProgressIndicator indicator, @NotNull ExternalSystemTaskNotificationListener... listeners) {
indicator.setIndeterminate(true);
ExternalSystemTaskNotificationListenerAdapter adapter = new ExternalSystemTaskNotificationListenerAdapter() {
@Override
public void onStatusChange(@NotNull ExternalSystemTaskNotificationEvent event) {
indicator.setText(wrapProgressText(event.getDescription()));
}
};
final ExternalSystemTaskNotificationListener[] ls;
if (listeners.length > 0) {
ls = ArrayUtil.append(listeners, adapter);
}
else {
ls = new ExternalSystemTaskNotificationListener[] { adapter };
}
cancel(ls);
}
@Override
public void cancel(@NotNull ExternalSystemTaskNotificationListener... listeners) {
ExternalSystemProgressNotificationManager progressManager = ServiceManager.getService(ExternalSystemProgressNotificationManager.class);
for (ExternalSystemTaskNotificationListener listener : listeners) {
progressManager.addNotificationListener(getId(), listener);
}
try {
doCancel();
}
catch (Throwable e) {
setState(ExternalSystemTaskState.FAILED);
myError.set(e);
LOG.warn(e);
}
finally {
for (ExternalSystemTaskNotificationListener listener : listeners) {
progressManager.removeNotificationListener(listener);
}
}
}
protected abstract void doCancel() throws Exception;
@NotNull
protected String wrapProgressText(@NotNull String text) {
return ExternalSystemBundle.message("progress.update.text", getExternalSystemId(), text);
@@ -106,4 +106,18 @@ public class ExternalSystemExecuteTaskTask extends AbstractExternalSystemTask {
setState(ExternalSystemTaskState.FINISHED);
}
}
@Override
protected void doCancel() throws Exception {
final ExternalSystemFacadeManager manager = ServiceManager.getService(ExternalSystemFacadeManager.class);
RemoteExternalSystemFacade facade = manager.getFacade(getIdeProject(), getExternalProjectPath(), getExternalSystemId());
RemoteExternalSystemTaskManager taskManager = facade.getTaskManager();
setState(ExternalSystemTaskState.CANCELING);
try {
taskManager.cancelTask(getId());
}
finally {
setState(ExternalSystemTaskState.CANCELED);
}
}
}
@@ -62,6 +62,20 @@ public class ExternalSystemResolveProjectTask extends AbstractExternalSystemTask
}
}
protected void doCancel() throws Exception {
final ExternalSystemFacadeManager manager = ServiceManager.getService(ExternalSystemFacadeManager.class);
Project ideProject = getIdeProject();
RemoteExternalSystemProjectResolver resolver = manager.getFacade(ideProject, myProjectPath, getExternalSystemId()).getResolver();
setState(ExternalSystemTaskState.CANCELING);
try {
resolver.cancelTask(getId());
}
finally {
setState(ExternalSystemTaskState.CANCELED);
}
}
@Nullable
public DataNode<ProjectData> getExternalProject() {
return myExternalProject.get();
@@ -26,6 +26,17 @@ public interface ExternalSystemTaskAware {
*/
boolean isTaskInProgress(@NotNull ExternalSystemTaskId id) throws RemoteException;
/**
* Allows to cancel the target task by the current service.
*
*
* @param id target task's id
* @return <code>true</code> if a task was successfully canceled;
* <code>false</code> otherwise
* @throws RemoteException as required by RMI
*/
void cancelTask(@NotNull ExternalSystemTaskId id) throws RemoteException;
/**
* Allows to ask current service for all tasks being executed at the moment.
*
@@ -20,9 +20,9 @@ import com.intellij.openapi.externalSystem.model.ExternalSystemException;
import com.intellij.openapi.externalSystem.model.project.ProjectData;
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType;
import com.intellij.openapi.externalSystem.service.RemoteExternalSystemService;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -64,6 +64,10 @@ public interface RemoteExternalSystemProjectResolver<S extends ExternalSystemExe
return false;
}
@Override
public void cancelTask(@NotNull ExternalSystemTaskId id) throws RemoteException {
}
@NotNull
@Override
public Map<ExternalSystemTaskType, Set<ExternalSystemTaskId>> getTasksInProgress() throws RemoteException {
@@ -42,4 +42,11 @@ public class RemoteExternalSystemProjectResolverImpl<S extends ExternalSystemExe
}
});
}
@Nullable
@Override
public void cancelTask(@NotNull final ExternalSystemTaskId id)
throws ExternalSystemException, IllegalArgumentException, IllegalStateException {
// canceling of the project resolving does not support yet
}
}
@@ -50,6 +50,11 @@ public interface RemoteExternalSystemTaskManager<S extends ExternalSystemExecuti
{
}
@Override
public void cancelTask(@NotNull ExternalSystemTaskId id) throws RemoteException, ExternalSystemException
{
}
@Override
public void setSettings(@NotNull ExternalSystemExecutionSettings settings) throws RemoteException {
}
@@ -76,4 +81,6 @@ public interface RemoteExternalSystemTaskManager<S extends ExternalSystemExecuti
@Nullable S settings,
@Nullable String vmOptions,
@Nullable String debuggerSetup) throws RemoteException, ExternalSystemException;
void cancelTask(@NotNull ExternalSystemTaskId id) throws RemoteException, ExternalSystemException;
}
@@ -15,10 +15,10 @@
*/
package com.intellij.openapi.externalSystem.service.remote;
import com.intellij.openapi.externalSystem.task.ExternalSystemTaskManager;
import com.intellij.openapi.externalSystem.model.ExternalSystemException;
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
import com.intellij.openapi.externalSystem.task.ExternalSystemTaskManager;
import com.intellij.util.Producer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -57,4 +57,10 @@ public class RemoteExternalSystemTaskManagerImpl<S extends ExternalSystemExecuti
}
});
}
@Override
public void cancelTask(@NotNull final ExternalSystemTaskId id) throws RemoteException, ExternalSystemException
{
myDelegate.cancelTask(id, getNotificationListener());
}
}
@@ -1,12 +1,12 @@
package com.intellij.openapi.externalSystem.service.remote.wrapper;
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType;
import com.intellij.openapi.externalSystem.service.RemoteExternalSystemFacade;
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemTaskManager;
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProgressNotificationManager;
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver;
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemTaskManager;
import org.jetbrains.annotations.NotNull;
import java.rmi.RemoteException;
@@ -72,4 +72,9 @@ public class ExternalSystemFacadeWrapper<S extends ExternalSystemExecutionSettin
public Map<ExternalSystemTaskType, Set<ExternalSystemTaskId>> getTasksInProgress() throws RemoteException {
return myDelegate.getTasksInProgress();
}
@Override
public void cancelTask(@NotNull ExternalSystemTaskId id) throws RemoteException {
myDelegate.cancelTask(id);
}
}
@@ -3,11 +3,11 @@ package com.intellij.openapi.externalSystem.service.remote.wrapper;
import com.intellij.openapi.externalSystem.model.DataNode;
import com.intellij.openapi.externalSystem.model.ExternalSystemException;
import com.intellij.openapi.externalSystem.model.project.ProjectData;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProgressNotificationManager;
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -52,4 +52,16 @@ public class ExternalSystemProjectResolverWrapper<S extends ExternalSystemExecut
myProgressManager.onEnd(id);
}
}
@Override
public void cancelTask(@NotNull ExternalSystemTaskId id)
throws ExternalSystemException, IllegalArgumentException, IllegalStateException, RemoteException {
myProgressManager.onQueued(id);
try {
getDelegate().cancelTask(id);
}
finally {
myProgressManager.onEnd(id);
}
}
}
@@ -60,4 +60,17 @@ public class ExternalSystemTaskManagerWrapper<S extends ExternalSystemExecutionS
myProgressManager.onEnd(id);
}
}
@Override
public void cancelTask(@NotNull ExternalSystemTaskId id) throws RemoteException, ExternalSystemException
{
myProgressManager.onQueued(id);
try {
getDelegate().cancelTask(id);
}
finally {
myProgressManager.onEnd(id);
}
}
}
@@ -32,6 +32,7 @@ import com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecution
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.execution.ProgressExecutionMode;
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;
@@ -39,8 +40,8 @@ import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataMan
import com.intellij.openapi.externalSystem.service.ui.DefaultExternalSystemUiAware;
import com.intellij.openapi.externalSystem.task.ExternalSystemTaskManager;
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.externalSystem.service.execution.ProgressExecutionMode;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.module.EmptyModuleType;
import com.intellij.openapi.module.JavaModuleType;
@@ -243,6 +244,9 @@ public class GradleManager
for (GradleProjectResolverExtension extension : RESOLVER_EXTENSIONS.getValue()) {
extension.enhanceRemoteProcessing(parameters);
}
parameters.getVMParametersList().addProperty(
ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY, GradleConstants.SYSTEM_ID.getId());
}
@Override
@@ -159,7 +159,7 @@ public class UseDistributionWithSourcesNotificationProvider extends EditorNotifi
private static void updateDefaultWrapperConfiguration(@NotNull String linkedProjectPath) {
try {
final VirtualFile wrapperPropertiesFile = GradleUtil.findDefaultWrapperPropertiesFile(linkedProjectPath);
final File wrapperPropertiesFile = GradleUtil.findDefaultWrapperPropertiesFile(linkedProjectPath);
if (wrapperPropertiesFile == null) return;
final WrapperConfiguration wrapperConfiguration = GradleUtil.getWrapperConfiguration(linkedProjectPath);
if (wrapperConfiguration == null) return;
@@ -177,7 +177,7 @@ public class UseDistributionWithSourcesNotificationProvider extends EditorNotifi
wrapperProperties.setProperty(WrapperExecutor.ZIP_STORE_BASE_PROPERTY, wrapperConfiguration.getZipBase());
wrapperProperties.setProperty(WrapperExecutor.ZIP_STORE_PATH_PROPERTY, wrapperConfiguration.getZipPath());
GUtil.saveProperties(wrapperProperties, new File(wrapperPropertiesFile.getPath()));
LocalFileSystem.getInstance().refreshFiles(Collections.singletonList(wrapperPropertiesFile));
LocalFileSystem.getInstance().refreshIoFiles(Collections.singletonList(wrapperPropertiesFile));
}
catch (Exception e) {
LOG.error(e);
@@ -17,8 +17,10 @@ package org.jetbrains.plugins.gradle.service.task;
import com.intellij.openapi.externalSystem.model.ExternalSystemException;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationEvent;
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
import com.intellij.openapi.externalSystem.task.ExternalSystemTaskManager;
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ArrayUtil;
@@ -29,8 +31,8 @@ import org.gradle.tooling.ProjectConnection;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper;
import org.jetbrains.plugins.gradle.settings.DistributionType;
import org.jetbrains.plugins.gradle.settings.GradleExecutionSettings;
import org.jetbrains.plugins.gradle.util.GradleConstants;
import java.io.File;
import java.io.IOException;
@@ -85,4 +87,15 @@ public class GradleTaskManager implements ExternalSystemTaskManager<GradleExecut
};
myHelper.execute(projectPath, settings, f);
}
@Override
public void cancelTask(@NotNull ExternalSystemTaskId id, @NotNull ExternalSystemTaskNotificationListener listener)
throws ExternalSystemException {
// TODO replace with cancellation gradle API invocation when it will be ready, see http://issues.gradle.org/browse/GRADLE-1539
if (!ExternalSystemApiUtil.isInProcessMode(GradleConstants.SYSTEM_ID)) {
listener.onStatusChange(new ExternalSystemTaskNotificationEvent(id, "Cancelling the task...\n"));
System.exit(-1);
}
}
}
@@ -9,7 +9,6 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileTypeDescriptor;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.util.containers.Stack;
@@ -70,14 +69,14 @@ public class GradleUtil {
*/
@Nullable
public static WrapperConfiguration getWrapperConfiguration(@Nullable String gradleProjectPath) {
final VirtualFile wrapperPropertiesFile = findDefaultWrapperPropertiesFile(gradleProjectPath);
final File wrapperPropertiesFile = findDefaultWrapperPropertiesFile(gradleProjectPath);
if (wrapperPropertiesFile == null) return null;
final WrapperConfiguration wrapperConfiguration = new WrapperConfiguration();
final Properties props = new Properties();
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(wrapperPropertiesFile.getPath()));
reader = new BufferedReader(new FileReader(wrapperPropertiesFile));
props.load(reader);
String distributionUrl = props.getProperty(WrapperExecutor.DISTRIBUTION_URL_PROPERTY);
if(StringUtil.isEmpty(distributionUrl)) {
@@ -97,7 +96,7 @@ public class GradleUtil {
}
catch (Exception e) {
GradleLog.LOG.warn(
String.format("I/O exception on reading gradle wrapper properties file at '%s'", wrapperPropertiesFile.getPath()), e);
String.format("I/O exception on reading gradle wrapper properties file at '%s'", wrapperPropertiesFile.getAbsolutePath()), e);
}
finally {
if (reader != null) {
@@ -190,7 +189,7 @@ public class GradleUtil {
}
@Nullable
public static VirtualFile findDefaultWrapperPropertiesFile(@Nullable String gradleProjectPath) {
public static File findDefaultWrapperPropertiesFile(@Nullable String gradleProjectPath) {
if (gradleProjectPath == null) {
return null;
}
@@ -232,6 +231,6 @@ public class GradleUtil {
return null;
}
return LocalFileSystem.getInstance().findFileByIoFile(candidates[0]);
return candidates[0];
}
}