Эх сурвалжийг харах

Setup Gradle multi-module build

Added core, config and samples modules. Moved sample project into samples module.

Closes gh-10
Eleftheria Stein 5 жил өмнө
parent
commit
5ed7c8f501

+ 1 - 1
.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

+ 17 - 13
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
 
-test {
-	useJUnitPlatform()
+subprojects {
+	plugins.withType(JavaPlugin) {
+		project.sourceCompatibility = '1.8'
+	}
 }

+ 1 - 0
config/spring-authorization-server-config.gradle

@@ -0,0 +1 @@
+apply plugin: 'io.spring.convention.spring-module'

+ 1 - 0
core/spring-authorization-server-core.gradle

@@ -0,0 +1 @@
+apply plugin: 'io.spring.convention.spring-module'

+ 11 - 0
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'
+	}
+}

+ 12 - 0
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()
+}

+ 0 - 0
src/main/java/sample/Application.java → samples/helloworld/src/main/java/sample/Application.java


+ 0 - 0
src/test/java/sample/ApplicationTest.java → samples/helloworld/src/test/java/sample/ApplicationTest.java


+ 15 - 0
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
+}