Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath "org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE"
- }
- }
- plugins {
- id "org.flywaydb.flyway" version "4.0"
- id "org.sonarqube" version "2.2.1"
- id "com.moowork.node" version "0.12"
- }
- apply plugin: 'java'
- apply plugin: 'idea'
- apply plugin: 'spring-boot'
- apply plugin: 'checkstyle'
- apply plugin: 'jacoco'
- apply plugin: 'pmd'
- group = serviceGroup
- version = serviceVersion
- archivesBaseName = rootProject.name
- project.ext.buildTime = java.time.Instant.now().toString() // for versioning
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
- repositories {
- mavenCentral()
- jcenter()
- maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
- }
- dependencies {
- compile "org.springframework.boot:spring-boot-starter-web"
- compile "org.springframework.boot:spring-boot-starter-data-rest"
- compile "org.projectlombok:lombok:1.16.8"
- compile "org.springframework.boot:spring-boot-starter-data-jpa"
- compile "org.postgresql:postgresql:9.4.1208"
- compile "com.github.tomakehurst:wiremock:1.58"
- compile "org.springframework:spring-test"
- compile 'org.webjars:swagger-ui:2.2.6'
- compile 'org.openlmis:openlmis-service-util:3.0.0'
- compile 'org.apache.commons:commons-lang3:3.5'
- compile 'org.javers:javers-spring-boot-starter-sql:2.8.1'
- compile 'org.flywaydb:flyway-core:4.0.3'
- testCompile "junit:junit"
- testCompile "org.mockito:mockito-core:1.+"
- testCompile "org.springframework.boot:spring-boot-starter-test"
- }
- idea {
- project {
- vcs = 'Git'
- ipr.withXml { xmlFile ->
- // enable 'Annotation Processors', source: https://gist.github.com/stephanos/8645809
- xmlFile.asNode().component
- .find { it.@name == 'CompilerConfiguration' }['annotationProcessing'][0]
- .replaceNode {
- annotationProcessing {
- profile(default: true, name: 'Default', useClasspath: 'true', enabled: true)
- }
- }
- }
- /* iml.withXml { xmlFile ->
- xmlFile.asNode().component.find { it.@name == 'NewModuleRootManager'}['Content'][0]
- .addNode {
- sourceFolder {
- profile(url: "file://$MODULE_DIR\$/src/integration-test/java", isTestSource:
- true)
- }
- }
- }*/
- }
- }
- flyway {
- url = "$System.env.DATABASE_URL"
- user = "$System.env.POSTGRES_USER"
- password = "$System.env.POSTGRES_PASSWORD"
- schemas = ['cce']
- sqlMigrationPrefix = ''
- placeholderPrefix = '#['
- placeholderSuffix = ']'
- }
- sourceSets {
- integrationTest {
- java {
- compileClasspath += main.output + test.output
- runtimeClasspath += main.output + test.output
- srcDir file('src/integration-test/java')
- }
- resources.srcDir file('src/integration-test/resources')
- }
- }
- configurations {
- integrationTestCompile.extendsFrom testCompile
- integrationTestRuntime.extendsFrom testRuntime
- }
- task integrationTest(type: Test) {
- testClassesDir = sourceSets.integrationTest.output.classesDir
- classpath = sourceSets.integrationTest.runtimeClasspath
- testLogging {
- events "passed", "skipped", "failed"
- exceptionFormat = 'full'
- }
- mustRunAfter test
- }
- tasks.withType(Test) {
- reports.html.destination = file("${reporting.baseDir}/${name}")
- reports.junitXml.destination = file("${testResultsDir}/${name}")
- }
- // Usage: gradle generateMigration [-PmigrationName=name_of_migration]
- // Defaults to 'migration' as migration name
- // Example: gradle generateMigration -PmigrationName=add_column_to_users
- // Will create a file in migration folder with name yyyyMMddHHmmssSSS_add_column_to_users.sql.
- task generateMigration << {
- description 'Creates an empty new file within the src/main/resources/db/migration directory into which developers can add new SQL migration code.'
- def fileName = project.hasProperty('migrationName') ? migrationName : 'migration'
- def timestamp = new Date().format('yyyyMMddHHmmssSSS', TimeZone.getTimeZone('GMT'))
- def fullFileName = "${timestamp}__${fileName}.sql"
- def migrationFile = new File(sourceSets.main.resources.srcDirs.first(),'db/migration/'+fullFileName)
- migrationFile.createNewFile()
- }
- task checkApiIsRaml(type:Exec) {
- executable "raml-cop"
- args "src/main/resources/api-definition.yaml"
- }
- configure(checkApiIsRaml) {
- group = JavaBasePlugin.VERIFICATION_GROUP
- description = 'Verify that the api-specification is valid RAML'
- }
- jacocoTestReport {
- group = "reporting"
- description = "Generate Jacoco coverage reports after running tests."
- reports {
- xml.enabled false
- html.enabled true
- csv.enabled false
- }
- additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)
- }
- checkstyle {
- toolVersion = "6.19"
- }
- //Usage: gradle sonarqube
- sonarqube {
- properties {
- property "sonar.projectName", "OpenLMIS CCE Service"
- property "sonar.projectKey", "org.sonarqube:$rootProject.name"
- property "sonar.projectVersion", version
- property "sonar.host.url", "http://sonar.openlmis.org"
- property "sonar.java.coveragePlugin", "jacoco"
- //Tells SonarQube where the unit tests execution reports are
- property "sonar.junit.reportsPath", "build/test-results/test"
- //Tells SonarQube where the unit tests code coverage report is
- property "sonar.jacoco.reportPath", "build/jacoco/test.exec"
- //Tells SonarQube where the integration tests code coverage report is
- property "sonar.jacoco.itReportPath", "build/jacoco/integrationTest.exec"
- properties["sonar.tests"] += sourceSets.integrationTest.java
- }
- }
- pmd {
- toolVersion = '5.4.0'
- consoleOutput= true
- ignoreFailures = false
- ruleSetFiles = files("config/pmd/ruleset.xml")
- reportsDir = file("build/reports/pmd")
- }
- tasks.withType(Pmd){
- reports {
- xml.enabled true
- html.enabled true
- }
- }
- test {
- testLogging {
- events 'started', 'passed'
- exceptionFormat = 'full'
- }
- }
- apply from: "documentation.gradle"
- integrationTest {
- dependsOn ramlToSwagger
- }
- processResources {
- // we want the generated swagger spec file included in the output jar
- finalizedBy ramlToSwagger
- // update version information in build
- filesMatching('**/version.properties') {
- expand(project.properties)
- }
- }
- check {
- dependsOn checkApiIsRaml
- dependsOn integrationTest
- }
- build {
- dependsOn jacocoTestReport
- dependsOn check
- dependsOn ramlToHtml
- dependsOn copyRamlHtmlToBuild
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement