IDEA-83394 Gradle: project refresh does nothing after removing Gradle home from Template Project Settings

1. Using per-project slave gradle process now;
2. Corrected GradleConfigurable balloon processing; (cherry picked from commit 7dd904a)
This commit is contained in:
Denis.Zhdanov
2012-03-26 11:45:22 +04:00
parent 673780a93e
commit 8f887cfec2
10 changed files with 171 additions and 79 deletions
+3 -1
View File
@@ -53,7 +53,6 @@
<!--Generic application services-->
<applicationService serviceImplementation="org.jetbrains.plugins.gradle.remote.GradleApiFacadeManager"/>
<applicationService serviceImplementation="org.jetbrains.plugins.gradle.util.GradleLibraryManager"/>
<applicationService serviceImplementation="org.jetbrains.plugins.gradle.task.GradleTaskManager"/>
<applicationService serviceInterface="org.jetbrains.plugins.gradle.notification.GradleProgressNotificationManager"
serviceImplementation="org.jetbrains.plugins.gradle.notification.GradleProgressNotificationManagerImpl"/>
<applicationService serviceInterface="org.jetbrains.plugins.gradle.config.PlatformFacade"
@@ -101,6 +100,9 @@
<component>
<implementation-class>org.jetbrains.plugins.gradle.notification.GradleConfigNotificationManager</implementation-class>
</component>
<component>
<implementation-class>org.jetbrains.plugins.gradle.task.GradleTaskManager</implementation-class>
</component>
</project-components>
<actions>
@@ -2,7 +2,6 @@ package org.jetbrains.plugins.gradle.action;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
@@ -32,7 +31,7 @@ public class GradleRefreshProjectAction extends AbstractGradleLinkedProjectActio
@Override
protected void doUpdate(@NotNull Presentation presentation, @NotNull Project project, @NotNull String linkedProjectPath) {
boolean enabled = false;
final GradleTaskManager taskManager = ServiceManager.getService(GradleTaskManager.class);
final GradleTaskManager taskManager = project.getComponent(GradleTaskManager.class);
if (taskManager != null) {
enabled = !taskManager.hasTaskOfTypeInProgress(GradleTaskType.RESOLVE_PROJECT);
}
@@ -37,6 +37,8 @@ import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.util.concurrent.TimeUnit;
@@ -117,6 +119,22 @@ public class GradleConfigurable implements SearchableConfigurable, Configurable.
}
}
};
myComponent.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!"ancestor".equals(evt.getPropertyName())) {
return;
}
// Configure the balloon to show on initial configurable drawing.
myShowBalloonIfNecessary = evt.getNewValue() != null && evt.getOldValue() == null;
if (evt.getNewValue() == null && evt.getOldValue() != null) {
// Cancel delayed balloons when the configurable is hidden.
myAlarm.cancelAllRequests();
}
}
});
GridBagConstraints constraints = new GridBagConstraints();
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.weightx = 1;
@@ -151,7 +169,6 @@ public class GradleConfigurable implements SearchableConfigurable, Configurable.
@Override
public boolean isModified() {
myShowBalloonIfNecessary = true;
if (!myPathManuallyModified) {
return false;
}
@@ -169,17 +186,25 @@ public class GradleConfigurable implements SearchableConfigurable, Configurable.
useNormalColorForPath();
String path = myGradleHomeComponent.getPath();
GradleSettings.applyGradleHome(path, myProject);
// There is a possible case that user defines gradle home for particular open project. We want to apply that value
// to the default project as well if it's still non-defined.
Project defaultProject = ProjectManager.getInstance().getDefaultProject();
if (defaultProject == myProject) {
if (isValidGradleHome(path)) {
myGradleHomeSettingType = GradleHomeSettingType.EXPLICIT_CORRECT;
// There is a possible case that user defines gradle home for particular open project. We want to apply that value
// to the default project as well if it's still non-defined.
Project defaultProject = ProjectManager.getInstance().getDefaultProject();
if (defaultProject != myProject && !isValidGradleHome(GradleSettings.getInstance(defaultProject).getGradleHome())) {
GradleSettings.applyGradleHome(path, defaultProject);
}
return;
}
if (isValidGradleHome(path) && !isValidGradleHome(GradleSettings.getInstance(defaultProject).getGradleHome())) {
GradleSettings.applyGradleHome(path, defaultProject);
}
if (StringUtil.isEmpty(path)) {
myGradleHomeSettingType = GradleHomeSettingType.UNKNOWN;
}
else {
myGradleHomeSettingType = GradleHomeSettingType.EXPLICIT_INCORRECT;
new DelayedBalloonInfo(MessageType.ERROR, myGradleHomeSettingType, 0).run();
}
}
private boolean isValidGradleHome(@Nullable String path) {
@@ -203,7 +228,7 @@ public class GradleConfigurable implements SearchableConfigurable, Configurable.
GradleHomeSettingType.EXPLICIT_CORRECT :
GradleHomeSettingType.EXPLICIT_INCORRECT;
if (myGradleHomeSettingType == GradleHomeSettingType.EXPLICIT_INCORRECT) {
new DelayedBalloonInfo(MessageType.ERROR, myGradleHomeSettingType).run();
new DelayedBalloonInfo(MessageType.ERROR, myGradleHomeSettingType, 0).run();
}
else {
myAlarm.cancelAllRequests();
@@ -283,9 +308,13 @@ public class GradleConfigurable implements SearchableConfigurable, Configurable.
private final long myTriggerTime;
DelayedBalloonInfo(@NotNull MessageType messageType, @NotNull GradleHomeSettingType settingType) {
this(messageType, settingType, BALLOON_DELAY_MILLIS);
}
DelayedBalloonInfo(@NotNull MessageType messageType, @NotNull GradleHomeSettingType settingType, long delayMillis) {
myMessageType = messageType;
myText = settingType.getDescription();
myTriggerTime = System.currentTimeMillis() + BALLOON_DELAY_MILLIS;
myTriggerTime = System.currentTimeMillis() + delayMillis;
}
@Override
@@ -296,11 +325,15 @@ public class GradleConfigurable implements SearchableConfigurable, Configurable.
myAlarm.addRequest(this, diff);
return;
}
if (myGradleHomeComponent == null || !myGradleHomeComponent.getPathComponent().isShowing()) {
if (myGradleHomeComponent == null) {
myAlarm.cancelAllRequests();
myAlarm.addRequest(this, 200);
return;
}
if (!myGradleHomeComponent.getPathComponent().isShowing()) {
// Don't schedule the balloon if the configurable is hidden.
return;
}
GradleUtil.showBalloon(myGradleHomeComponent.getPathComponent(), myMessageType, myText);
}
}
@@ -338,7 +338,7 @@ public class GradleModulesImporter {
public void run(@NotNull final ProgressIndicator indicator) {
GradleResolveProjectTask task = new GradleResolveProjectTask(intellijProject, gradleProjectPath, true);
task.execute(indicator);
GradleProject projectWithResolvedLibraries = task.getProject();
GradleProject projectWithResolvedLibraries = task.getGradleProject();
gradleProjectRef.set(projectWithResolvedLibraries);
ApplicationManager.getApplication().invokeLater(setupExternalDependenciesTask, ModalityState.NON_MODAL);
}
@@ -14,11 +14,15 @@ import com.intellij.execution.process.ProcessTerminatedListener;
import com.intellij.execution.rmi.RemoteProcessSupport;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.ide.actions.OpenProjectFileChooserDescriptor;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.projectRoots.*;
import com.intellij.openapi.roots.DependencyScope;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.ShutDownTracker;
import com.intellij.openapi.util.text.StringUtil;
@@ -27,8 +31,10 @@ import com.intellij.psi.PsiBundle;
import com.intellij.util.Alarm;
import com.intellij.util.PathUtil;
import com.intellij.util.SystemProperties;
import com.intellij.util.containers.ConcurrentWeakHashMap;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.gradle.notification.GradleProgressNotificationManager;
import org.jetbrains.plugins.gradle.notification.GradleProgressNotificationManagerImpl;
import org.jetbrains.plugins.gradle.remote.impl.GradleApiFacadeImpl;
@@ -49,8 +55,8 @@ import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
/**
* Entry point to work with remote {@link GradleApiFacade}.
@@ -62,15 +68,19 @@ import java.util.concurrent.atomic.AtomicReference;
*/
public class GradleApiFacadeManager {
private static final Pair<GradleApiFacade, RemoteGradleProcessSettings> NULL_VALUE = Pair.empty();
private static final String REMOTE_PROCESS_TTL_IN_MS_KEY = "gradle.remote.process.ttl.ms";
private static final String MAIN_CLASS_NAME = GradleApiFacadeImpl.class.getName();
private static final int REMOTE_FAIL_RECOVERY_ATTEMPTS_NUMBER = 3;
private final AtomicReference<Pair<GradleApiFacade, RemoteGradleProcessSettings>> myFacade
= new AtomicReference<Pair<GradleApiFacade, RemoteGradleProcessSettings>>();
private final AtomicReference<RemoteGradleProgressNotificationManager> myExportedProgressManager
= new AtomicReference<RemoteGradleProgressNotificationManager>();
private final ConcurrentMap<String /*project name*/, GradleApiFacade> myFacadeWrappers
= new ConcurrentWeakHashMap<String, GradleApiFacade>();
private final ConcurrentMap<String /*project name*/, RemoteGradleProgressNotificationManager> myRemoteNotificationManagers
= new ConcurrentWeakHashMap<String, RemoteGradleProgressNotificationManager>();
private final ConcurrentMap<String /*project name*/, Pair<GradleApiFacade, RemoteGradleProcessSettings>> myRemoteFacades
= new ConcurrentWeakHashMap<String, Pair<GradleApiFacade, RemoteGradleProcessSettings>>();
@NotNull private final GradleLibraryManager myGradleLibraryManager;
@NotNull private final GradleProgressNotificationManagerImpl myProgressManager;
@@ -78,13 +88,12 @@ public class GradleApiFacadeManager {
// Please note that we don't use RemoteGradleProcessSettings as the 'Configuration' type parameter here because we need
// to apply the settings to the newly created process. I.e. every time new process is created we need to call
// 'GradleApiFacade.applySettings()'. So, we need to hold reference to the last returned 'GradleApiFacade' stub anyway.
private final RemoteProcessSupport<Object, GradleApiFacade, Object> mySupport;
private final GradleApiFacade myApiFacade;
private final RemoteProcessSupport<Object, GradleApiFacade, String> mySupport;
public GradleApiFacadeManager(@NotNull GradleLibraryManager gradleLibraryManager, @NotNull GradleProgressNotificationManager manager) {
myGradleLibraryManager = gradleLibraryManager;
myProgressManager = (GradleProgressNotificationManagerImpl)manager;
mySupport = new RemoteProcessSupport<Object, GradleApiFacade, Object>(GradleApiFacade.class) {
mySupport = new RemoteProcessSupport<Object, GradleApiFacade, String>(GradleApiFacade.class) {
@Override
protected void fireModificationCountChanged() {
}
@@ -95,13 +104,10 @@ public class GradleApiFacadeManager {
}
@Override
protected RunProfileState getRunProfileState(Object o, Object configuration, Executor executor) throws ExecutionException {
return createRunProfileState();
protected RunProfileState getRunProfileState(Object o, String configuration, Executor executor) throws ExecutionException {
return createRunProfileState(findProjectByName(configuration));
}
};
myApiFacade = (GradleApiFacade)Proxy.newProxyInstance(
GradleApiFacadeManager.class.getClassLoader(), new Class[]{GradleApiFacade.class}, new MyHandler()
);
ShutDownTracker.getInstance().registerShutdownTask(new Runnable() {
public void run() {
@@ -110,10 +116,21 @@ public class GradleApiFacadeManager {
});
}
private RunProfileState createRunProfileState() {
@NotNull
private static Project findProjectByName(@NotNull String name) {
final ProjectManager projectManager = ProjectManager.getInstance();
for (Project project : projectManager.getOpenProjects()) {
if (name.equals(project.getName())) {
return project;
}
}
return projectManager.getDefaultProject();
}
private RunProfileState createRunProfileState(@Nullable final Project project) {
return new CommandLineState(null) {
private SimpleJavaParameters createJavaParameters() throws ExecutionException {
Collection<File> gradleLibraries = myGradleLibraryManager.getAllLibraries();
Collection<File> gradleLibraries = myGradleLibraryManager.getAllLibraries(project);
GradleLog.LOG.assertTrue(gradleLibraries != null, GradleBundle.message("gradle.generic.text.error.sdk.undefined"));
if (gradleLibraries == null) {
throw new ExecutionException("Can't find gradle libraries");
@@ -193,19 +210,29 @@ public class GradleApiFacadeManager {
* @throws Exception in case of inability to return the facade
*/
@NotNull
public GradleApiFacade getFacade() throws Exception {
return myApiFacade;
public GradleApiFacade getFacade(@Nullable Project project) throws Exception {
if (project == null) {
project = ProjectManager.getInstance().getDefaultProject();
}
final GradleApiFacade facade = myFacadeWrappers.get(project.getName());
if (facade == null) {
final GradleApiFacade newFacade = (GradleApiFacade)Proxy.newProxyInstance(
GradleApiFacadeManager.class.getClassLoader(), new Class[]{GradleApiFacade.class}, new MyHandler(project)
);
myFacadeWrappers.putIfAbsent(project.getName(), newFacade);
}
return myFacadeWrappers.get(project.getName());
}
public Object doInvoke(Method method, Object[] args, int invocationNumber) throws Throwable {
GradleApiFacade facade = doGetFacade();
public Object doInvoke(@NotNull Project project, Method method, Object[] args, int invocationNumber) throws Throwable {
GradleApiFacade facade = doGetFacade(project);
try {
return method.invoke(facade, args);
}
catch (InvocationTargetException e) {
if (e.getTargetException() instanceof RemoteException && invocationNumber > 0) {
Thread.sleep(1000);
return doInvoke(method, args, invocationNumber - 1);
return doInvoke(project, method, args, invocationNumber - 1);
}
else {
throw e;
@@ -213,43 +240,57 @@ public class GradleApiFacadeManager {
}
}
@SuppressWarnings("ConstantConditions")
@NotNull
private GradleApiFacade doGetFacade() throws Exception {
if (!GradleUtil.isGradleAvailable()) {
private GradleApiFacade doGetFacade(@NotNull Project project) throws Exception {
if (project.isDisposed() || !GradleUtil.isGradleAvailable(project)) {
return GradleApiFacade.NULL_OBJECT;
}
Pair<GradleApiFacade, RemoteGradleProcessSettings> pair = myFacade.get();
Pair<GradleApiFacade, RemoteGradleProcessSettings> pair = myRemoteFacades.get(project.getName());
if (pair != null) {
if (isValid(pair)) {
if (isValid(pair, project)) {
return pair.first;
}
mySupport.stopAll(true);
myFacade.compareAndSet(pair, null);
myFacadeWrappers.clear();
myRemoteFacades.clear();
final Pair<GradleApiFacade, RemoteGradleProcessSettings> p = myRemoteFacades.putIfAbsent(project.getName(), NULL_VALUE);
if (p != null && p != NULL_VALUE) {
return p.first;
}
}
final GradleApiFacade facade = mySupport.acquire(this, "");
final GradleApiFacade facade = mySupport.acquire(this, project.getName());
if (facade == null) {
throw new IllegalStateException("Can't obtain facade to working with gradle api at the remote process");
throw new IllegalStateException("Can't obtain facade to working with gradle api at the remote process. Project: " + project);
}
Disposer.register(project, new Disposable() {
@Override
public void dispose() {
mySupport.stopAll(true);
myFacadeWrappers.clear();
myRemoteFacades.clear();
}
});
final GradleApiFacade result = new GradleApiFacadeWrapper(facade, myProgressManager);
Pair<GradleApiFacade, RemoteGradleProcessSettings> newPair
= new Pair<GradleApiFacade, RemoteGradleProcessSettings>(result, getRemoteSettings());
if (!myFacade.compareAndSet(null, newPair)) {
GradleLog.LOG.warn("Detected unexpected duplicate tooling api facade instance creation");
return myFacade.get().first;
= new Pair<GradleApiFacade, RemoteGradleProcessSettings>(result, getRemoteSettings(project));
if (myRemoteFacades.putIfAbsent(project.getName(), newPair) != null && !myRemoteFacades.replace(project.getName(), NULL_VALUE, newPair)) {
GradleLog.LOG.warn("Detected unexpected duplicate tooling api facade instance creation. Project: " + project);
return myRemoteFacades.get(project.getName()).first;
}
if (!StringUtil.isEmpty(newPair.second.getJavaHome())) {
GradleLog.LOG.info("Instructing gradle to use java from " + newPair.second.getJavaHome());
}
result.applySettings(newPair.second);
RemoteGradleProgressNotificationManager exported = myExportedProgressManager.get();
RemoteGradleProgressNotificationManager exported = myRemoteNotificationManagers.get(project.getName());
if (exported == null) {
try {
exported = (RemoteGradleProgressNotificationManager)UnicastRemoteObject.exportObject(myProgressManager, 0);
myExportedProgressManager.set(exported);
myRemoteNotificationManagers.putIfAbsent(project.getName(), exported);
}
catch (RemoteException e) {
exported = myExportedProgressManager.get();
exported = myRemoteNotificationManagers.get(project.getName());
}
}
if (exported == null) {
@@ -261,7 +302,11 @@ public class GradleApiFacadeManager {
return result;
}
private boolean isValid(@NotNull Pair<GradleApiFacade, RemoteGradleProcessSettings> pair) {
private boolean isValid(@NotNull Pair<GradleApiFacade, RemoteGradleProcessSettings> pair, @Nullable Project project) {
if (pair == NULL_VALUE) {
return false;
}
// Check remote process is alive.
try {
pair.first.getResolver();
@@ -272,8 +317,8 @@ public class GradleApiFacadeManager {
// Check that significant settings are not changed
RemoteGradleProcessSettings oldSettings = pair.second;
RemoteGradleProcessSettings currentSettings = getRemoteSettings();
RemoteGradleProcessSettings currentSettings = getRemoteSettings(project);
// We restart the slave process because there is a possible case that it was started with the incorrect classpath.
// For example, it could be started with gradle milestone-3 and that means that its classpath doesn't contain BasicIdeaProject.class.
// So, even if the user defines gradle milestone-7 to use, the slave process still is unable to operate because its classpath
@@ -285,8 +330,8 @@ public class GradleApiFacadeManager {
}
@NotNull
private RemoteGradleProcessSettings getRemoteSettings() {
File gradleHome = myGradleLibraryManager.getGradleHome();
private RemoteGradleProcessSettings getRemoteSettings(@Nullable Project project) {
File gradleHome = myGradleLibraryManager.getGradleHome(project);
RemoteGradleProcessSettings result = new RemoteGradleProcessSettings(gradleHome.getAbsolutePath());
String ttlAsString = System.getProperty(REMOTE_PROCESS_TTL_IN_MS_KEY);
if (ttlAsString != null) {
@@ -304,9 +349,16 @@ public class GradleApiFacadeManager {
}
private class MyHandler implements InvocationHandler {
@NotNull private final String myProjectName;
MyHandler(@NotNull Project project) {
myProjectName = project.getName();
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return doInvoke(method, args, REMOTE_FAIL_RECOVERY_ATTEMPTS_NUMBER);
return doInvoke(findProjectByName(myProjectName), method, args, REMOTE_FAIL_RECOVERY_ATTEMPTS_NUMBER);
}
}
}
@@ -3,7 +3,9 @@ package org.jetbrains.plugins.gradle.task;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.gradle.notification.GradleProgressNotificationManager;
import org.jetbrains.plugins.gradle.notification.GradleTaskNotificationEvent;
import org.jetbrains.plugins.gradle.notification.GradleTaskNotificationListener;
@@ -28,9 +30,11 @@ public abstract class AbstractGradleTask implements GradleTask {
private final AtomicReference<GradleTaskState> myState = new AtomicReference<GradleTaskState>(GradleTaskState.NOT_STARTED);
private final AtomicReference<Throwable> myError = new AtomicReference<Throwable>();
private final GradleTaskId myId;
@Nullable transient private final Project myIntellijProject;
@NotNull private final GradleTaskId myId;
protected AbstractGradleTask(@NotNull GradleTaskType type) {
protected AbstractGradleTask(Project project, @NotNull GradleTaskType type) {
myIntellijProject = project;
myId = GradleTaskId.create(type);
}
@@ -53,13 +57,18 @@ public abstract class AbstractGradleTask implements GradleTask {
return myError.get();
}
@Nullable
public Project getIntellijProject() {
return myIntellijProject;
}
public void refreshState() {
if (getState() != GradleTaskState.IN_PROGRESS) {
return;
}
final GradleApiFacadeManager manager = ServiceManager.getService(GradleApiFacadeManager.class);
try {
final GradleApiFacade facade = manager.getFacade();
final GradleApiFacade facade = manager.getFacade(myIntellijProject);
setState(facade.isTaskInProgress(getId()) ? GradleTaskState.IN_PROGRESS : GradleTaskState.FAILED);
}
catch (Throwable e) {
@@ -21,20 +21,19 @@ public class GradleResolveProjectTask extends AbstractGradleTask {
private final AtomicReference<GradleProject> myGradleProject = new AtomicReference<GradleProject>();
private final Project myIntellijProject;
private final String myProjectPath;
private final boolean myResolveLibraries;
public GradleResolveProjectTask(@Nullable Project project, @NotNull String projectPath, boolean resolveLibraries) {
super(GradleTaskType.RESOLVE_PROJECT);
myIntellijProject = project;
super(project, GradleTaskType.RESOLVE_PROJECT);
myProjectPath = projectPath;
myResolveLibraries = resolveLibraries;
}
protected void doExecute() throws Exception {
final GradleApiFacadeManager manager = ServiceManager.getService(GradleApiFacadeManager.class);
GradleProjectResolver resolver = manager.getFacade().getResolver();
GradleProjectResolver resolver = manager.getFacade(getIntellijProject()).getResolver();
setState(GradleTaskState.IN_PROGRESS);
final GradleProject project = resolver.resolveProjectInfo(getId(), myProjectPath, myResolveLibraries);
if (project == null) {
@@ -42,10 +41,11 @@ public class GradleResolveProjectTask extends AbstractGradleTask {
}
myGradleProject.set(project);
setState(GradleTaskState.FINISHED);
if (myIntellijProject == null || myIntellijProject.isDisposed()) {
final Project intellijProject = getIntellijProject();
if (intellijProject == null || intellijProject.isDisposed()) {
return;
}
final GradleProjectStructureChangesModel model = myIntellijProject.getComponent(GradleProjectStructureChangesModel.class);
final GradleProjectStructureChangesModel model = intellijProject.getComponent(GradleProjectStructureChangesModel.class);
if (model != null) {
// This task may be called during the 'import from gradle' processing, hence, no project-level IoC is up.
// Model update is necessary for the correct tool window project structure diff showing but we don't have
@@ -55,7 +55,7 @@ public class GradleResolveProjectTask extends AbstractGradleTask {
}
@Nullable
public GradleProject getProject() {
public GradleProject getGradleProject() {
return myGradleProject.get();
}
}
@@ -1,5 +1,7 @@
package org.jetbrains.plugins.gradle.task;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.project.Project;
import com.intellij.util.Alarm;
import com.intellij.util.containers.ConcurrentHashMap;
import org.jetbrains.annotations.NotNull;
@@ -23,7 +25,7 @@ import java.util.concurrent.TimeUnit;
* @author Denis Zhdanov
* @since 2/8/12 1:52 PM
*/
public class GradleTaskManager implements GradleTaskNotificationListener {
public class GradleTaskManager extends AbstractProjectComponent implements GradleTaskNotificationListener {
/**
* We receive information about the tasks being enqueued to the slave gradle projects here. However, there is a possible
@@ -46,7 +48,11 @@ public class GradleTaskManager implements GradleTaskNotificationListener {
@NotNull private final GradleApiFacadeManager myFacadeManager;
public GradleTaskManager(@NotNull GradleApiFacadeManager facadeManager, @NotNull GradleProgressNotificationManager notificationManager) {
public GradleTaskManager(@NotNull Project project,
@NotNull GradleApiFacadeManager facadeManager,
@NotNull GradleProgressNotificationManager notificationManager)
{
super(project);
myFacadeManager = facadeManager;
notificationManager.addNotificationListener(this);
myAlarm.addRequest(new Runnable() {
@@ -106,7 +112,7 @@ public class GradleTaskManager implements GradleTaskNotificationListener {
public void update() {
try {
final Map<GradleTaskType, Set<GradleTaskId>> currentState = myFacadeManager.getFacade().getTasksInProgress();
final Map<GradleTaskType, Set<GradleTaskId>> currentState = myFacadeManager.getFacade(myProject).getTasksInProgress();
myTasksInProgress.clear();
for (Set<GradleTaskId> ids : currentState.values()) {
for (GradleTaskId id : ids) {
@@ -44,15 +44,6 @@ public class GradleLibraryManager {
GRADLE_ENV_PROPERTY_NAME = System.getProperty("gradle.home.env.key", "GRADLE_HOME");
}
@Nullable
public Collection<File> getAllLibraries() {
final Project[] projects = ProjectManager.getInstance().getOpenProjects();
if (projects.length == 1) {
return getAllLibraries(projects[0]);
}
return getAllLibraries(null);
}
/**
* Allows to get file handles for the gradle binaries to use.
*
@@ -208,7 +208,7 @@ public class GradleUtil {
public void execute(@NotNull ProgressIndicator indicator) {
GradleResolveProjectTask task = new GradleResolveProjectTask(project, gradleProjectPath, resolveLibraries);
task.execute(indicator);
gradleProject.set(task.getProject());
gradleProject.set(task.getGradleProject());
final Throwable error = task.getError();
if (error == null) {
return;