From 5ed7c8f50159a923211c1f96c9388936d4aec903 Mon Sep 17 00:00:00 2001 From: Eleftheria Stein Date: Thu, 23 Apr 2020 15:37:17 -0400 Subject: [PATCH] Setup Gradle multi-module build Added core, config and samples modules. Moved sample project into samples module. Closes gh-10 --- .../continuous-integration-workflow.yml | 2 +- build.gradle | 30 +++++++++++-------- .../spring-authorization-server-config.gradle | 1 + core/spring-authorization-server-core.gradle | 1 + gradle/dependency-management.gradle | 11 +++++++ ...orization-server-samples-helloworld.gradle | 12 ++++++++ .../src}/main/java/sample/Application.java | 0 .../test/java/sample/ApplicationTest.java | 0 settings.gradle | 15 ++++++++++ 9 files changed, 58 insertions(+), 14 deletions(-) create mode 100644 config/spring-authorization-server-config.gradle create mode 100644 core/spring-authorization-server-core.gradle create mode 100644 gradle/dependency-management.gradle create mode 100644 samples/helloworld/spring-authorization-server-samples-helloworld.gradle rename {src => samples/helloworld/src}/main/java/sample/Application.java (100%) rename {src => samples/helloworld/src}/test/java/sample/ApplicationTest.java (100%) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 3b368747..e0c7964d 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -23,7 +23,7 @@ jobs: with: java-version: ${{ matrix.jdk }} - name: Build with Gradle - run: echo Starting build + run: ./gradlew clean build snapshot_tests: name: Test against snapshots runs-on: ubuntu-latest diff --git a/build.gradle b/build.gradle index 8bd97c3a..de09a73d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,24 +1,28 @@ -plugins { - id 'org.springframework.boot' version '2.2.6.RELEASE' - id 'io.spring.dependency-management' version '1.0.9.RELEASE' - id 'java' +buildscript { + dependencies { + classpath 'io.spring.gradle:spring-build-conventions:0.0.31.RELEASE' + classpath "org.springframework.boot:spring-boot-gradle-plugin:latest.release" + + } + repositories { + maven { url 'https://repo.spring.io/plugins-snapshot' } + maven { url 'https://plugins.gradle.org/m2/' } + } } +apply plugin: 'io.spring.convention.root' + group = 'org.springframework.experimental' version = '0.0.1-SNAPSHOT' -sourceCompatibility = '1.8' repositories { mavenCentral() } -dependencies { - implementation 'org.springframework.boot:spring-boot-starter' - testImplementation('org.springframework.boot:spring-boot-starter-test') { - exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' +dependencyManagementExport.projects = subprojects + +subprojects { + plugins.withType(JavaPlugin) { + project.sourceCompatibility = '1.8' } } - -test { - useJUnitPlatform() -} diff --git a/config/spring-authorization-server-config.gradle b/config/spring-authorization-server-config.gradle new file mode 100644 index 00000000..56dcd799 --- /dev/null +++ b/config/spring-authorization-server-config.gradle @@ -0,0 +1 @@ +apply plugin: 'io.spring.convention.spring-module' diff --git a/core/spring-authorization-server-core.gradle b/core/spring-authorization-server-core.gradle new file mode 100644 index 00000000..56dcd799 --- /dev/null +++ b/core/spring-authorization-server-core.gradle @@ -0,0 +1 @@ +apply plugin: 'io.spring.convention.spring-module' diff --git a/gradle/dependency-management.gradle b/gradle/dependency-management.gradle new file mode 100644 index 00000000..188db8e5 --- /dev/null +++ b/gradle/dependency-management.gradle @@ -0,0 +1,11 @@ +dependencyManagement { + imports { + mavenBom 'org.springframework:spring-framework-bom:latest.release' + } + + dependencies { + dependency 'junit:junit:latest.release' + dependency 'org.assertj:assertj-core:latest.release' + dependency 'org.mockito:mockito-core:latest.release' + } +} diff --git a/samples/helloworld/spring-authorization-server-samples-helloworld.gradle b/samples/helloworld/spring-authorization-server-samples-helloworld.gradle new file mode 100644 index 00000000..5300d84c --- /dev/null +++ b/samples/helloworld/spring-authorization-server-samples-helloworld.gradle @@ -0,0 +1,12 @@ +apply plugin: 'io.spring.convention.spring-sample-boot' + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter' + testImplementation('org.springframework.boot:spring-boot-starter-test') { + exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' + } +} + +test { + useJUnitPlatform() +} diff --git a/src/main/java/sample/Application.java b/samples/helloworld/src/main/java/sample/Application.java similarity index 100% rename from src/main/java/sample/Application.java rename to samples/helloworld/src/main/java/sample/Application.java diff --git a/src/test/java/sample/ApplicationTest.java b/samples/helloworld/src/test/java/sample/ApplicationTest.java similarity index 100% rename from src/test/java/sample/ApplicationTest.java rename to samples/helloworld/src/test/java/sample/ApplicationTest.java diff --git a/settings.gradle b/settings.gradle index f3915b5e..c2654bdc 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,16 @@ rootProject.name = 'spring-authorization-server' + +FileTree buildFiles = fileTree(rootDir) { + include '**/*.gradle' + exclude 'build', '**/gradle', 'settings.gradle', 'buildSrc', '/build.gradle', '.*', 'out' +} + +buildFiles.each { File buildFile -> + String projectName = buildFile.name.replace('.gradle', ''); + String projectPath = ':' + projectName; + include projectPath + def project = findProject("${projectPath}") + project.name = projectName + project.projectDir = buildFile.parentFile + project.buildFileName = buildFile.name +}