changeset 136:9ce07c211984

for idea: add enabling hg, set default codestyle, set standard copyright notice
author smith@nwoca.org
date Mon, 12 Aug 2013 20:09:49 +0100
parents 51e4ee02d47a
children cc3cd7da35a7
files init.gradle
diffstat 1 files changed, 81 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/init.gradle	Fri Jul 05 18:55:37 2013 +0100
+++ b/init.gradle	Mon Aug 12 20:09:49 2013 +0100
@@ -68,11 +68,88 @@
 
 apply from: "${gradle.ssdtDevelkitLocation}/metrics.gradle"   
 
-task wrapper(type: Wrapper) {}
+rootProject.afterEvaluate { r ->
 
-wrapper << {
-    // patch wrapper path for 1.0-milestone-7 (http://issues.gradle.org/browse/GRADLE-1823)
-    ant.replace(file: 'gradlew', token: '\\wrapper\\gradle-wrapper.jar',value:'/wrapper/gradle-wrapper.jar')
+   if (r.plugins.hasPlugin(org.gradle.plugins.ide.idea.IdeaPlugin)) {
+   
+		r.idea.project.ipr.withXml { xml ->
+			if (file('.hg').exists()) {
+				println 'enabling HG on project'
+				def vcs = findComponent(xml.asNode(),'VcsDirectoryMappings')
+				vcs.mapping.@vcs = 'hg4idea'
+			}
+			
+			def codeStyle = findComponent(xml.asNode(),'ProjectCodeStyleSettingsManager')
+			if (codeStyle) { xml.asNode().remove(codeStyle) }
+			
+			def styleManager = xml.asNode().appendNode('component', [name: 'ProjectCodeStyleSettingsManager'])
+			styleManager.appendNode 'option', [name: 'USE_PER_PROJECT_SETTINGS',value: true]
+			
+			def styleOptions = new NodeBuilder().option(name:'PER_PROJECT_SETTINGS') {
+				value {
+					GroovyCodeStyleSettings {
+						option(name: 'CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND', value:'10') 
+						option(name: 'PACKAGES_TO_USE_IMPORT_ON_DEMAND') {
+							value {
+								'package'( name:"java.awt", withSubpackages: false, static: false )
+								'package'( name:"javax.swing", withSubpackages:false, static:false )
+								'package'( name:"javax.persistence", withSubpackages:false, static:false )
+								'package'( name:"javax.validation", withSubpackages: true, static:false )
+							}
+						}
+					}
+					XML {
+						option(name: 'XML_LEGACY_SETTINGS_IMPORTED',value:true)
+					}
+					
+				}
+			}
+			
+			styleManager.append styleOptions
+			
+			if (r.group.contains('org.ssdt') ) {
+			
+				def copyRight = findComponent(xml.asNode(),'CopyrightManager')
+				if (copyRight) { xml.asNode().remove(copyRight) }
+
+				copyRight = new NodeBuilder().component(name: 'CopyrightManager', default: 'ODE') {
+				
+					copyright {
+						option (name: 'notice', value:'Copyright (c) $today.year.  Ohio Department of Education. - All Rights Reserved.\nUnauthorized copying of this file, in any medium, is strictly prohibited.\nWritten by State Software Development Team (http://ssdt.oecn.k12.oh.us/)' )
+						option (name: 'keyword', value: 'Copyright')
+						option (name: 'allowReplaceKeyword', value: 'South Front' )
+						option (name: 'myName', value: 'ODE' )
+						option (name: 'myLocal', value: true )				
+					}
+					LanguageOptions(name: 'CSS') {
+						option(name:'fileTypeOverride', value: 1)
+					}
+					LanguageOptions(name: 'JSP') {
+						option(name:'fileTypeOverride', value: 1)
+						option(name:'prefixLines', value: false)
+					}
+					LanguageOptions(name: 'JSPX') {
+						option(name:'fileTypeOverride', value: 1)
+						option(name:'prefixLines', value: false)
+					}
+					LanguageOptions(name: 'JavaScript') {
+						option(name:'fileTypeOverride', value: 1)
+					}
+					LanguageOptions(name: 'Properties') {
+						option(name:'fileTypeOverride', value: 1)
+					}
+				}
+				
+				xml.asNode().append copyRight
+			
+			}
+		}
+   }
+   
+}
+
+def findComponent(project, name) {
+	project.component.find { it.@name == name }
 }
 
 allprojects {