Skip to content

Commit

Permalink
chore: use gradle multi-projects
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyjames committed Mar 12, 2024
1 parent b79ab91 commit 87ceb30
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 63 deletions.
90 changes: 27 additions & 63 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,78 +1,42 @@
plugins {
id 'java-library'
id 'org.springframework.boot' version '3.2.2' apply false
id 'io.spring.dependency-management' version '1.1.4'

id 'java'
id 'com.diffplug.spotless' version '6.25.0'

id 'maven-publish'
}

group = "dev.openfga"
version = "0.0.1-SNAPSHOT"

java {
sourceCompatibility = 17
targetCompatibility = 17
}
subprojects {
apply plugin: 'java'
apply plugin: 'com.diffplug.spotless'

repositories {
mavenCentral()
}
group = "dev.openfga"
version = "0.0.1-SNAPSHOT"

test {
useJUnitPlatform()
}

dependencyManagement {
imports {
mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
java {
sourceCompatibility = 17
targetCompatibility = 17
}
}

dependencies {
implementation 'org.springframework.boot:spring-boot'
implementation 'org.springframework.boot:spring-boot-autoconfigure'
implementation 'org.springframework.boot:spring-boot-starter-security'

api 'dev.openfga:openfga-sdk:0.4.0'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation 'org.mockito:mockito-core:5.11.0'


}

publishing {
publications {
maven(MavenPublication) {
groupId = "${groupId}"
artifactId = 'openfga-spring-boot-starter'
version = "${version}"
repositories {
mavenCentral()
}

from components.java
spotless {
format 'misc', {
// define the files (e.g. '*.gradle', '*.md') to apply `misc` to
target '.gitignore', '*.gradle'
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
java {
palantirJavaFormat()
removeUnusedImports()
importOrder()
}
}
}

spotless {
format 'misc', {
// define the files (e.g. '*.gradle', '*.md') to apply `misc` to
target '.gitignore', '*.gradle'
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
tasks.register('fmt') {
dependsOn 'spotlessApply'
}
java {
palantirJavaFormat()
removeUnusedImports()
importOrder()
}
}

tasks.register('fmt') {
dependsOn 'spotlessApply'
}
11 changes: 11 additions & 0 deletions examples/servlet/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.2'
id 'io.spring.dependency-management' version '1.1.4'
id 'maven-publish'
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation project(':openfga-spring-boot-starter')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package dev.openfga.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ServletFgaApp {

public static void main(String[] args) {
SpringApplication.run(ServletFgaApp.class, args);
}
}
Empty file.
41 changes: 41 additions & 0 deletions openfga-spring-boot-starter/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
plugins {
id 'java-library'
id 'org.springframework.boot' version '3.2.2' apply false
id 'io.spring.dependency-management' version '1.1.4'
id 'maven-publish'
}

dependencyManagement {
imports {
mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
}
}

dependencies {
implementation 'org.springframework.boot:spring-boot'
implementation 'org.springframework.boot:spring-boot-autoconfigure'
implementation 'org.springframework.boot:spring-boot-starter-security'

api 'dev.openfga:openfga-sdk:0.4.0'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation 'org.mockito:mockito-core:5.11.0'
}

test {
useJUnitPlatform()
}

publishing {
publications {
maven(MavenPublication) {
groupId = "${groupId}"
artifactId = 'openfga-spring-boot-starter'
version = "${version}"

from components.java
}
}
}
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
rootProject.name = 'fga-spring-boot-starter'

include 'openfga-spring-boot-starter'
include 'examples:servlet'

0 comments on commit 87ceb30

Please sign in to comment.