Skip to content

Commit

Permalink
- change versioning for JAlgoArena components
Browse files Browse the repository at this point in the history
- add docker image publishing to travis build
- move to plugins within gradle build
  • Loading branch information
spolnik committed Apr 28, 2018
1 parent f4a4429 commit 09e9af5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 39 deletions.
32 changes: 20 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
sudo: required
language: Java
services:
- docker
jdk:
- oraclejdk8
- oraclejdk8
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
cache:
directories:
- "$HOME/.gradle/caches/"
- "$HOME/.gradle/wrapper/"
before_deploy:
- "./gradlew releaseZip"
- "./gradlew releaseZip"
deploy:
provider: releases
api_key:
secure: szOvA8ebcgVLl6vSiHCm2xkAPZ/2Cpna8Gc2lrUkIzblFcoEtmKsySiKXYruLqGA7G7vjHG6zExfea60eGUyP5QRdRvj6M0I9nIJlkHzkNccgDVLoPjNY8U3M7xIgRPoDtZ5QHwnC+mtxmzeotvovk8GYUZNmthi1EjChXTrsy3WFFDK0zQ0R96YLH/1EJ+vwHn22LCZx03ZJC6tOU/D7uoRSj9BcuzO0lSuc8Lh/E9o8Oj7NxLLMgca113BCMcS6I2h5pt2j0Bghww2Kry7OLc8PjZuh4FHVhHfdb5sklr+CzSldR62y2aC8ILz3QdxyBocwAUNRqdJkBRZGEyMHmoyirEDWJY88W7AEdKW2RVkyCdd9Z7U811NTU81gsl7xFIN8N+M8hKvaYUA/9Yp75pR4wl6aS1rEM9mL9JsvlE9SoFa0xgCirnStJIXeVaIecSR9kldXUJPJSgVKS589L1cDRXSQNbfab03uVDBj5ykk6Driiz7wCvjuQQ6WYz+naKiImwgcgEoxbtGNRxZtYtXSM9EUMXHDNJIxn51ER6Nb41bPcS8Q49r595HdpgEvop3NegggS9fokkTIpAIllzKv43v2xbyVYQ/gfiQZn1L11OHaQL6u3JxGSYe11un/vanjI6PaMMP2I/Ypq33e4mJImY52hkD481pnniCzfM=
file_glob: true
file: "./build/libs/JAlgoArena-Eureka-*.zip"
skip_cleanup: true
on:
repo: spolnik/JAlgoArena-Eureka
tags: true
- provider: releases
api_key:
secure: szOvA8ebcgVLl6vSiHCm2xkAPZ/2Cpna8Gc2lrUkIzblFcoEtmKsySiKXYruLqGA7G7vjHG6zExfea60eGUyP5QRdRvj6M0I9nIJlkHzkNccgDVLoPjNY8U3M7xIgRPoDtZ5QHwnC+mtxmzeotvovk8GYUZNmthi1EjChXTrsy3WFFDK0zQ0R96YLH/1EJ+vwHn22LCZx03ZJC6tOU/D7uoRSj9BcuzO0lSuc8Lh/E9o8Oj7NxLLMgca113BCMcS6I2h5pt2j0Bghww2Kry7OLc8PjZuh4FHVhHfdb5sklr+CzSldR62y2aC8ILz3QdxyBocwAUNRqdJkBRZGEyMHmoyirEDWJY88W7AEdKW2RVkyCdd9Z7U811NTU81gsl7xFIN8N+M8hKvaYUA/9Yp75pR4wl6aS1rEM9mL9JsvlE9SoFa0xgCirnStJIXeVaIecSR9kldXUJPJSgVKS589L1cDRXSQNbfab03uVDBj5ykk6Driiz7wCvjuQQ6WYz+naKiImwgcgEoxbtGNRxZtYtXSM9EUMXHDNJIxn51ER6Nb41bPcS8Q49r595HdpgEvop3NegggS9fokkTIpAIllzKv43v2xbyVYQ/gfiQZn1L11OHaQL6u3JxGSYe11un/vanjI6PaMMP2I/Ypq33e4mJImY52hkD481pnniCzfM=
file_glob: true
file: "./build/libs/JAlgoArena-Eureka-*.zip"
skip_cleanup: true
on:
repo: spolnik/JAlgoArena-Eureka
tags: true
- provider: script
script: bash docker_push
on:
repo: spolnik/JAlgoArena-Eureka
tags: true
32 changes: 16 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
buildscript {
ext {
ext.kotlin_version = '1.2.31'
ext.spring_boot_version = '1.5.10.RELEASE'
}

repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${spring_boot_version}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}")
}
plugins {
id "org.jetbrains.kotlin.jvm" version "1.2.40"
id 'org.springframework.boot' version '1.5.10.RELEASE'
}

apply plugin: 'idea'
apply plugin: 'kotlin'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

apply from: "$rootDir/gradle/versioning.gradle"
Expand All @@ -29,7 +17,7 @@ jar {
}

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version",
compile "org.jetbrains.kotlin:kotlin-stdlib",
'org.springframework.cloud:spring-cloud-starter-hystrix-dashboard',
'org.springframework.cloud:spring-cloud-starter-eureka-server'
}
Expand All @@ -54,10 +42,22 @@ task releaseZip(type: Zip, dependsOn: 'bootRepackage') {
destinationDir(file('build/libs'))
}

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}

task buildDockerImage(type: Exec, dependsOn: 'bootRepackage') {
commandLine 'docker', 'build', '-t', "spolnik/${rootProject.name}:latest", '-t', "spolnik/${rootProject.name}:${version}", '.'
}

task pushDockerImages(type: Exec, dependsOn: 'buildDockerImage') {
commandLine 'docker', 'push', "spolnik/${rootProject.name}:latest"
commandLine 'docker', 'push', "spolnik/${rootProject.name}:${version}"
}

task runAsContainer(type: Exec, dependsOn: 'buildDockerImage') {
commandLine 'docker', 'container', 'run', '-d', '-p', '5000:5000', "spolnik/${rootProject.name}:${version}"
}
3 changes: 3 additions & 0 deletions docker_push
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
./gradlew pushDockerImages
14 changes: 3 additions & 11 deletions gradle/versioning.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//noinspection GroovyAssignabilityCheck
version = new ProjectVersion(
'2', '0', '1', System.env.TRAVIS_BUILD_NUMBER
'2', '0', System.env.TRAVIS_BUILD_NUMBER
)

println "Version number: " + version
Expand All @@ -9,23 +9,15 @@ class ProjectVersion {
String major
String minor
String patch
String build

ProjectVersion(String major, String minor, String patch, String build) {
ProjectVersion(String major, String minor, String patch) {
this.major = major
this.minor = minor
this.patch = patch
this.build = build
}

@Override
String toString() {
String fullVersion = "$major.$minor.$patch"

if (build) {
fullVersion += ".$build"
}

fullVersion
patch ? "$major.$minor.$patch" : "$major.$minor.0-SNAPSHOT"
}
}

0 comments on commit 09e9af5

Please sign in to comment.