forked from uschi2000/atlasdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
idea.gradle
215 lines (195 loc) · 12.1 KB
/
idea.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
apply plugin: 'java'
apply plugin: 'idea'
assert sourceCompatibility instanceof JavaVersion;
assert targetCompatibility instanceof JavaVersion;
assert sourceCompatibility == targetCompatibility;
project.tasks.withType(JavaCompile) { JavaCompile task ->
// This actually runs javax.tools.JavaCompiler in-process, but we can still pass arguments
// as though it were running the javac executable.
task.options.compilerArgs << "-XDignore.symbol.file";
task.options.compilerArgs << "-Xlint:none";
task.options.compilerArgs << '-encoding' << 'utf-8';
task.options.encoding = 'UTF-8'
}
/**
* This wrapper around groovy's Node class provides just what we need to make all the XML
* manipulations look nice and uniform.
*/
class Xml {
Node node
static Xml from(XmlProvider provider) {
new Xml(node: provider.asNode())
}
Xml get(Map<String, String> attr = [:], tag) {
new Xml(node: node[tag].find { attr - it.attributes() == [:] } ?: node.appendNode(tag, attr))
}
void set(Map<String, String> attr) {
node.attributes().putAll(attr)
}
}
// This is intended to match the value in gradlew and/or gradle.properties
def ideaBuildSizeMb = '2048'
if (project == rootProject) {
idea.workspace {
iws.withXml { XmlProvider provider ->
Xml.from(provider)
.get('component', name: 'CompilerWorkspaceConfiguration')
.get('option', name: 'MAKE_PROJECT_ON_SAVE')
.set(value: 'true')
Xml.from(provider)
.get('component', name: 'CompilerWorkspaceConfiguration')
.get('option', name: 'PARALLEL_COMPILATION')
.set(value: 'true')
Xml.from(provider)
.get('component', name: 'CompilerWorkspaceConfiguration')
.get('option', name: 'COMPILER_PROCESS_HEAP_SIZE')
.set(value: ideaBuildSizeMb)
Xml.from(provider)
.get('component', name: 'PropertiesComponent')
.get('property', name: 'show.inlinked.gradle.project.popup')
.set(value: 'false')
}
}
idea.project {
outputFile = new File(projectDir, 'atlasdb.ipr')
ipr.withXml { XmlProvider provider ->
Xml.from(provider)
.get('component', name: 'CompilerConfiguration')
.get('option', name: 'DEFAULT_COMPILER')
.set(value: 'Javac')
Xml.from(provider)
.get('component', name: 'CompilerConfiguration')
.get('option', name: 'BUILD_PROCESS_HEAP_SIZE')
.set(value: ideaBuildSizeMb)
Xml.from(provider)
.get('component', name: 'ProjectRootManager')
.set('project-jdk-name': sourceCompatibility.toString())
Xml.from(provider)
.get('component', name: 'VcsDirectoryMappings')
.get('mapping')
.set(vcs: 'Git')
Xml.from(provider)
.get('component', name: 'ProjectCodeStyleSettingsManager')
.get('option', name: 'USE_PER_PROJECT_SETTINGS')
.set('value': 'true')
def importsTable = Xml.from(provider)
.get('component', name: 'ProjectCodeStyleSettingsManager')
.get('option', name: 'PER_PROJECT_SETTINGS').get('value')
.get('option', name: 'IMPORT_LAYOUT_TABLE').get('value')
importsTable.node.children().clear()
['true', 'false'].each { static1 ->
['java', 'javax', 'org', 'com', ''].each { name ->
importsTable.node.appendNode('package', [name: name, withSubpackages: 'true', static: static1])
importsTable.node.appendNode('emptyLine')
}
}
Xml.from(provider)
.get('component', name: 'ProjectCodeStyleSettingsManager')
.get('option', name: 'PER_PROJECT_SETTINGS').get('value')
.get('option', name: 'RIGHT_MARGIN')
.set(value: '140')
def checkStyleTable = Xml.from(provider)
.get('component', name: 'ProjectCodeStyleSettingsManager')
.get('option', name: 'PER_PROJECT_SETTINGS').get('value')
.get('codeStyleSettings', language: 'JAVA').get('value')
checkStyleTable.get('option', name: 'RIGHT_MARGIN').set(value: '140')
checkStyleTable.get('option', name: 'ALIGN_MULTILINE_CHAINED_METHODS').set(value: 'true')
checkStyleTable.get('option', name: 'ALIGN_MULTILINE_ASSIGNMENT').set(value: 'true')
checkStyleTable.get('option', name: 'ALIGN_MULTILINE_PARAMETERS_IN_CALLS').set(value: 'true')
checkStyleTable.get('option', name: 'ALIGN_MULTILINE_BINARY_OPERATION').set(value: 'true')
checkStyleTable.get('option', name: 'ALIGN_MULTILINE_TERNARY_OPERATION').set(value: 'true')
checkStyleTable.get('option', name: 'ALIGN_MULTILINE_THROWS_LIST').set(value: 'true')
checkStyleTable.get('option', name: 'ALIGN_MULTILINE_EXTENDS_LIST').set(value: 'true')
checkStyleTable.get('option', name: 'ALIGN_MULTILIGN_RESOURCES').set(value: 'false')
checkStyleTable.get('option', name: 'ALIGN_MULTILINE_PARENTHESIZED_EXPRESSION').set(value: 'true')
checkStyleTable.get('option', name: 'ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION').set(value: 'true')
checkStyleTable.get('option', name: 'ASSERT_STATEMENT_WRAP').set(value: '1')
checkStyleTable.get('option', name: 'CALL_PARAMETERS_WRAP').set(value: '5')
checkStyleTable.get('option', name: 'PREFER_PARAMETERS_WRAP').set(value: 'true')
checkStyleTable.get('option', name: 'METHOD_PARAMETERS_WRAP').set(value: '5')
checkStyleTable.get('option', name: 'RESOURCE_LIST_WRAP').set(value: '5')
checkStyleTable.get('option', name: 'EXTENDS_LIST_WRAP').set(value: '1')
checkStyleTable.get('option', name: 'THROWS_LIST_WRAP').set(value: '1')
checkStyleTable.get('option', name: 'ENUM_CONSTANTS_WRAP').set(value: '5')
checkStyleTable.get('option', name: 'EXTENDS_KEYWORD_WRAP').set(value: '1')
checkStyleTable.get('option', name: 'METHOD_CALL_CHAIN_WRAP').set(value: '5')
checkStyleTable.get('option', name: 'BINARY_OPERATION_WRAP').set(value: '1')
checkStyleTable.get('option', name: 'TERNARY_OPERATION_WRAP').set(value: '5')
checkStyleTable.get('option', name: 'FOR_STATEMENT_WRAP').set(value: '5')
checkStyleTable.get('option', name: 'ARRAY_INITIALIZER_WRAP').set(value: '5')
checkStyleTable.get('option', name: 'ASSIGNMENT_WRAP').set(value: '1')
checkStyleTable.get('option', name: 'WRAP_ON_TYPING').set(value: '1')
checkStyleTable.get('option', name: 'CALL_PARAMETERS_LPAREN_ON_NEXT_LINE').set(value: 'true')
checkStyleTable.get('option', name: 'BINARY_OPERATION_SIGN_ON_NEXT_LINE').set(value: 'true')
checkStyleTable.get('option', name: 'PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE').set(value: 'true')
checkStyleTable.get('option', name: 'IF_BRACE_FORCE').set(value: '3')
checkStyleTable.get('option', name: 'DOWHILE_BRACE_FORCE').set(value: '3')
checkStyleTable.get('option', name: 'WHILE_BRACE_FORCE').set(value: '3')
checkStyleTable.get('option', name: 'FOR_BRACE_FORCE').set(value: '3')
checkStyleTable.get('option', name: 'KEEP_BLANK_LINES_IN_DECLARATIONS').set(value: '1')
checkStyleTable.get('option', name: 'KEEP_BLANK_LINES_IN_CODE').set(value: '1')
checkStyleTable.get('option', name: 'KEEP_BLANK_LINES_BEFORE_RBRACE').set(value: '1')
checkStyleTable.get('option', name: 'KEEP_LINE_BREAKS').set(value: 'false')
checkStyleTable.get('option', name: 'KEEP_FIRST_COLUMN_COMMENT').set(value: 'false')
checkStyleTable.get('option', name: 'SPACE_WITHIN_ARRAY_INITIALIZER_BRACES').set(value: '1')
checkStyleTable.get('option', name: 'SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE').set(value: '1')
checkStyleTable.get('option', name: 'SPACE_WITHIN_ARRAY_INITIALIZER_BRACES').set(value: '1')
checkStyleTable.get('option', name: 'INDENT_CASE_FROM_SWITCH').set(value: 'false')
Xml.from(provider)
.get('component', name: 'ProjectCodeStyleSettingsManager')
.get('option', name: 'PER_PROJECT_SETTINGS').get('value')
.get('option', name: 'CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND')
.set('value': '999')
Xml.from(provider)
.get('component', name: 'ProjectCodeStyleSettingsManager')
.get('option', name: 'PER_PROJECT_SETTINGS').get('value')
.get('option', name: 'NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND')
.set('value': '999')
Xml.from(provider)
.get('component', name: 'ProjectCodeStyleSettingsManager')
.get('option', name: 'PER_PROJECT_SETTINGS').get('value')
.get('option', name: 'PACKAGES_TO_USE_IMPORT_ON_DEMAND')
.get('value').node.children().clear()
def inspectionProjectProfileManager = Xml.from(provider)
.get('component', name: 'InspectionProjectProfileManager')
def inspectionProfile = inspectionProjectProfileManager.get('profile', version: '1.0')
inspectionProfile.get('option', name: 'myName').set(value: 'Project Default')
inspectionProfile.get('inspection_tool', class: 'EnumSwitchStatementWhichMissesCases', enabled: 'true', level: 'ERROR', enabled_by_default: 'false')
.get('scope', name: 'Project Files', level: 'ERROR', enabled: 'true')
.get('option', name: 'ignoreSwitchStatementsWithDefault')
.set(value: 'false')
inspectionProfile.get('inspection_tool', class: 'FinallyBlockCannotCompleteNormally', enabled: 'true', level: 'ERROR', enabled_by_default: 'false')
.get('scope', name: 'Project Files', level: 'ERROR', enabled: 'true')
def missingOverride = inspectionProfile.get('inspection_tool', class: 'MissingOverrideAnnotation', enabled: 'true', level: 'ERROR', enabled_by_default: 'false')
.get('scope', name: 'Project Files', level: 'ERROR', enabled: 'true')
missingOverride.get('option', name: 'ignoreObjectMethods').set(value: 'false')
missingOverride.get('option', name: 'ignoreAnonymousClassMethods').set(value: 'false')
inspectionProfile.get('inspection_tool', class: 'UnusedImport', enabled: 'true', level: 'ERROR', enabled_by_default: 'false')
.get('scope', name: 'Project Files', level: 'ERROR', enabled: 'true')
inspectionProjectProfileManager.get('option', name: 'PROJECT_PROFILE').set(value: 'Project Default')
inspectionProjectProfileManager.get('option', name: 'USE_PROJECT_PROFILE').set(value: 'true')
inspectionProjectProfileManager.get('version').set(value: '1.0')
}
}
}
idea.module {
inheritOutputDirs = false
outputDir = file('ecbuild')
iml.withXml { provider ->
def jdkSpec = Xml.from(provider)
.get('component', name: 'NewModuleRootManager')
.get('orderEntry', type: 'inheritedJdk')
jdkSpec.set('type': 'jdk')
jdkSpec.set('jdkName': "${sourceCompatibility}")
jdkSpec.set('jdkType': 'JavaSDK')
Xml.from(provider)
.get('component', name: 'NewModuleRootManager')
.node.content*.sourceFolder*.@isTestSource = 'false'
Xml.from(provider)
.get('component', name: 'NewModuleRootManager')
.node.orderEntry*.@exported = ''
Xml.from(provider)
.get('component', name: 'NewModuleRootManager')
.node.orderEntry*.@scope = 'COMPILE'
}
}