diff init20.gradle @ 233:400f9d8bbf5b

DEP-13: enable sonar analysis for gradle 3.1 projects. disable sonar for ant based projects
author smith@nwoca.org
date Wed, 19 Oct 2016 22:42:08 +0100
parents 47535c8358ce
children 05a1bbd319bc
line wrap: on
line diff
--- a/init20.gradle	Tue Oct 18 18:29:04 2016 +0100
+++ b/init20.gradle	Wed Oct 19 22:42:08 2016 +0100
@@ -5,17 +5,19 @@
 
 buildscript {
     repositories {
-		maven { url 'http://repos.ssdt.nwoca.org/artifactory/gradle-plugins' }
+        maven { url 'http://repos.ssdt.nwoca.org/artifactory/gradle-plugins' }
         maven { url 'http://repos.ssdt.nwoca.org/artifactory/ssdt-repo' }
     }
-	dependencies {
-		classpath 'postgresql:postgresql:9.1-901.jdbc4'
-		classpath  'com.netflix.nebula:gradle-dependency-lock-plugin:4.3.0'
-	}
+    dependencies {
+        classpath 'postgresql:postgresql:9.1-901.jdbc4'
+        classpath  'com.netflix.nebula:gradle-dependency-lock-plugin:4.3.0'
+    }
 }
 
 final GradleVersion gradleCurrent = GradleVersion.current()
 final GradleVersion gradleV20 = GradleVersion.version('2.0')
+final GradleVersion gradleV31 = GradleVersion.version('3.1')
+
 println "Gradle Version: $gradleCurrent"
 
 if (gradleCurrent < gradleV20) {
@@ -88,8 +90,8 @@
 
 def cacheTimeout = 60 * 60 * 8 
 if (gradle.environment['dependencyTimeout']) {
-	cacheTimeout = gradle.environment['dependencyTimeout'] as Integer
-	println "setting changing dependency timeout to $cacheTimeout seconds"	
+    cacheTimeout = gradle.environment['dependencyTimeout'] as Integer
+    println "setting changing dependency timeout to $cacheTimeout seconds"  
 }
 
 gradle.ext.cacheTimeout = cacheTimeout 
@@ -135,9 +137,9 @@
 
 rootProject.afterEvaluate { r ->
 
-	if (gradle.bambooBuild && r.hasProperty('requireJavaVersion')) {
-		gradle.runtimeInfo.requireJava( r.getProperty('requireJavaVersion') )
-	}
+    if (gradle.bambooBuild && r.hasProperty('requireJavaVersion')) {
+        gradle.runtimeInfo.requireJava( r.getProperty('requireJavaVersion') )
+    }
 
     if (r.plugins.hasPlugin(org.gradle.plugins.ide.idea.IdeaPlugin)) {
 
@@ -225,9 +227,15 @@
     project.component.find { it.@name == name }
 }
 
+if (gradleCurrent >= gradleV31) {
+   wrapper {
+        distributionType = org.gradle.api.tasks.wrapper.Wrapper.DistributionType.ALL
+   }
+}
+
 allprojects {
 
-	apply plugin: nebula.plugin.dependencylock.DependencyLockPlugin
+    apply plugin: nebula.plugin.dependencylock.DependencyLockPlugin
 
     dependencyLock {
         globalLockFile =  gradle.branch.isRelease() ? 'release.lock' : 'global.lock'
@@ -240,10 +248,10 @@
     configurations.all {
         resolutionStrategy.eachDependency { DependencyResolveDetails details ->
             if (details.requested.group == 'org.ssdt_ohio' && !details.requested.version ) {
-				details.useVersion( "latest.${gradle.branch.defaultDependencyStatus}" )
+                details.useVersion( "latest.${gradle.branch.defaultDependencyStatus}" )
             }
             if (details.requested.version == 'default') {
-				details.useVersion("latest.${gradle.branch.defaultDependencyStatus}" )
+                details.useVersion("latest.${gradle.branch.defaultDependencyStatus}" )
             }
             if (project.hasProperty("overrideCommon")) {
                if (details.requested.group == 'org.ssdt_ohio' && details.requested.name.contains('ssdt.common.')) {
@@ -280,7 +288,7 @@
             def t = taskName.contains('Test') ? sourceSets.test.output.resourcesDir : sourceSets.main.output.resourcesDir
             def e = (taskName - 'Test' - 'AsProperties').capitalize()
             task(taskName) {
-				ext.outputDir = t
+                ext.outputDir = t
                 ext.propertyFile = "${e.toLowerCase()}.properties"
                 ext.buildenv = project.file('build/buildenv.txt')
                 inputs.files project.file("../environment${e}.groovy"), project.file("../private${e}.groovy"), project.file('../private.properties')
@@ -293,8 +301,8 @@
                     buildenv.text = gradle.env
                     def ps = gradle."environment${e}".toProperties()
                     ps['ssdt.project'] = project.name
-					def pf = new File(outputDir,propertyFile)
-					ext.outputPropertyFile = pf
+                    def pf = new File(outputDir,propertyFile)
+                    ext.outputPropertyFile = pf
                     ps.store(pf.newOutputStream(), "by $taskName of $this")
                     def l = pf.readLines().sort()
                     pf.text = l.join('\n')
@@ -332,10 +340,10 @@
                                 gradle.environmentDatabase.jdbc.password,
                                 driverName)
                         if (dropIt) {
-							logger.info "disconnecting sessions from $databaseName"
-							sql.execute "REVOKE CONNECT ON DATABASE \"" + databaseName + "\" FROM public;"
-							sql.execute "REVOKE CONNECT ON DATABASE \"" + databaseName + "\" FROM " + gradle.environmentDatabase.jdbc.username + ";"
-							sql.execute "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '" + databaseName + "';"
+                            logger.info "disconnecting sessions from $databaseName"
+                            sql.execute "REVOKE CONNECT ON DATABASE \"" + databaseName + "\" FROM public;"
+                            sql.execute "REVOKE CONNECT ON DATABASE \"" + databaseName + "\" FROM " + gradle.environmentDatabase.jdbc.username + ";"
+                            sql.execute "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '" + databaseName + "';"
                             logger.info "dropping $databaseName (if exists) from $adminUrl"
                             sql.execute 'DROP DATABASE IF EXISTS "' + databaseName + '";'
                         }
@@ -521,17 +529,17 @@
                 }
 
             }
-			
-			def remoteRepos = thisProject.repositories.findAll { it.hasProperty('url') && !(it.name == 'local' || it.url.toString().contains('ssdt')) }	
-			if (remoteRepos) {
-				logger.warn "WARNING: Remote repositories configured for $thisProject:\n" + remoteRepos.collect { "\t$it.name $it.url " }.join('\n')  + "\n Moved to lowest priority..."
-				remoteRepos.each {
-					thisProject.repositories.remove(it)
-					thisProject.repositories.addLast(it)
-				}
-			}
-			logger.info "$thisProject configured repositories:\n" + thisProject.repositories.collect {"\t$it.name ${it.hasProperty('url') ? it.url : '' }" }.join('\n')
-			
+            
+            def remoteRepos = thisProject.repositories.findAll { it.hasProperty('url') && !(it.name == 'local' || it.url.toString().contains('ssdt')) } 
+            if (remoteRepos) {
+                logger.warn "WARNING: Remote repositories configured for $thisProject:\n" + remoteRepos.collect { "\t$it.name $it.url " }.join('\n')  + "\n Moved to lowest priority..."
+                remoteRepos.each {
+                    thisProject.repositories.remove(it)
+                    thisProject.repositories.addLast(it)
+                }
+            }
+            logger.info "$thisProject configured repositories:\n" + thisProject.repositories.collect {"\t$it.name ${it.hasProperty('url') ? it.url : '' }" }.join('\n')
+            
 
             if (thisProject.repositories.find { it.name == 'local' } && thisProject.getTasksByName('uploadArchives', false)) {
                 uploadArchives {
@@ -603,10 +611,10 @@
 
     def environment = slurper.parse(
             '''deploy.mode="production"
-	   environments {
-		test { deploy.mode="test" }
-		dev { deploy.mode="development"}
-	   }''')
+       environments {
+        test { deploy.mode="test" }
+        dev { deploy.mode="development"}
+       }''')
     if (developerPrivate['deploy.mode']) {
         environment.put('deploy.mode', developerPrivate['deploy.mode'])
     }
@@ -661,7 +669,7 @@
     // OS memory in megabytes, zero if unknown
     int systemMemory = 0
     int systemFreeMemory = 0
-	String javaVersion = System.getProperty('java.version')
+    String javaVersion = System.getProperty('java.version')
 
     RuntimeInfo() {
         try {
@@ -674,28 +682,28 @@
         } catch (e) {  }
 
     }
-	
-	void requireMemory(int megabytes) {
-		if (systemFreeMemory > 0 && systemFreeMemory < megabytes) {
-			throw new GradleException("insufficent free OS memory for this build (available: ${systemFreeMemory}m, required: ${megabytes}m)")
-		}
-	}
-	/**
-	* Returns maximum memory available upto the value specified. 
-	*/
-	int maxMemory(int megabytes) {
-	   if (systemFreeMemory) {
-			[systemFreeMemory,megabytes].min()
-	   } else { megabytes }
-	
-	}
-	
-	void requireJava(String version) {
-	
-		if ( version && !javaVersion.startsWith(version)) {
-			throw new GradleException("Requires java version $version but running under $javaVersion")
-		}
-	}
+    
+    void requireMemory(int megabytes) {
+        if (systemFreeMemory > 0 && systemFreeMemory < megabytes) {
+            throw new GradleException("insufficent free OS memory for this build (available: ${systemFreeMemory}m, required: ${megabytes}m)")
+        }
+    }
+    /**
+    * Returns maximum memory available upto the value specified. 
+    */
+    int maxMemory(int megabytes) {
+       if (systemFreeMemory) {
+            [systemFreeMemory,megabytes].min()
+       } else { megabytes }
+    
+    }
+    
+    void requireJava(String version) {
+    
+        if ( version && !javaVersion.startsWith(version)) {
+            throw new GradleException("Requires java version $version but running under $javaVersion")
+        }
+    }
 
 }
 
@@ -744,8 +752,8 @@
 class BranchInfo {
     def name
     def stream = "none"
-	def buildNumber = ""	
-	def changeset = ""
+    def buildNumber = ""    
+    def changeset = ""
     def version
 
     BranchInfo(name) {
@@ -755,26 +763,26 @@
         }
         this.name = this.name.replace('@', '-')
         determineStream()
-		buildNumber = System.getenv('bamboo_buildNumber') ?: ""
-		changeset = System.getenv('bamboo_planRepository_revision') ?: ""
-	}
-	
-	String getDefaultDependencyStatus() {
-		return isRelease() ? 'release' : 'integration'
-	}
+        buildNumber = System.getenv('bamboo_buildNumber') ?: ""
+        changeset = System.getenv('bamboo_planRepository_revision') ?: ""
+    }
+    
+    String getDefaultDependencyStatus() {
+        return isRelease() ? 'release' : 'integration'
+    }
 
     private boolean isRelease() {
         return stream in ['release', 'hotfix']
     }
 
     def getShortName() {
-		def result = name.contains('/') ? name.split('/')[1] : name 
-	} 
-	
-	String getBuildVersion() {
-		def v = isRelease() ? shortName - "v": ""
+        def result = name.contains('/') ? name.split('/')[1] : name 
+    } 
+    
+    String getBuildVersion() {
+        def v = isRelease() ? shortName - "v": ""
         return v
-	}
+    }
 
     def Version getVersion() {
         if (!version) {
@@ -788,15 +796,15 @@
     }
 
     def getImageId() {
-		(buildVersion ?:  shortName.take(25)) + (buildNumber ? "-${buildNumber}" : "-0")
-	}
+        (buildVersion ?:  shortName.take(25)) + (buildNumber ? "-${buildNumber}" : "-0")
+    }
 
-	def getDeployName() {
-		(buildVersion ?:  shortName.take(25)).toLowerCase().collectReplacements {
-			('a'..'z').contains(it) || ('0'..'9').contains(it) || it == "-" ? null : '-'
-		}
-	}
-	
+    def getDeployName() {
+        (buildVersion ?:  shortName.take(25)).toLowerCase().collectReplacements {
+            ('a'..'z').contains(it) || ('0'..'9').contains(it) || it == "-" ? null : '-'
+        }
+    }
+    
     def getHash() {
         generateMD5(name)
     }
@@ -807,10 +815,10 @@
     }
 
     private findSnapshotVersion() {
-		def repositoryUrl = System.getenv('bamboo_planRepository_repositoryUrl')
-		if (repositoryUrl) { 
-			println "hg pull $repositoryUrl".execute().text 
-		}
+        def repositoryUrl = System.getenv('bamboo_planRepository_repositoryUrl')
+        if (repositoryUrl) { 
+            println "hg pull $repositoryUrl".execute().text 
+        }
         def versions = "hg branches --closed".execute().text.split('\n').findAll {
             it.startsWith( 'release') || it.startsWith( 'hotfix')
         }.collect {