Permalink
Browse files

Improve the idea metadata generation by the build system.

• Specify the code formatting rules
• Specify the license header to use
  • Loading branch information...
1 parent 4f41644 commit 57dee89de849fe7a7bdfb454b6a1c888e3dd8f2c @alkemist alkemist committed Oct 24, 2012
Showing with 61 additions and 11 deletions.
  1. +1 −11 build.gradle
  2. +32 −0 gradle/idea.gradle
  3. +28 −0 gradle/ideaCodeStyle.xml
View
@@ -96,18 +96,8 @@ allprojects {
}
}
+apply from: "gradle/idea.gradle"
-idea {
- project {
- jdkName "1.6"
- ipr {
- withXml { provider ->
- def node = provider.asNode()
- node.component.find { it.'@name' == 'VcsDirectoryMappings' }?.mapping[0].'@vcs' = 'Git'
- }
- }
- }
-}
subprojects { project ->
apply plugin: 'groovy'
apply plugin: 'maven'
View
@@ -0,0 +1,32 @@
+idea {
+ project {
+ jdkName "1.6"
+ ipr {
+ withXml { provider ->
+ def node = provider.asNode()
+
+ // Use Git
+ node.component.find { it.'@name' == 'VcsDirectoryMappings' }?.mapping[0].'@vcs' = 'Git'
+
+ // Apply our code formatting
+ node.append(new XmlParser().parse(file("gradle/ideaCodeStyle.xml")))
+
+ // Use the ASL2 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 2012 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>
+ '''))
+ }
+ }
+ }
+ }
+}
View
@@ -0,0 +1,28 @@
+<component name="CodeStyleSettingsManager">
+ <option name="PER_PROJECT_SETTINGS">
+ <value>
+ <option name="USE_SAME_INDENTS" value="true"/>
+ <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"/>
+ <option name="INDENT_SIZE" value="4"/>
+ <option name="CONTINUATION_INDENT_SIZE" value="4"/>
+ <option name="TAB_SIZE" value="4"/>
+ <option name="USE_TAB_CHARACTER" value="false"/>
+ <option name="SMART_TABS" value="false"/>
+ <option name="LABEL_INDENT_SIZE" value="0"/>
+ <option name="LABEL_INDENT_ABSOLUTE" value="false"/>
+ <option name="USE_RELATIVE_INDENTS" value="false"/>
+ </value>
+ </option>
+ <option name="USE_PER_PROJECT_SETTINGS" value="true"/>
+</component>

0 comments on commit 57dee89

Please sign in to comment.