PAN-15 Created gradle tasks to start the persistence API and to start the API asynchronously

This commit is contained in:
dantanxiaotian
2019-03-10 19:58:04 -06:00
parent ffaf020b80
commit 46122cbafd
2 changed files with 32 additions and 5 deletions
+21 -5
View File
@@ -1,6 +1,20 @@
import java.util.concurrent.Callable
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
class RunAsyncTask extends DefaultTask {
String taskToExecute = ':persistence:startPersistenceApi'
@TaskAction
def startAsync() {
ExecutorService es = Executors.newSingleThreadExecutor()
es.submit({taskToExecute.execute()} as Callable)
}
}
buildscript {
repositories {
mavenCentral()
maven { url 'http://dl.bintray.com/vermeulen-mp/gradle-plugins' }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE")
@@ -15,6 +29,7 @@ plugins {
id "org.sonarqube" version "2.6"
id 'org.unbroken-dome.test-sets' version '1.4.5'
id 'war'
id "com.wiredforcode.spawn" version "0.8.2"
}
apply plugin: 'org.springframework.boot'
@@ -87,11 +102,6 @@ subprojects {
}
}
bootJar {
baseName = 'gs-spring-boot'
version = '0.1.0'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
@@ -136,6 +146,12 @@ testSets {
integrationTest
}
task startApi(type: RunAsyncTask) {
dependsOn ':persistence:loadDb'
dependsOn 'build'
taskToExecute = ':persistence:startPersistenceApi'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
+11
View File
@@ -3,6 +3,9 @@ plugins {
id 'java'
}
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.springframework.boot'
description = 'Provides database access and connectivity'
group 'edu.msudenver.tsp'
version '1.0'
@@ -50,3 +53,11 @@ task loadDb(type: Exec, group: 'Verification', description: 'Reloads the local d
commandLine=['cmd','/c','loaddb.bat']
}
}
task startPersistenceApi(type: JavaExec, description: 'Starts the Persistence API') {
dependsOn 'loadDb'
dependsOn 'build'
classpath = files('build/libs/persistence-1.0.jar')
classpath += sourceSets.main.runtimeClasspath
main = 'edu.msudenver.tsp.persistence.PersistenceApi'
}