From 46122cbafd1c7211635b07723d0324c2a50790ee Mon Sep 17 00:00:00 2001 From: dantanxiaotian Date: Sun, 10 Mar 2019 19:58:04 -0600 Subject: [PATCH] PAN-15 Created gradle tasks to start the persistence API and to start the API asynchronously --- build.gradle | 26 +++++++++++++++++++++----- persistence/build.gradle | 11 +++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 6690226..6c4a792 100644 --- a/build.gradle +++ b/build.gradle @@ -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" } diff --git a/persistence/build.gradle b/persistence/build.gradle index b832e7e..4672194 100644 --- a/persistence/build.gradle +++ b/persistence/build.gradle @@ -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' +}