2 * Copyright 2000-2014 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.jetbrains.plugins.groovy.compiler;
19 import com.intellij.openapi.Disposable;
20 import com.intellij.openapi.compiler.options.ExcludedEntriesConfiguration;
21 import com.intellij.openapi.compiler.options.ExcludesConfiguration;
22 import com.intellij.openapi.components.*;
23 import com.intellij.openapi.project.Project;
24 import com.intellij.openapi.util.Disposer;
25 import org.jetbrains.jps.incremental.groovy.JpsGroovySettings;
31 name = "GroovyCompilerProjectConfiguration",
33 @Storage(file = StoragePathMacros.PROJECT_FILE),
34 @Storage(file = StoragePathMacros.PROJECT_CONFIG_DIR + "/groovyc.xml", scheme = StorageScheme.DIRECTORY_BASED)
37 public class GroovyCompilerConfiguration implements PersistentStateComponent<JpsGroovySettings>, Disposable {
38 private String myConfigScript = "";
39 private String myHeapSize = JpsGroovySettings.DEFAULT_HEAP_SIZE;
40 private boolean myInvokeDynamic = JpsGroovySettings.DEFAULT_INVOKE_DYNAMIC;
41 public boolean transformsOk = JpsGroovySettings.DEFAULT_TRANSFORMS_OK;
42 private final ExcludedEntriesConfiguration myExcludeFromStubGeneration = new ExcludedEntriesConfiguration();
45 public JpsGroovySettings getState() {
46 final JpsGroovySettings bean = new JpsGroovySettings();
47 bean.heapSize = myHeapSize;
48 bean.configScript = myConfigScript;
49 bean.invokeDynamic = myInvokeDynamic;
50 bean.transformsOk = transformsOk;
51 myExcludeFromStubGeneration.writeExternal(bean.excludes);
55 public static ExcludesConfiguration getExcludeConfiguration(Project project) {
56 return getInstance(project).myExcludeFromStubGeneration;
59 public ExcludesConfiguration getExcludeFromStubGeneration() {
60 return myExcludeFromStubGeneration;
64 public void loadState(JpsGroovySettings state) {
65 myHeapSize = state.heapSize;
66 myConfigScript = state.configScript;
67 myInvokeDynamic = state.invokeDynamic;
68 transformsOk = state.transformsOk;
70 myExcludeFromStubGeneration.readExternal(state.excludes);
73 public static GroovyCompilerConfiguration getInstance(Project project) {
74 return ServiceManager.getService(project, GroovyCompilerConfiguration.class);
77 public String getHeapSize() {
81 public boolean isInvokeDynamic() {
82 return myInvokeDynamic;
85 public void setHeapSize(String heapSize) {
86 myHeapSize = heapSize;
89 public void setInvokeDynamic(boolean invokeDynamic) {
90 myInvokeDynamic = invokeDynamic;
93 public String getConfigScript() {
94 return myConfigScript;
97 public void setConfigScript(String configScript) {
98 myConfigScript = configScript;
102 public void dispose() {
103 Disposer.dispose(myExcludeFromStubGeneration);