File: idea.gradle

package info (click to toggle)
gradle 4.4.1-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 85,104 kB
  • sloc: java: 319,724; xml: 14,356; cpp: 4,200; ansic: 1,025; sh: 300; makefile: 60; asm: 17; jsp: 17; objc: 10
file content (306 lines) | stat: -rw-r--r-- 15,818 bytes parent folder | download | duplicates (2)
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
allprojects {
    apply plugin: "idea"

    idea {
        module {
            // Force everything to Java 6, pending detangling some int test cycles or switching to project-per-source-set mapping
            languageLevel = new org.gradle.plugins.ide.idea.model.IdeaLanguageLevel("1.6")
            targetBytecodeVersion = JavaVersion.VERSION_1_6

            iml {
                whenMerged { module ->
                    module.dependencies.removeAll {
                        it instanceof org.gradle.plugins.ide.idea.model.ModuleLibrary &&
                        it.classes.any {
                            // remove all Gradle build output directories from all scopes
                            it.url.contains('/build/classes/') ||
                            it.url.contains('/build/resources/') ||
                            // remove possible resource directories from all scopes
                            // replaced by java-resource/java-test-resource
                            it.url.contains('$MODULE_DIR$/src/') ||
                            // keep for build/generated-resources/main/*-classpath.properties
                            // required by DefaultModuleRegistry
                            (it.url.contains('$MODULE_DIR$/build/') && !it.url.contains('generated-resources'))
                        }
                    }
                    // remove all build directories from sourceFolders
                    // f.e. buildInit module contains such a sourceFolder
                    module.sourceFolders.removeAll {
                        it.url.contains('$MODULE_DIR$/build/')
                    }
                }
                withXml {
                    def node = it.asNode()
                    def content = node.component.find { it.'@name' == 'NewModuleRootManager' }.content[0]
                    content.sourceFolder.each { sourceFolder ->
                        // make resource directories a java-resource / java-test-resource type in Idea
                        if(sourceFolder.@url?.endsWith('/resources')) {
                            sourceFolder.attributes().with {
                                boolean isTestSource = (remove('isTestSource') == 'true')
                                put('type', isTestSource ? 'java-test-resource' : 'java-resource')
                            }
                        }
                    }
                }
            }
        }
    }
}

idea {
    module {
        excludeDirs += file('intTestHomeDir')
        excludeDirs += file('buildSrc/build')
        excludeDirs += file('buildSrc/.gradle')
    }

    project {
        wildcards += ['?*.gradle']

        vcs = 'Git'
        ipr {
            withXml { provider ->
                def node = provider.asNode()
                def compilerConfig = node.component.find { it.'@name' == 'CompilerConfiguration' }
                def exclude = compilerConfig.excludeFromCompile
                if (exclude) {
                    compilerConfig.remove(exclude)
                }
                exclude = compilerConfig.appendNode('excludeFromCompile')

                // exclude java version specific classes from compilation when not compilable with current java version
                def excludeSource = { version, sourceFolder ->
                    if (sourceFolder.exists()) {
                        sourceFolder.eachDirRecurse { packageFolder ->
                            if (packageFolder.name == version) {
                                exclude.appendNode('directory', [url: "file://\$PROJECT_DIR\$/${rootProject.relativePath(packageFolder)}", includeSubdirectories: true])
                            }
                        }
                    }
                }

                // Set gradle home
                def gradleSettings = node.appendNode('component', [name: 'GradleSettings'])
                gradleSettings.appendNode('option', [name: 'SDK_HOME', value: gradle.gradleHomeDir.absolutePath])

                // set compiler heap space
                compilerConfig.appendNode('option', [name: 'BUILD_PROCESS_HEAP_SIZE', value: '2048'])

                // license header
                def copyrightManager = node.component.find { it.'@name' == 'CopyrightManager' }
                copyrightManager.@default = "ASL2"
                def aslCopyright = copyrightManager.copyright.find { it.option.find { it.@name == "myName" }?.@value == "ASL2" }
                if (aslCopyright == null) {
                  copyrightManager.append(new XmlParser().parseText("""
                      <copyright>
                          <option name="notice" value="Copyright \${today.year} the original author or authors.&#10;&#10;Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);&#10;you may not use this file except in compliance with the License.&#10;You may obtain a copy of the License at&#10;&#10;     http://www.apache.org/licenses/LICENSE-2.0&#10;&#10;Unless required by applicable law or agreed to in writing, software&#10;distributed under the License is distributed on an &quot;AS IS&quot; BASIS,&#10;WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&#10;See the License for the specific language governing permissions and&#10;limitations under the License." />
                          <option name="keyword" value="Copyright" />
                          <option name="allowReplaceKeyword" value="" />
                          <option name="myName" value="ASL2" />
                          <option name="myLocal" value="true" />
                      </copyright>
                """))
                }

                // Code formatting options
                def codeFormatSettings = new XmlParser().parseText('''
          <component name="ProjectCodeStyleSettingsManager">
            <option name="PER_PROJECT_SETTINGS">
              <value>
                <option name="USE_SAME_INDENTS" value="true" />
                <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
                <option name="RIGHT_MARGIN" value="200" />
                <option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
                <option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" />
                <option name="JD_P_AT_EMPTY_LINES" value="false" />
                <option name="JD_KEEP_EMPTY_PARAMETER" value="false" />
                <option name="JD_KEEP_EMPTY_EXCEPTION" value="false" />
                <option name="JD_KEEP_EMPTY_RETURN" value="false" />
                <option name="WRAP_COMMENTS" value="true" />
                <option name="IF_BRACE_FORCE" value="3" />
                <option name="DOWHILE_BRACE_FORCE" value="3" />
                <option name="WHILE_BRACE_FORCE" value="3" />
                <option name="FOR_BRACE_FORCE" value="3" />
                <codeStyleSettings language="JAVA">
                  <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
                  <option name="IF_BRACE_FORCE" value="3" />
                  <option name="DOWHILE_BRACE_FORCE" value="3" />
                  <option name="WHILE_BRACE_FORCE" value="3" />
                  <option name="FOR_BRACE_FORCE" value="3" />
                </codeStyleSettings>
                <GroovyCodeStyleSettings>
                  <option name="ALIGN_NAMED_ARGS_IN_MAP" value="false" />
                  <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
                </GroovyCodeStyleSettings>
              </value>
            </option>
            <option name="USE_PER_PROJECT_SETTINGS" value="true" />
          </component>
        ''')
                node.append(codeFormatSettings)

                node.append(new XmlParser().parseText('''
                    <component name="GroovyCompilerProjectConfiguration">
                      <excludes>
                        <file url="file://$PROJECT_DIR$/subprojects/plugins/src/test/groovy/org/gradle/api/internal/tasks/testing/junit/JUnitTestClassProcessorTest.groovy" />
                      </excludes>
                      <option name="heapSize" value="2000" />
                    </component>
                '''))

                node.append(new NodeBuilder().component(name: 'FrameworkDetectionExcludesConfiguration') {
                  type(id: 'android')
                  type(id: 'web')
                })

                def buildSrcModuleFile = 'buildSrc/buildSrc.iml'
                if (file(buildSrcModuleFile).exists()) {
                    def projects = node.component.find { it.@name == 'ProjectModuleManager' }
                    if (projects) {
                        def buildSrc = projects.modules.module.find { it.@filepath.contains('buildSrc') }
                        if (!buildSrc) {
                            projects.modules.find().appendNode('module', [
                                fileurl: "file://\$PROJECT_DIR\$/${buildSrcModuleFile}",
                                filepath: "\$PROJECT_DIR\$/${buildSrcModuleFile}"
                            ])
                        }
                    }
                }
            }
        }
    }

    workspace.iws.withXml { provider ->
        Node node = provider.asNode()

        node.append(new XmlParser().parseText('''
            <component name="CompilerWorkspaceConfiguration">
              <option name="COMPILER_PROCESS_HEAP_SIZE" value="2048" />
            </component>
        '''))

        Node runManagerConfig = node.component.find { it.'@name' == 'RunManager' }

        // Add int test configuration to JUnit defaults
        Node runConfig = runManagerConfig.configuration.find { it.'@type' == 'JUnit'}

        Node vmParameters = runConfig.option.find { it.'@name' == 'VM_PARAMETERS' }

        def docsProject = project(":docs")
        def defaultTestVmParams = [
                "-Dorg.gradle.docs.releasenotes.source=${docsProject.releaseNotesMarkdown.markdownFile}",
                "-Dorg.gradle.docs.releasenotes.rendered=${new File(docsProject.releaseNotes.destinationDir, docsProject.releaseNotes.fileName)}",
                "-DintegTest.gradleHomeDir=\$MODULE_DIR\$/build/integ test",
                "-DintegTest.gradleUserHomeDir=${rootProject.file('intTestHomeDir').absolutePath}",
                "-DintegTest.libsRepo=${rootProject.file('build/repo').absolutePath}",
                "-Dorg.gradle.integtest.daemon.registry=${rootProject.file('build/daemon').absolutePath}",
                "-DintegTest.distsDir=${rootProject.distsDir.absolutePath}",
                "-Dorg.gradle.integtest.executer=embedded",
                "-Dorg.gradle.integtest.versions=latest",
                "-Dorg.gradle.integtest.multiversion=default",
                "-Dorg.gradle.integtest.testkit.compatibility=current",
                "-Dorg.gradle.public.api.includes=${publicApiIncludes.join(':')}",
                "-Dorg.gradle.public.api.excludes=${publicApiExcludes.join(':')}",
                "-ea",
                "-Xmx512m"
        ]

        if (!javaVersion.java8Compatible) {
            defaultTestVmParams += "-XX:MaxPermSize=512m"
        }

        vmParameters.'@value' = defaultTestVmParams.collect { it.contains(" ") ? "\"$it\"" : it }.join(" ")

        // Add int test environment variables
        def lang = System.getenv('LANG') ?: 'en_US.UTF-8'
        def envVars = runConfig.envs.first()
        envVars.children.each { child -> envVars.remove(child) }
        envVars.appendNode('env', [name: 'LANG', value: lang])

        // Add an application configuration
        runManagerConfig.'@selected' = 'Application.Gradle'
        def appConfig =

        runManagerConfig.append(new XmlParser().parseText('''
            <configuration default="false" name="Gradle" type="Application" factoryName="Application">
              <extension name="coverage" enabled="false" merge="false" />
              <option name="MAIN_CLASS_NAME" value="org.gradle.debug.GradleRunConfiguration" />
              <option name="VM_PARAMETERS" value="" />
              <option name="PROGRAM_PARAMETERS" value="" />
              <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
              <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
              <option name="ALTERNATIVE_JRE_PATH" value="" />
              <option name="ENABLE_SWING_INSPECTOR" value="false" />
              <option name="ENV_VARIABLES" />
              <option name="PASS_PARENT_ENVS" value="true" />
              <module name="integTest" />
              <envs />
              <RunnerSettings RunnerId="Debug">
                <option name="DEBUG_PORT" value="63810" />
                <option name="TRANSPORT" value="0" />
                <option name="LOCAL" value="true" />
              </RunnerSettings>
              <RunnerSettings RunnerId="Run" />
              <ConfigurationWrapper RunnerId="Debug" />
              <ConfigurationWrapper RunnerId="Run" />
              <method />
            </configuration>
        '''))

        def gradleRunners = [
                "Regenerate IDEA metadata": "idea",
                "Regenerate Int Test Image": "prepareVersionsInfo intTestImage publishLocalArchives"
        ]

        def runnerClass = "org.gradle.testing.internal.util.GradlewRunner"
        def runnerClassModule = "internalTesting"

        def listItems = []
        gradleRunners.each { runnerName, commandLine ->
            runManagerConfig.append(new XmlParser().parseText("""
                <configuration default='false' name='${runnerName}' type='Application' factoryName='Application'>
                  <extension name='coverage' enabled='false' merge='false' />
                  <option name='MAIN_CLASS_NAME' value='${runnerClass}' />
                  <option name='VM_PARAMETERS' value='' />
                  <option name='PROGRAM_PARAMETERS' value='${commandLine}' />
                  <option name='WORKING_DIRECTORY' value='file://\$PROJECT_DIR\$' />
                  <option name='ALTERNATIVE_JRE_PATH_ENABLED' value='false' />
                  <option name='ALTERNATIVE_JRE_PATH' value='' />
                  <option name='ENABLE_SWING_INSPECTOR' value='false' />
                  <option name='ENV_VARIABLES' />
                  <option name='PASS_PARENT_ENVS' value='true' />
                  <module name='${runnerClassModule}' />
                  <envs>
                    <env name="TERM" value="xterm" />
                  </envs>
                  <method>
                    <option name="Make" enabled="false" />
                  </method>
                </configuration>
            """))

            listItems << "<item index='${listItems.size() + 1}' class='java.lang.String' itemvalue='Application.${runnerName}' />"
        }

        // Add remote debugger configuration
        runManagerConfig.append(new XmlParser().parseText("""
            <configuration default="false" name="Remote debug port 5005" type="Remote" factoryName="Remote">
              <option name="USE_SOCKET_TRANSPORT" value="true" />
              <option name="SERVER_MODE" value="false" />
              <option name="SHMEM_ADDRESS" value="javadebug" />
              <option name="HOST" value="localhost" />
              <option name="PORT" value="5005" />
              <method />
            </configuration>
        """))
        listItems << "<item index='${listItems.size() + 1}' class='java.lang.String' itemvalue='Remote.Remote debug port 5005' />"

        runManagerConfig.append(new XmlParser().parseText("""
            <list size='${listItems.size() + 1}'>
              <item index='0' class='java.lang.String' itemvalue='Application.Gradle' />
              ${listItems.join('\n')}
            </list>
        """))
    }
}