Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.88 KB | None | 0 0
  1. buildscript {
  2. repositories {
  3. mavenCentral()
  4. }
  5. dependencies {
  6. classpath "org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE"
  7. }
  8. }
  9.  
  10. plugins {
  11. id "org.flywaydb.flyway" version "4.0"
  12. id "org.sonarqube" version "2.2.1"
  13. id "com.moowork.node" version "0.12"
  14. }
  15.  
  16. apply plugin: 'java'
  17. apply plugin: 'idea'
  18. apply plugin: 'spring-boot'
  19. apply plugin: 'checkstyle'
  20. apply plugin: 'jacoco'
  21. apply plugin: 'pmd'
  22.  
  23. group = serviceGroup
  24. version = serviceVersion
  25. archivesBaseName = rootProject.name
  26. project.ext.buildTime = java.time.Instant.now().toString() // for versioning
  27. sourceCompatibility = 1.8
  28. targetCompatibility = 1.8
  29.  
  30. repositories {
  31. mavenCentral()
  32. jcenter()
  33. maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
  34. }
  35.  
  36. dependencies {
  37. compile "org.springframework.boot:spring-boot-starter-web"
  38. compile "org.springframework.boot:spring-boot-starter-data-rest"
  39. compile "org.projectlombok:lombok:1.16.8"
  40. compile "org.springframework.boot:spring-boot-starter-data-jpa"
  41. compile "org.postgresql:postgresql:9.4.1208"
  42. compile "com.github.tomakehurst:wiremock:1.58"
  43. compile "org.springframework:spring-test"
  44. compile 'org.webjars:swagger-ui:2.2.6'
  45. compile 'org.openlmis:openlmis-service-util:3.0.0'
  46. compile 'org.apache.commons:commons-lang3:3.5'
  47. compile 'org.javers:javers-spring-boot-starter-sql:2.8.1'
  48. compile 'org.flywaydb:flyway-core:4.0.3'
  49.  
  50. testCompile "junit:junit"
  51. testCompile "org.mockito:mockito-core:1.+"
  52. testCompile "org.springframework.boot:spring-boot-starter-test"
  53. }
  54.  
  55. idea {
  56. project {
  57. vcs = 'Git'
  58. ipr.withXml { xmlFile ->
  59. // enable 'Annotation Processors', source: https://gist.github.com/stephanos/8645809
  60. xmlFile.asNode().component
  61. .find { it.@name == 'CompilerConfiguration' }['annotationProcessing'][0]
  62. .replaceNode {
  63. annotationProcessing {
  64. profile(default: true, name: 'Default', useClasspath: 'true', enabled: true)
  65. }
  66. }
  67. }
  68. /* iml.withXml { xmlFile ->
  69. xmlFile.asNode().component.find { it.@name == 'NewModuleRootManager'}['Content'][0]
  70. .addNode {
  71. sourceFolder {
  72. profile(url: "file://$MODULE_DIR\$/src/integration-test/java", isTestSource:
  73. true)
  74. }
  75. }
  76. }*/
  77. }
  78. }
  79.  
  80. flyway {
  81. url = "$System.env.DATABASE_URL"
  82. user = "$System.env.POSTGRES_USER"
  83. password = "$System.env.POSTGRES_PASSWORD"
  84. schemas = ['cce']
  85. sqlMigrationPrefix = ''
  86. placeholderPrefix = '#['
  87. placeholderSuffix = ']'
  88. }
  89.  
  90. sourceSets {
  91. integrationTest {
  92. java {
  93. compileClasspath += main.output + test.output
  94. runtimeClasspath += main.output + test.output
  95. srcDir file('src/integration-test/java')
  96. }
  97. resources.srcDir file('src/integration-test/resources')
  98. }
  99. }
  100.  
  101. configurations {
  102. integrationTestCompile.extendsFrom testCompile
  103. integrationTestRuntime.extendsFrom testRuntime
  104. }
  105.  
  106. task integrationTest(type: Test) {
  107. testClassesDir = sourceSets.integrationTest.output.classesDir
  108. classpath = sourceSets.integrationTest.runtimeClasspath
  109. testLogging {
  110. events "passed", "skipped", "failed"
  111. exceptionFormat = 'full'
  112. }
  113. mustRunAfter test
  114. }
  115.  
  116. tasks.withType(Test) {
  117. reports.html.destination = file("${reporting.baseDir}/${name}")
  118. reports.junitXml.destination = file("${testResultsDir}/${name}")
  119. }
  120.  
  121. // Usage: gradle generateMigration [-PmigrationName=name_of_migration]
  122. // Defaults to 'migration' as migration name
  123. // Example: gradle generateMigration -PmigrationName=add_column_to_users
  124. // Will create a file in migration folder with name yyyyMMddHHmmssSSS_add_column_to_users.sql.
  125. task generateMigration << {
  126. description 'Creates an empty new file within the src/main/resources/db/migration directory into which developers can add new SQL migration code.'
  127. def fileName = project.hasProperty('migrationName') ? migrationName : 'migration'
  128. def timestamp = new Date().format('yyyyMMddHHmmssSSS', TimeZone.getTimeZone('GMT'))
  129. def fullFileName = "${timestamp}__${fileName}.sql"
  130. def migrationFile = new File(sourceSets.main.resources.srcDirs.first(),'db/migration/'+fullFileName)
  131. migrationFile.createNewFile()
  132. }
  133.  
  134. task checkApiIsRaml(type:Exec) {
  135. executable "raml-cop"
  136. args "src/main/resources/api-definition.yaml"
  137. }
  138.  
  139. configure(checkApiIsRaml) {
  140. group = JavaBasePlugin.VERIFICATION_GROUP
  141. description = 'Verify that the api-specification is valid RAML'
  142. }
  143.  
  144. jacocoTestReport {
  145. group = "reporting"
  146. description = "Generate Jacoco coverage reports after running tests."
  147. reports {
  148. xml.enabled false
  149. html.enabled true
  150. csv.enabled false
  151. }
  152.  
  153. additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)
  154. }
  155.  
  156. checkstyle {
  157. toolVersion = "6.19"
  158. }
  159.  
  160. //Usage: gradle sonarqube
  161. sonarqube {
  162. properties {
  163. property "sonar.projectName", "OpenLMIS CCE Service"
  164. property "sonar.projectKey", "org.sonarqube:$rootProject.name"
  165. property "sonar.projectVersion", version
  166. property "sonar.host.url", "http://sonar.openlmis.org"
  167. property "sonar.java.coveragePlugin", "jacoco"
  168. //Tells SonarQube where the unit tests execution reports are
  169. property "sonar.junit.reportsPath", "build/test-results/test"
  170. //Tells SonarQube where the unit tests code coverage report is
  171. property "sonar.jacoco.reportPath", "build/jacoco/test.exec"
  172. //Tells SonarQube where the integration tests code coverage report is
  173. property "sonar.jacoco.itReportPath", "build/jacoco/integrationTest.exec"
  174. properties["sonar.tests"] += sourceSets.integrationTest.java
  175. }
  176. }
  177.  
  178. pmd {
  179. toolVersion = '5.4.0'
  180. consoleOutput= true
  181. ignoreFailures = false
  182. ruleSetFiles = files("config/pmd/ruleset.xml")
  183. reportsDir = file("build/reports/pmd")
  184. }
  185.  
  186. tasks.withType(Pmd){
  187. reports {
  188. xml.enabled true
  189. html.enabled true
  190. }
  191. }
  192.  
  193.  
  194. test {
  195. testLogging {
  196. events 'started', 'passed'
  197. exceptionFormat = 'full'
  198. }
  199. }
  200.  
  201. apply from: "documentation.gradle"
  202. integrationTest {
  203. dependsOn ramlToSwagger
  204. }
  205.  
  206. processResources {
  207. // we want the generated swagger spec file included in the output jar
  208. finalizedBy ramlToSwagger
  209. // update version information in build
  210. filesMatching('**/version.properties') {
  211. expand(project.properties)
  212. }
  213. }
  214.  
  215. check {
  216. dependsOn checkApiIsRaml
  217. dependsOn integrationTest
  218. }
  219.  
  220. build {
  221. dependsOn jacocoTestReport
  222. dependsOn check
  223. dependsOn ramlToHtml
  224. dependsOn copyRamlHtmlToBuild
  225. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement