mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
Gradle: use application level for gradle system setting
related issue: IDEA-128535 Global Gradle Settings aren't global
This commit is contained in:
@@ -106,6 +106,7 @@
|
||||
|
||||
<applicationService serviceImplementation="org.jetbrains.plugins.gradle.service.GradleInstallationManager"/>
|
||||
|
||||
<applicationService serviceImplementation="org.jetbrains.plugins.gradle.settings.GradleSystemSettings"/>
|
||||
<projectService serviceImplementation="org.jetbrains.plugins.gradle.settings.GradleSettings"/>
|
||||
<projectService serviceImplementation="org.jetbrains.plugins.gradle.settings.GradleLocalSettings"/>
|
||||
<projectService serviceImplementation="org.jetbrains.plugins.gradle.service.project.GradleNotification"/>
|
||||
|
||||
@@ -30,26 +30,24 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* Holds shared project-level gradle-related settings (should be kept at the '*.ipr' or under '.idea').
|
||||
*
|
||||
*
|
||||
* @author peter
|
||||
*/
|
||||
@State(
|
||||
name = "GradleSettings",
|
||||
storages = {
|
||||
@Storage(file = StoragePathMacros.PROJECT_FILE),
|
||||
@Storage(file = StoragePathMacros.PROJECT_CONFIG_DIR + "/gradle.xml", scheme = StorageScheme.DIRECTORY_BASED)
|
||||
}
|
||||
name = "GradleSettings",
|
||||
storages = {
|
||||
@Storage(file = StoragePathMacros.PROJECT_FILE),
|
||||
@Storage(file = StoragePathMacros.PROJECT_CONFIG_DIR + "/gradle.xml", scheme = StorageScheme.DIRECTORY_BASED)
|
||||
}
|
||||
)
|
||||
public class GradleSettings extends AbstractExternalSystemSettings<GradleSettings, GradleProjectSettings, GradleSettingsListener>
|
||||
implements PersistentStateComponent<GradleSettings.MyState>
|
||||
{
|
||||
implements PersistentStateComponent<GradleSettings.MyState> {
|
||||
|
||||
@Nullable private String myServiceDirectoryPath;
|
||||
@Nullable private String myGradleVmOptions;
|
||||
private boolean myIsOfflineWork;
|
||||
private final GradleSystemSettings mySystemSettings;
|
||||
|
||||
public GradleSettings(@NotNull Project project) {
|
||||
super(GradleSettingsListener.TOPIC, project);
|
||||
mySystemSettings = GradleSystemSettings.getInstance();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -65,9 +63,6 @@ public class GradleSettings extends AbstractExternalSystemSettings<GradleSetting
|
||||
|
||||
@Override
|
||||
protected void copyExtraSettingsFrom(@NotNull GradleSettings settings) {
|
||||
myServiceDirectoryPath = settings.getServiceDirectoryPath();
|
||||
myGradleVmOptions = settings.getGradleVmOptions();
|
||||
myIsOfflineWork = settings.isOfflineWork();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -76,58 +71,52 @@ public class GradleSettings extends AbstractExternalSystemSettings<GradleSetting
|
||||
public GradleSettings.MyState getState() {
|
||||
MyState state = new MyState();
|
||||
fillState(state);
|
||||
state.serviceDirectoryPath = myServiceDirectoryPath;
|
||||
state.gradleVmOptions = myGradleVmOptions;
|
||||
state.offlineWork = myIsOfflineWork;
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(MyState state) {
|
||||
super.loadState(state);
|
||||
myServiceDirectoryPath = state.serviceDirectoryPath;
|
||||
myGradleVmOptions = state.gradleVmOptions;
|
||||
myIsOfflineWork = state.offlineWork;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return service directory path (if defined). 'Service directory' is a directory which is used internally by gradle during
|
||||
* calls to the tooling api. E.g. it holds downloaded binaries (dependency jars). We allow to define it because there
|
||||
* is a possible situation when a user wants to configure particular directory to be excluded from anti-virus protection
|
||||
* in order to increase performance
|
||||
* calls to the tooling api. E.g. it holds downloaded binaries (dependency jars). We allow to define it because there
|
||||
* is a possible situation when a user wants to configure particular directory to be excluded from anti-virus protection
|
||||
* in order to increase performance
|
||||
*/
|
||||
@Nullable
|
||||
public String getServiceDirectoryPath() {
|
||||
return myServiceDirectoryPath;
|
||||
return mySystemSettings.getServiceDirectoryPath();
|
||||
}
|
||||
|
||||
public void setServiceDirectoryPath(@Nullable String newPath) {
|
||||
String myServiceDirectoryPath = mySystemSettings.getServiceDirectoryPath();
|
||||
if (!Comparing.equal(myServiceDirectoryPath, newPath)) {
|
||||
String oldPath = myServiceDirectoryPath;
|
||||
myServiceDirectoryPath = newPath;
|
||||
getPublisher().onServiceDirectoryPathChange(oldPath, newPath);
|
||||
}
|
||||
mySystemSettings.setServiceDirectoryPath(newPath);
|
||||
getPublisher().onServiceDirectoryPathChange(myServiceDirectoryPath, newPath);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getGradleVmOptions() {
|
||||
return myGradleVmOptions;
|
||||
return mySystemSettings.getGradleVmOptions();
|
||||
}
|
||||
|
||||
|
||||
public void setGradleVmOptions(@Nullable String gradleVmOptions) {
|
||||
String myGradleVmOptions = mySystemSettings.getGradleVmOptions();
|
||||
if (!Comparing.equal(myGradleVmOptions, gradleVmOptions)) {
|
||||
String old = myGradleVmOptions;
|
||||
myGradleVmOptions = gradleVmOptions;
|
||||
getPublisher().onGradleVmOptionsChange(old, gradleVmOptions);
|
||||
mySystemSettings.setGradleVmOptions(gradleVmOptions);
|
||||
getPublisher().onGradleVmOptionsChange(myGradleVmOptions, gradleVmOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOfflineWork() {
|
||||
return myIsOfflineWork;
|
||||
return mySystemSettings.isOfflineWork();
|
||||
}
|
||||
|
||||
public void setOfflineWork(boolean isOfflineWork) {
|
||||
myIsOfflineWork = isOfflineWork;
|
||||
mySystemSettings.setOfflineWork(isOfflineWork);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -143,9 +132,6 @@ public class GradleSettings extends AbstractExternalSystemSettings<GradleSetting
|
||||
public static class MyState implements State<GradleProjectSettings> {
|
||||
|
||||
private Set<GradleProjectSettings> myProjectSettings = ContainerUtilRt.newTreeSet();
|
||||
public String serviceDirectoryPath;
|
||||
public String gradleVmOptions;
|
||||
public boolean offlineWork;
|
||||
|
||||
@AbstractCollection(surroundWithTag = false, elementTypes = {GradleProjectSettings.class})
|
||||
public Set<GradleProjectSettings> getLinkedExternalProjectsSettings() {
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.plugins.gradle.settings;
|
||||
|
||||
import com.intellij.openapi.components.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Vladislav.Soroka
|
||||
* @since 14/8/2014
|
||||
*/
|
||||
@State(
|
||||
name = "GradleSystemSettings",
|
||||
storages = {
|
||||
@Storage(file = StoragePathMacros.APP_CONFIG + "/gradle.settings.xml")
|
||||
}
|
||||
)
|
||||
public class GradleSystemSettings implements PersistentStateComponent<GradleSystemSettings.MyState> {
|
||||
|
||||
@Nullable private String myServiceDirectoryPath;
|
||||
@Nullable private String myGradleVmOptions;
|
||||
private boolean myIsOfflineWork;
|
||||
|
||||
@NotNull
|
||||
public static GradleSystemSettings getInstance() {
|
||||
return ServiceManager.getService(GradleSystemSettings.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
@Override
|
||||
public GradleSystemSettings.MyState getState() {
|
||||
MyState state = new MyState();
|
||||
state.serviceDirectoryPath = myServiceDirectoryPath;
|
||||
state.gradleVmOptions = myGradleVmOptions;
|
||||
state.offlineWork = myIsOfflineWork;
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(MyState state) {
|
||||
myServiceDirectoryPath = state.serviceDirectoryPath;
|
||||
myGradleVmOptions = state.gradleVmOptions;
|
||||
myIsOfflineWork = state.offlineWork;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getServiceDirectoryPath() {
|
||||
return myServiceDirectoryPath;
|
||||
}
|
||||
|
||||
public void setServiceDirectoryPath(@Nullable String newPath) {
|
||||
myServiceDirectoryPath = newPath;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getGradleVmOptions() {
|
||||
return myGradleVmOptions;
|
||||
}
|
||||
|
||||
public void setGradleVmOptions(@Nullable String gradleVmOptions) {
|
||||
myGradleVmOptions = gradleVmOptions;
|
||||
}
|
||||
|
||||
public boolean isOfflineWork() {
|
||||
return myIsOfflineWork;
|
||||
}
|
||||
|
||||
public void setOfflineWork(boolean isOfflineWork) {
|
||||
myIsOfflineWork = isOfflineWork;
|
||||
}
|
||||
|
||||
public static class MyState {
|
||||
public String serviceDirectoryPath;
|
||||
public String gradleVmOptions;
|
||||
public boolean offlineWork;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user