diff --git a/.drone.yml b/.drone.yml index cbaa0aa..451710a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -27,9 +27,9 @@ steps: from_secret: docker_password dockerfile: docker/Dockerfile context: docker/ - when: - branch: master - event: push + when: + branch: master + event: push - name: deploy_and_restart image: appleboy/drone-ssh diff --git a/.gitignore b/.gitignore index 7de50b0..22c1a07 100644 --- a/.gitignore +++ b/.gitignore @@ -87,6 +87,7 @@ cmake-build-release/ # IntelliJ out/ +build/ # mpeltonen/sbt-idea plugin .idea_modules/ diff --git a/README.md b/README.md index a96b9c7..7b681e3 100644 --- a/README.md +++ b/README.md @@ -29,5 +29,11 @@ to the same folder and rename it to **secrets.env** ``` 11. Send `/start` command to your bot +### Develop run + +1. Run `docker-compose up` to launch PostgreSQL database +2. Set env `TELEGRAM_TOKEN="YOUR_TOKEN"` +3. Run `Boot.scala` app + diff --git a/api/build.gradle b/api/build.gradle index 4100376..3329f79 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -1,7 +1,7 @@ dependencies { - compile project(':common') + implementation project(':common') - compile group: "org.scalaj", name: "scalaj-http_2.12", version: "2.4.2" - compile group: "org.json4s", name: "json4s-jackson_2.12", version: "3.6.0-M3" - compile group: "com.softwaremill.quicklens", name: "quicklens_2.12", version: "1.4.12" + api "org.scalaj:scalaj-http_$scala:2.4.2" + api "org.json4s:json4s-jackson_$scala:3.6.0-M3" + api "com.softwaremill.quicklens:quicklens_$scala:1.4.12" } diff --git a/bot/build.gradle b/bot/build.gradle index e31c7e4..646f77f 100644 --- a/bot/build.gradle +++ b/bot/build.gradle @@ -1,6 +1,5 @@ dependencies { - compile project(':common') + implementation project(':common') - compile group: "com.bot4s", name: "telegram-core_2.12", version: "5.6.0" - compile group: "com.bot4s", name: "telegram-akka_2.12", version: "5.6.0" + api "com.bot4s:telegram-akka_$scala:5.6.0" } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 4e92fd1..a1d1dc9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,49 +1,24 @@ -group = 'com.lbs' - -ext { - scalaVersion = "2.12.8" +plugins { + id "com.github.maiflai.scalatest" version "0.32" + id "org.springframework.boot" version "2.7.2" } allprojects { - group = 'com.lbs' -} - -apply plugin: 'idea' - -subprojects { - - idea { - module { - downloadSources = true - } - } + apply plugin: "scala" + apply plugin: "java-library" + apply plugin: "com.github.maiflai.scalatest" repositories { mavenCentral() - jcenter() - maven { url 'https://repo.spring.io/libs-milestone' } + maven { url "https://repo.spring.io/libs-milestone" } } - apply plugin: 'java' - apply plugin: 'scala' - dependencies { - compile group: 'org.scala-lang', name: "scala-library", version: scalaVersion + compileOnly "org.scala-lang:scala-library:$scala.$scala_minor" - testCompile('org.scalatest:scalatest_2.12:3.0.4') - testCompile('org.mockito:mockito-core:2.13.0') - testCompile('org.pegdown:pegdown:1.6.0') + testImplementation "org.scalatest:scalatest_$scala:3.0.4" + + testImplementation "org.mockito:mockito-core:2.13.0" + testImplementation "org.pegdown:pegdown:1.6.0" } - - task scalaTest(dependsOn: ['testClasses'], type: JavaExec) { - main = 'org.scalatest.tools.Runner' - args = ['-R', "build/classes/scala/test", - '-u', "build/test-results/$name", - '-h', "build/resports/scalaTests/$name", - '-o' - ] - classpath = sourceSets.test.runtimeClasspath - } - - test.dependsOn scalaTest -} \ No newline at end of file +} diff --git a/common/build.gradle b/common/build.gradle index adfb9e2..c8b27d5 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,6 +1,5 @@ dependencies { - compile group: "org.slf4j", name: "slf4j-api", version: "1.7.25" - compile group: "ch.qos.logback", name: "logback-classic", version: "1.2.3" - compile group: "ch.qos.logback", name: "logback-core", version: "1.2.3" - compile("org.typelevel:cats-core_2.12:2.0.0-M1") + api "org.slf4j:slf4j-api:1.7.25" + api "ch.qos.logback:logback-classic:1.2.3" + api "org.typelevel:cats-core_$scala:2.0.0-M1" } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..cf261aa --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3.4' +services: + database: + image: postgres:10.6 + ports: + - "5432:5432" + environment: + - POSTGRES_USER=lbs + - POSTGRES_PASSWORD=lsb123 + - POSTGRES_DB=lbs + - TZ=Europe/Warsaw diff --git a/gradle.properties b/gradle.properties index 6452a29..68e7962 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,7 @@ org.gradle.daemon=true org.gradle.parallel=true org.gradle.configureondemand=true -org.gradle.jvmargs=-Dfile.encoding=UTF-8 \ No newline at end of file +org.gradle.jvmargs=-Dfile.encoding=UTF-8 + +scala=2.12 +scala_minor=16 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d8bd030..92b665a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip diff --git a/server/build.gradle b/server/build.gradle index e52773b..3ba7fd5 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -1,39 +1,26 @@ -buildscript { - ext { - springBootVersion = '2.1.1.RELEASE' - } - repositories { - mavenCentral() - jcenter() - } - dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") - } -} - -apply plugin: 'java' -apply plugin: 'scala' -apply plugin: 'org.springframework.boot' -apply plugin: 'io.spring.dependency-management' +apply plugin: "org.springframework.boot" +apply plugin: "io.spring.dependency-management" dependencies { - compile project(':api') - compile project(':bot') - compile project(':common') + implementation project(":api") + implementation project(":bot") + implementation project(":common") - compile('com.lihaoyi:sourcecode_2.12:0.1.4') + implementation "com.lihaoyi:sourcecode_$scala:0.1.4" - compile('org.springframework.boot:spring-boot-starter') - compile('org.springframework.boot:spring-boot-starter-data-jpa') - compile('org.liquibase:liquibase-core') + implementation "org.springframework.boot:spring-boot-starter" + implementation "org.springframework.boot:spring-boot-starter-data-jpa" + implementation "org.liquibase:liquibase-core" - compile('org.jasypt:jasypt:1.9.2') - compile('org.postgresql:postgresql:42.2.1.jre7') + implementation "org.jasypt:jasypt:1.9.2" + implementation "org.postgresql:postgresql:42.2.26" - testImplementation('com.typesafe.akka:akka-testkit_2.12:2.6.19') - testImplementation('org.springframework.boot:spring-boot-starter-test') - testImplementation('com.h2database:h2') - runtime group: "org.jetbrains.kotlin", name: "kotlin-stdlib", version: "1.4.10" + testImplementation "com.typesafe.akka:akka-testkit_$scala:2.6.19" + testImplementation "org.springframework.boot:spring-boot-starter-test" + testImplementation "com.h2database:h2" + + // fixme: remove junit + testImplementation 'junit:junit:4.13.2' } task prepare(type: Copy) { diff --git a/server/src/main/resources/application.yml b/server/src/main/resources/application.yml index b5eca2e..5746b19 100644 --- a/server/src/main/resources/application.yml +++ b/server/src/main/resources/application.yml @@ -13,6 +13,8 @@ spring: generate-ddl: "false" liquibase: change-log: classpath:db/liquibase-changelog.yml + main: + allow-circular-references: true banner: location: "classpath:/banner.txt"