build.gradle 6.96 KB
Newer Older
1 2
import com.bmuschko.gradle.docker.tasks.image.*

akafred's avatar
akafred committed
3
apply plugin: 'java'
Rurik Greenall's avatar
Rurik Greenall committed
4
apply plugin: 'eclipse'
5
apply plugin: 'idea'
akafred's avatar
akafred committed
6 7
apply plugin: 'checkstyle'
apply plugin: 'pmd'
8
apply plugin: 'cpd'
akafred's avatar
akafred committed
9
apply plugin: 'com.github.ben-manes.versions'
10
apply plugin: 'gradle-one-jar'
11
apply plugin: 'com.bmuschko.docker-remote-api'
akafred's avatar
akafred committed
12 13 14 15 16 17 18 19 20

group = 'no.deichman.services'
version = '1.0-SNAPSHOT'
description = "services"

sourceCompatibility = 1.8
targetCompatibility = 1.8

compileJava.options.encoding = 'UTF-8'
21
compileTestJava.options.encoding = 'UTF-8'
akafred's avatar
akafred committed
22 23 24

repositories {
    mavenCentral()
25 26 27 28 29 30 31 32
    maven {
        url "http://xss-html-filter.sf.net/releases/"
        name "xss-html-filter.sf.net releases"
    }
    maven {
        url "https://maven.nuxeo.org/nexus/content/groups/public/"
        name "nexeo"
    }
akafred's avatar
akafred committed
33 34
}

35
configurations {
36 37 38 39 40 41
    // We're logging with slf4j api and log4j2 backend so all other backends must be removed
    all*.exclude group: 'log4j', module: 'log4j'
    all*.exclude group: 'org.slf4j', module: 'slf4j-nop'
    all*.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
    all*.exclude group: 'commons-logging'

42 43
}

44
def version_jetty = '9.4.2.v20170220'
45
def version_jersey = '2.22.1'
Rurik Greenall's avatar
Rurik Greenall committed
46
def version_jackson = '2.8.7'
Rurik Greenall's avatar
Rurik Greenall committed
47
def version_slf4j = '1.7.25'
48
def version_jena = '3.4.0'
49
def version_commons_lang = '3.5'
Rurik Greenall's avatar
Rurik Greenall committed
50
def version_commons_io = '2.5'
akafred's avatar
akafred committed
51 52 53 54 55 56 57 58 59 60

dependencies {

    compile group: 'org.eclipse.jetty', name: 'jetty-server', version: version_jetty
    compile group: 'org.eclipse.jetty', name: 'jetty-util', version: version_jetty
    compile group: 'org.eclipse.jetty', name: 'jetty-servlet', version: version_jetty
    compile group: 'org.glassfish.jersey.core', name: 'jersey-server', version: version_jersey
    compile group: 'org.glassfish.jersey.containers', name: 'jersey-container-servlet-core', version: version_jersey
    compile group: 'org.glassfish.jersey.containers', name: 'jersey-container-jetty-http', version: version_jersey
    compile group: 'org.glassfish.jersey.media', name: 'jersey-media-moxy', version: version_jersey
61 62
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: version_jackson
    compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-smile', version: version_jackson
akafred's avatar
akafred committed
63 64
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: version_jackson
    compile group: 'org.apache.jena', name: 'apache-jena-libs', version: version_jena
65
    compile group: 'commons-io', name: 'commons-io', version: version_commons_io
66
    compile group: 'org.apache.commons', name: 'commons-lang3', version: version_commons_lang
67
    compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'
68
    compile('info.freelibrary:freelib-marc4j:2.6.12') {
akafred's avatar
akafred committed
69 70
        transitive = false
    }
71
    compile group: 'com.google.guava', name: 'guava', version: '21.0'
72
    compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
akafred's avatar
akafred committed
73

74 75 76
    compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4+' // unirest has issues with 4.2
    compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.4+' // unirest has issues with 4.2
    compile group: 'org.apache.httpcomponents', name: 'httpclient-cache', version: '4.5+' // unirest has issues with 4.2
akafred's avatar
akafred committed
77

78 79 80 81
    // We're logging with slf4j api and log4j2 backend
    compile group: 'org.slf4j', name: 'slf4j-api', version: version_slf4j
    compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: version_slf4j
    compile group: 'org.slf4j', name: 'log4j-over-slf4j', version: version_slf4j
82 83
    compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.8.1'
    compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.8.1'
84
    compile group: 'com.jamonapi', name: 'jamon', version: '2.81'
85 86
    compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: version_jetty
    compile group: 'org.eclipse.jetty', name: 'jetty-annotations', version: version_jetty
87
    compile group: 'org.eclipse.jetty', name: 'apache-jsp', version: version_jetty
88
    compile group: 'com.jamonapi', name: 'fdsapi', version: '1.2'
89
    compile group: 'joda-time', name: 'joda-time', version: '2.9.7'
90

91
    testCompile group: 'junit', name: 'junit', version: '4.12'
Rurik Greenall's avatar
Rurik Greenall committed
92
    testCompile group: 'org.mockito', name: 'mockito-core', version: '2.7.19'
93
    testCompile group: 'com.github.rest-driver', name: 'rest-client-driver', version: '2.0.0'
94
    testCompile group: 'uk.co.datumedge', name: 'hamcrest-json', version: '0.2'
95

96
    testCompile group: 'com.mashape.unirest', name: 'unirest-java', version: '1.4.9'
97
    testCompile group: 'pl.allegro.tech', name: 'embedded-elasticsearch', version: '2.1.0'
akafred's avatar
akafred committed
98 99
}

100 101 102 103
task oneJar(type: OneJar) {
    mainClass = 'no.deichman.services.App'
}

akafred's avatar
akafred committed
104
task wrapper(type: Wrapper) {
Rurik Greenall's avatar
Rurik Greenall committed
105
    gradleVersion = '3.4.1'
akafred's avatar
akafred committed
106 107
}

108
check.dependsOn test
109 110 111

tasks.withType(Test) {
    reports.html.destination = file("${reporting.baseDir}/${name}")
112 113
    reports.junitXml.enabled = false
    reports.html.enabled = false
114 115
}

116
task allTestsExceptAppTest(type: Test) {
117 118 119
    exclude 'no/deichman/services/services/AppTest.class'
}

120
task testAppTest(type: Test) {
121 122 123 124 125 126 127
    include 'no/deichman/services/services/AppTest.class'
}

test {
    exclude '**'
}

128
test.dependsOn allTestsExceptAppTest, testAppTest
129

130 131
checkstyle {
    configProperties = [samedir: "${rootDir}"]
Rurik Greenall's avatar
Rurik Greenall committed
132
    toolVersion = '7.6'
133 134
}

akafred's avatar
akafred committed
135 136
pmd {
    consoleOutput = true
Rurik Greenall's avatar
Rurik Greenall committed
137
    toolVersion = '5.5.4'
akafred's avatar
akafred committed
138 139
}

140
cpd {
Rurik Greenall's avatar
Rurik Greenall committed
141
    toolVersion = '5.5.4'
142 143 144 145 146 147 148 149 150 151 152 153 154
    ignoreIdentifiers = true
    ignoreLiterals = true

    ignoreFailures = true // not failing the build for now
}

cpdCheck {
    reports {
        text.enabled = true
        xml.enabled = false
    }
}

akafred's avatar
akafred committed
155
buildscript {
156 157 158 159 160 161
    repositories {
        mavenCentral()
        maven { url '~/.m2/repository' }
        maven { url "https://plugins.gradle.org/m2/" }
        jcenter()
    }
akafred's avatar
akafred committed
162 163
    dependencies {
        classpath 'com.github.rholder:gradle-one-jar:1.0.4'
164
        classpath 'com.github.ben-manes:gradle-versions-plugin:0.14.0'
Rurik Greenall's avatar
Rurik Greenall committed
165
        classpath 'de.aaschmid:gradle-cpd-plugin:1.0'
166
        classpath 'com.bmuschko:gradle-docker-plugin:3.1.0'
akafred's avatar
akafred committed
167
    }
168 169 170 171 172 173 174 175 176 177 178 179 180 181
}

task resolveDependencies {
    doLast {
        project.rootProject.allprojects.each { subProject ->
            subProject.buildscript.configurations.each { configuration ->
                configuration.resolve()
            }
            subProject.configurations.each { configuration ->
                configuration.resolve()
            }
        }
    }
}
182 183 184 185 186 187 188 189 190 191 192 193 194

task copyJar(type: Copy) {
    dependsOn 'oneJar'
    from "build/libs/services-${project.version}-standalone.jar"
    into 'build/docker'
    rename { String fileName ->
        fileName.replace("-${project.version}", "")
    }
}

def getGitHash = { ->
    def stdout = new ByteArrayOutputStream()
    exec {
195
        ignoreExitValue = true
196 197 198 199 200 201 202 203 204 205 206 207 208 209
        commandLine 'git', 'rev-parse', 'HEAD'
        standardOutput = stdout
    }
    return stdout.toString().trim()
}

task buildDockerImage(type: DockerBuildImage) {
    dependsOn copyJar
    inputDir = file('.')
    tag = "digibib/redef-services:${getGitHash()}"
}

buildDockerImage.dependsOn copyJar