Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
198 lines (169 sloc) 5.92 KB
buildscript {
repositories {
mavenCentral()
mavenLocal()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.bmuschko:gradle-docker-plugin:4.4.1'
classpath "com.github.ben-manes:gradle-versions-plugin:0.20.0"
}
}
plugins {
//id "com.github.hierynomus.license" version "0.14.0"
id 'net.researchgate.release' version '2.8.0'
//id 'com.github.kt3k.coveralls' version '2.8.2'
id "io.spring.dependency-management" version "1.0.6.RELEASE"
id "com.github.johnrengelman.shadow" version "4.0.4"
id "net.ltgt.apt-eclipse" version "0.21"
id "net.ltgt.apt-idea" version "0.21"
id "com.github.hierynomus.license" version "0.15.0"
}
group "wonky"
apply plugin: "application"
apply plugin: 'groovy'
apply plugin: 'jacoco'
apply plugin: com.bmuschko.gradle.docker.DockerRemoteApiPlugin
apply plugin: "com.github.ben-manes.versions"
ext {
email = 'domingo.suarez@gmail.com'
lombokVersion = '1.18.6'
groovyVersion = '2.5.6'
}
ext {
email = 'domingo.suarez@gmail.com'
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencyManagement {
imports {
mavenBom 'io.micronaut:micronaut-bom:1.1.0.M1'
}
}
configurations {
// for dependencies that are needed for development only
developmentOnly
}
dependencies {
//WARN: It's very important to preserve this order (https://github.com/micronaut-projects/micronaut-core/issues/218#issuecomment-392549294)
compileOnly "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "io.micronaut:micronaut-inject-java"
annotationProcessor "io.micronaut:micronaut-validation"
compile "io.micronaut:micronaut-http-client"
compile "io.micronaut:micronaut-http-server-netty"
compile "io.micronaut:micronaut-inject"
compile "io.micronaut:micronaut-validation"
compile "io.micronaut:micronaut-runtime"
compile "io.micronaut:micronaut-security"
compile "io.micronaut:micronaut-management"
compile "io.micronaut:micronaut-tracing"
//compile 'io.jaegertracing:jaeger-core:0.33.1'
compile 'commons-io:commons-io:2.6'
compile 'com.github.ben-manes.caffeine:caffeine:2.6.2'
compileOnly "io.micronaut:micronaut-inject-java"
compileOnly "org.codehaus.groovy:groovy-all:${groovyVersion}"
compileOnly "com.oracle.substratevm:svm"
runtime "ch.qos.logback:logback-classic:1.2.3"
runtime "io.micronaut:micronaut-graal"
runtime "io.jaegertracing:jaeger-thrift"
testAnnotationProcessor "io.micronaut:micronaut-inject-java"
testCompile "org.junit.jupiter:junit-jupiter-api"
testCompile "io.micronaut.test:micronaut-test-junit5"
testRuntime "org.junit.jupiter:junit-jupiter-engine"
testCompile 'org.apache.commons:commons-lang3:3.8.1'
testCompile "io.micronaut:micronaut-inject-java"
testCompile "org.codehaus.groovy:groovy-all:${groovyVersion}"
testCompile "org.spockframework:spock-core:1.3-RC1-groovy-2.5", {
exclude module: 'groovy-all'
}
}
shadowJar {
mergeServiceFiles()
}
mainClassName = "wonky.Application"
compileJava.options.compilerArgs += '-parameters'
compileTestJava.options.compilerArgs += '-parameters'
jacocoTestReport.dependsOn check
jacocoTestReport {
//We are running on Continuos Integration environment
def ci = System.getenv('CI') == "true"
reports {
xml.enabled ci
html.enabled !ci
}
}
run.classpath += configurations.developmentOnly
test.classpath += configurations.developmentOnly
run.jvmArgs('-noverify', '-XX:TieredStopAtLevel=1')
mainClassName = "wonky.Application"
tasks.withType(JavaCompile){
options.encoding = "UTF-8"
options.compilerArgs.add('-parameters')
}
task createDockerfile(type: com.bmuschko.gradle.docker.tasks.image.Dockerfile) {
destFile = project.file('build/libs/Dockerfile')
from 'openjdk:11.0.1-jre-slim'
def ci = System.getenv('CI') == "true"
def extra = ''
if(ci) {
extra = ' (CI builded)'
}
label(['maintainer': "Domingo Suarez Torres${ extra } <${ email }>"])
copyFile "wonky-${project.version}.jar", '/opt/service.jar'
exposePort 8080
entryPoint 'java', "-Djava.awt.headless=true", "-Xms128m", "-Xmx128m", '-jar', '/opt/service.jar'
}
task buildImage(type: com.bmuschko.gradle.docker.tasks.image.DockerBuildImage) {
dependsOn createDockerfile
inputDir = createDockerfile.destFile.get().asFile.parentFile
tags = ["domix/wonky:${project.version}".toLowerCase()]
}
task pushImage(type: com.bmuschko.gradle.docker.tasks.image.DockerPushImage) {
dependsOn buildImage
def im = buildImage.tags.get().first()
imageName = im
def ci = System.getenv('CI') == "true"
def enabledPush = true
if(ci && project.version.toString().toLowerCase().endsWith("snapshot")) {
enabledPush = false
}
enabled = enabledPush
println "Push enabled: ${enabled}"
}
createDockerfile.dependsOn assemble
docker {
registryCredentials {
username = (System.getenv('DOCKER_BUILDER_USERNAME') ?: (project.hasProperty('dockerRegistryUsername') ? dockerRegistryUsername : '')) ?: ''
password = (System.getenv('DOCKER_BUILDER_PASSWORD') ?: (project.hasProperty('dockerRegistryPassword') ? dockerRegistryPassword : '')) ?: ''
}
}
dependencyUpdates.resolutionStrategy {
componentSelection { rules ->
rules.all { ComponentSelection selection ->
boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm'].any { qualifier ->
selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
}
if (rejected) {
selection.reject('Release candidate')
}
}
}
}
license {
excludes(["**/*.html", "**/*.factories", "**/*.yaml", "**/*.yml", "**/*.xml", "**/*.css", '**/*.png'])
ext.year = Calendar.getInstance().get(Calendar.YEAR)
ext.name = 'Domingo Suarez Torres'
ext.email = 'domingo.suarez@gmail.com'
header rootProject.file('HEADER_LICENSE')
strictCheck true
}
classes.dependsOn licenseFormat
check.dependsOn licenseFormatTest
jacocoTestReport.dependsOn check
pushImage.dependsOn jacocoTestReport
createReleaseTag.dependsOn pushImage