Skip to content

Commit

Permalink
chore: use gradle multi-projects and add example app stub (#21)
Browse files Browse the repository at this point in the history
<!-- Thanks for opening a PR! Here are some quick tips:
If this is your first time contributing, [read our Contributing
Guidelines](https://github.com/openfga/.github/blob/main/CONTRIBUTING.md)
to learn how to create an acceptable PR for this repo.
By submitting a PR to this repository, you agree to the terms within the
[OpenFGA Code of
Conduct](https://github.com/openfga/.github/blob/main/CODE_OF_CONDUCT.md)

If your PR is under active development, please submit it as a "draft".
Once it's ready, open it up for review.
-->

<!-- Provide a brief summary of the changes -->

## Description
<!-- Provide a detailed description of the changes -->

Sets up the start of an example app, and restructures the project to a
multi-project build so the example can use the starter as a dependency.

Structure is now:

```bash
fga-spring-boot-starter/
├─ build.gradle
examples/
├─ servlet/
│  ├─ build.gradle
build.gradle
```

## Review Checklist
- [x] I have clicked on ["allow edits by
maintainers"](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork).
- [ ] I have added documentation for new/changed functionality in this
PR or in a PR to [openfga.dev](https://github.com/openfga/openfga.dev)
[Provide a link to any relevant PRs in the references section above]
- [x] The correct base branch is being used, if not `main`
- [ ] I have added tests to validate that the change in functionality is
working as expected
  • Loading branch information
jimmyjames authored Mar 13, 2024
2 parents b79ab91 + 3a66fff commit 3d78847
Show file tree
Hide file tree
Showing 14 changed files with 93 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'
}
10 changes: 10 additions & 0 deletions examples/servlet/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.2'
id 'io.spring.dependency-management' version '1.1.4'
}

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 3d78847

Please sign in to comment.