| /** |
| * Configuration for gradle idea. |
| * |
| * Inspired from the Gradle build. |
| */ |
| |
| allprojects { |
| apply plugin: 'idea' |
| } |
| |
| idea { |
| |
| project { |
| jdkName = '1.6' |
| languageLevel = '1.6' |
| |
| ipr { |
| withXml { provider -> |
| def node = provider.asNode() |
| |
| // Use git |
| def vcsConfig = node.component.find { it.'@name' == 'VcsDirectoryMappings' } |
| vcsConfig.mapping[0].'@vcs' = 'Git' |
| |
| // 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 2003-$today.year the original author or authors. 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." /> |
| <option name="keyword" value="Copyright" /> |
| <option name="allowReplaceKeyword" value="" /> |
| <option name="myName" value="ASL2" /> |
| <option name="myLocal" value="true" /> |
| </copyright> |
| ''')) |
| } |
| } |
| } |
| } |
| |
| workspace { |
| iws { |
| withXml { provider -> |
| def node = provider.asNode() |
| |
| // exclude some files from stub generation |
| def groovyCompilerConfig = node.component.find { it.'@name' == 'GroovyCompilerConfiguration' } |
| if (!groovyCompilerConfig) { |
| node.append(new XmlParser().parseText(''' |
| <component name='GroovyCompilerConfiguration'> |
| <excludes></excludes> |
| </component>''')) |
| groovyCompilerConfig = node.component.find { it.'@name' == 'GroovyCompilerConfiguration' } |
| } |
| def excludeNode = groovyCompilerConfig.excludes[0] |
| ['/src/test/org/codehaus/groovy/transform/DelegateTransformTest.groovy', |
| '/src/test/groovy/bugs/Groovy593_Bug.groovy'].each { excludedFile -> |
| def url = "file://\$PROJECT_DIR\$$excludedFile" |
| if (!excludeNode.file.any { it.'@url' == url }) { |
| excludeNode.append(new XmlParser().parseText("<file url=\"$url\" />")) |
| } |
| } |
| } |
| } |
| } |
| |
| module.iml.withXml { provider -> |
| def node = provider.asNode() |
| |
| // replace groovy-1.8.6.jar in libraries with the one generated in target |
| def entry = node.component.find { it.'@name' == 'NewModuleRootManager' }.orderEntry.find { oe -> |
| oe.library.CLASSES.root.'@url' =~ /groovy-(all-)?[0-9]\.[0-9]\.[0-9](-SNAPSHOT)?\.jar/ |
| } |
| if (entry) { |
| //entry.library.CLASSES.root[0].'@url' = "jar://\$MODULE_DIR\$/target/libs/groovy-all-${groovyVersion}.jar!/" |
| entry.library.CLASSES.root[0].'@url' = "jar://\$MODULE_DIR\$/target/libs/groovy-${groovyVersion}.jar!/" |
| } |
| } |
| |
| } |
| |
| tasks.withType(GenerateIdeaProject).all { |
| it.doLast { |
| println """ |
| -------------------------------------------------------------------------------- |
| Project has been created, but it is recommended that you run the 'jarAll' task |
| in order to provide IntelliJ IDEA a groovy jar that it can use for compilation |
| -------------------------------------------------------------------------------- |
| """ |
| } |
| } |