Skip to content
This repository has been archived by the owner on Sep 13, 2020. It is now read-only.

Commit

Permalink
Migrate to Gradle builds (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gleb Kosteiko authored Jul 5, 2018
1 parent 0f960a8 commit 00ad053
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 129 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Exclude all files from target directory
target/
# Exclude all files from Gradle directories
.gradle
/build/

# Exclude all Idea related project files
.idea/
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ branches:
only:
- master

before_install: mvn package -DbuildNumber=$TRAVIS_BUILD_NUMBER
before_install: gradle clean release -DbuildNumber=$TRAVIS_BUILD_NUMBER

before_deploy:
- export TRAVIS_TAG="1.$TRAVIS_BUILD_NUMBER"
Expand All @@ -23,7 +23,7 @@ deploy:
api_key: $GITHUB_TOKEN
file_glob: true
file:
- target/tweetsched-cron-1.$TRAVIS_BUILD_NUMBER.jar
- build/dist/tweetsched-cron-1.$TRAVIS_BUILD_NUMBER.zip
on:
branch: master
repo: Tweetsched/tweetsched-cron
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
Cron jobs service for the Scheduled Tweets service.

## Requirements:
- Java 8 or higher
- Maven 3.3.3 or higher
- Java 8 or higher
- Gradle 4.8 or higher

## How to build:
`mvn clean package -DbuildNumber=<<<desired_number_of_build>>>`
`gradle release -DbuildNumber=<<<desired_number_of_build>>>`

## How to run locally:
- Configure next app properties in "tweetsched.properties" file:
- Configure next app properties in "tweetsched.properties" file:
- CRON_EXPRESSION (optional)
- REDIS_URL
- REDIS_PORT
Expand All @@ -22,4 +22,5 @@ Cron jobs service for the Scheduled Tweets service.
- OAUTH_CONSUMER_SECRET
- OAUTH_ACCESS_TOKEN
- OAUTH_ACCESS_TOKEN_SECRET
- Run `java -jar target/tweetsched-cron-1.<<<desired_number_of_build>>>.jar`
- Copy "tweetsched.properties" file to folder with jar file
- Run `java -jar build/libs/tweetsched-cron-1.<<<desired_number_of_build>>>.jar`
70 changes: 70 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
apply plugin: 'java'

group 'gk.tweetsched'
version '1.' + System.getProperty("buildNumber")

def fatJarFolder = 'build/libs/'
def distFolder = 'build/dist'
def tempDistFolder = 'build/tmp-dist/'
def configFolder = 'config/'
def startupShFileName = 'startup.sh'
def startupScript =
"""#!/bin/bash
nohup java -jar tweetsched-cron-${version}.jar &
PID=\$!
echo \$PID > pid.txt
"""

repositories {
mavenCentral()
}

test {
useTestNG() {
useDefaultListeners = true
suites 'src/test/resources/testng.xml'
}
}

task fatJar(type: Jar, dependsOn: test) {
manifest {
attributes 'Main-Class': 'gk.tweetsched.cron.TweetschedCronTrigger'
}
baseName = project.name
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}

task copyJar(dependsOn: fatJar, type: Copy) {
from fatJarFolder
into tempDistFolder
}

task copyConf(dependsOn: copyJar, type: Copy) {
from configFolder
into tempDistFolder
}

task release(dependsOn: copyConf, type: Zip) {
doFirst {
def startupFile = new File(tempDistFolder + startupShFileName)
startupFile.text = startupScript
}
from tempDistFolder
into project.name
destinationDir file(distFolder)
}

dependencies {
compile 'org.springframework:spring-core:5.0.6.RELEASE'
compile 'org.springframework:spring-context:5.0.6.RELEASE'
compile 'redis.clients:jedis:2.9.0'
compile 'org.twitter4j:twitter4j-core:4.0.6'
compile 'com.google.code.gson:gson:2.8.5'
compile 'org.apache.logging.log4j:log4j-core:2.11.0'
compile 'org.apache.logging.log4j:log4j-api:2.11.0'
testCompile 'org.testng:testng:6.14.3'
testCompile 'org.mockito:mockito-all:1.10.19'
}
2 changes: 1 addition & 1 deletion tweetsched.properties → config/tweetsched.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ OAUTH_CONSUMER_KEY=
OAUTH_CONSUMER_SECRET=
OAUTH_ACCESS_TOKEN=
OAUTH_ACCESS_TOKEN_SECRET=
CRON_EXPRESSION=
CRON_EXPRESSION=0 */30 0-3 * * *
114 changes: 0 additions & 114 deletions pom.xml

This file was deleted.

1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'tweetsched-cron'
5 changes: 0 additions & 5 deletions start.sh

This file was deleted.

0 comments on commit 00ad053

Please sign in to comment.