From cb0fa2cb1edc3ae149bef411def7db371c82ff22 Mon Sep 17 00:00:00 2001 From: Dmitriy Kopylenko Date: Thu, 15 Mar 2018 13:57:58 +0000 Subject: [PATCH] Merged in boot2 (pull request #11) Boot2 * Migrate to Spring Boot 2.0 * Finishing up Spring Boot 2.0 upgrade Approved-by: Dmitriy Kopylenko Approved-by: Jonathan Johnson --- backend/build.gradle | 55 ++++++++----------- .../admin/ui/ShibbolethUiApplication.java | 2 +- .../src/main/resources/application.properties | 11 +--- gradle.properties | 2 +- 4 files changed, 28 insertions(+), 42 deletions(-) diff --git a/backend/build.gradle b/backend/build.gradle index 592c49d82..d3d63c9ce 100644 --- a/backend/build.gradle +++ b/backend/build.gradle @@ -1,19 +1,11 @@ -buildscript { - repositories { - mavenCentral() - } - dependencies { - classpath "org.springframework.boot:spring-boot-gradle-plugin:1.5.7.RELEASE" - } -} - plugins { id 'java' id 'groovy' id 'war' + id 'org.springframework.boot' version '2.0.0.RELEASE' } -apply plugin: 'org.springframework.boot' +apply plugin: 'io.spring.dependency-management' sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -23,24 +15,21 @@ repositories { mavenCentral() } -//Integration of the frontend and backend into the build to have all of the UI resources available in the app's jar -jar.dependsOn(':ui:npm_run_buildProd') -jar { - from(tasks.findByPath(':ui:npm_run_buildProd').outputs) { - into 'public' - } -} -jar.baseName = 'shibui' processResources.dependsOn(':ui:npm_run_buildProd') -war.dependsOn(':ui:npm_run_buildProd') -war { +//Integration of the frontend and backend into the build to have all of the UI resources available in the app's executable war +bootWar.dependsOn(':ui:npm_run_buildProd') +bootWar { from(tasks.findByPath(':ui:npm_run_buildProd').outputs) { into '/' } archiveName = 'shibui.war' } -war.baseName = 'shibui' +bootWar.baseName = 'shibui' + +springBoot { + mainClassName = 'edu.internet2.tier.shibboleth.admin.ui.ShibbolethUiApplication' +} dependencies { // opensaml deps @@ -58,13 +47,18 @@ dependencies { compile "org.hibernate:${it}:${project.'hibernate.version'}" } - // spring boot plugins - ['starter-web', 'starter-actuator', 'starter-data-jpa', 'starter-security', 'devtools'].each { + // spring boot auto-config starters + ['starter-web', 'starter-data-jpa', 'starter-security', 'devtools'].each { compile "org.springframework.boot:spring-boot-${it}" } + providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' + compile "org.liquibase:liquibase-core" compile group: 'org.jadira.usertype', name: 'usertype.core', version: '6.0.1.GA' + //So it works on Java 9 without explicitly requiring to load that module (needed ny Hibernate) + runtimeOnly 'javax.xml.bind:jaxb-api:2.3.0' + // TODO: these will likely only be runtimeOnly or test scope, unless we want to ship the libraries with the final product compile "com.h2database:h2" runtimeOnly "org.postgresql:postgresql" @@ -148,14 +142,13 @@ task generateSources { } } -compileJava { - dependsOn generateSources +tasks.withType(JavaExec) { + // Assign all Java system properties from + // the command line to the JavaExec task which 'bootRun' task is a subclass of + // so we could pass -Dstyle.system.props=to-bootRun-task + systemProperties System.properties } -bootRun { - systemProperties = System.properties +compileJava { + dependsOn generateSources } - -bootRepackage { - mainClass = 'edu.internet2.tier.shibboleth.admin.ui.ShibbolethUiApplication' -} \ No newline at end of file diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/ShibbolethUiApplication.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/ShibbolethUiApplication.java index 52f2b6250..bffe130ad 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/ShibbolethUiApplication.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/ShibbolethUiApplication.java @@ -4,7 +4,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.support.SpringBootServletInitializer; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.scheduling.annotation.EnableScheduling; diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 458c2e0c4..edddaec0c 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -27,16 +27,9 @@ spring.h2.console.enabled=true #spring.datasource.driverClassName=org.mariadb.jdbc.Driver #spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect -#Tomcat specific DataSource props. Do we need these? -#spring.datasource.tomcat.maxActive=100 -#spring.datasource.tomcat.minIdle=10 -#spring.datasource.tomcat.maxIdle=10 -#spring.datasource.tomcat.initialSize=50 -#spring.datasource.tomcat.validationQuery=select 1 - # Liquibase properties -liquibase.enabled=false -#liquibase.change-log=classpath:edu/internet2/tier/shibboleth/admin/ui/database/masterchangelog.xml +spring.liquibase.enabled=false +#spring.liquibase.change-log=classpath:edu/internet2/tier/shibboleth/admin/ui/database/masterchangelog.xml # Hibernate properties # for production never ever use create, create-drop. It's BEST to use validate diff --git a/gradle.properties b/gradle.properties index 8e15f7661..90e1e24b3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,6 +4,6 @@ shibboleth.version=3.4.0-SNAPSHOT opensaml.version=3.4.0-SNAPSHOT xmltooling.version=1.4.7-SNAPSHOT -spring-boot.version=1.5.6.RELEASE +spring-boot.version=2.0.0.RELEASE hibernate.version=5.2.11.Final \ No newline at end of file