Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move src folder to subproject #69

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 61 additions & 59 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,85 +1,87 @@
plugins {
id 'java-library'
id 'org.springframework.boot' version "${springBootVersion}" apply false
id 'java'
id 'io.spring.dependency-management' version "${springDependencyManagementVersion}"

// quality
id 'com.diffplug.spotless' version '6.25.0'
id 'jacoco'
id 'com.diffplug.spotless' version '6.25.0' apply false

// Publishing
id 'maven-publish'
id 'signing'
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
}

apply from: 'publish.gradle'
subprojects {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'io.spring.dependency-management'

group = 'dev.openfga'
version = '0.0.1'
// quality
apply plugin: 'com.diffplug.spotless'
apply plugin: 'jacoco'

java {
sourceCompatibility = 17
targetCompatibility = 17
apply from: "$rootDir/publish.gradle"

withJavadocJar()
withSourcesJar()
}
group = 'dev.openfga'
version = '0.0.1'

repositories {
mavenCentral()
}
java {
sourceCompatibility = 17
targetCompatibility = 17

dependencyManagement {
imports {
mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
withJavadocJar()
withSourcesJar()
}
}

dependencies {
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'

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'
repositories {
mavenCentral()
}

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'
}
dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
}
}

test {
useJUnitPlatform()
}
test {
useJUnitPlatform()
}

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()
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()
}
}
java {
palantirJavaFormat()
removeUnusedImports()
importOrder()

test {
finalizedBy jacocoTestReport // report is always generated after tests run
}
}

test {
finalizedBy jacocoTestReport // report is always generated after tests run
}
jacocoTestReport {
// tests are required to run before generating a JaCoCo coverage report.
dependsOn test
}

jacocoTestReport {
// tests are required to run before generating a JaCoCo coverage report.
dependsOn test
tasks.register('fmt') {
dependsOn 'spotlessApply'
}
}

tasks.register('fmt') {
dependsOn 'spotlessApply'
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri('https://s01.oss.sonatype.org/service/local/'))
snapshotRepositoryUrl.set(uri('https://s01.oss.sonatype.org/content/repositories/snapshots/'))
username.set(System.getenv('MAVEN_USERNAME'))
password.set(System.getenv('MAVEN_PASSWORD'))
}
}
}
16 changes: 16 additions & 0 deletions openfga-spring-boot-starter/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
description = 'This is the Spring Boot Starter for OpenFGA.'

dependencies {
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'

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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
@EnableConfigurationProperties(OpenFgaProperties.class)
public class OpenFgaAutoConfiguration {

private final OpenFgaProperties openFgaProperties;

public OpenFgaAutoConfiguration(OpenFgaProperties openFgaProperties) {
this.openFgaProperties = openFgaProperties;
@Bean
@ConditionalOnMissingBean(OpenFgaConnectionDetails.class)
PropertiesOpenFgaConnectionDetails openFgaConnectionDetails(OpenFgaProperties openFgaProperties) {
return new PropertiesOpenFgaConnectionDetails(openFgaProperties);
}

@Bean
@ConditionalOnMissingBean
public ClientConfiguration fgaConfig() {
public ClientConfiguration fgaConfig(OpenFgaProperties properties, OpenFgaConnectionDetails connectionDetails) {
var credentials = new Credentials();

var credentialsProperties = openFgaProperties.getCredentials();
var credentialsProperties = properties.getCredentials();

if (credentialsProperties != null) {
if (OpenFgaProperties.CredentialsMethod.API_TOKEN.equals(credentialsProperties.getMethod())) {
Expand All @@ -54,9 +54,9 @@ public ClientConfiguration fgaConfig() {
}

return new ClientConfiguration()
.apiUrl(openFgaProperties.getApiUrl())
.storeId(openFgaProperties.getStoreId())
.authorizationModelId(openFgaProperties.getAuthorizationModelId())
.apiUrl(connectionDetails.getApiUrl())
.storeId(properties.getStoreId())
.authorizationModelId(properties.getAuthorizationModelId())
.credentials(credentials);
}

Expand All @@ -75,4 +75,18 @@ public OpenFgaClient fgaClient(ClientConfiguration configuration) {
public OpenFga fga(OpenFgaClient openFgaClient) {
return new OpenFga(openFgaClient);
}

static class PropertiesOpenFgaConnectionDetails implements OpenFgaConnectionDetails {

private final OpenFgaProperties openFgaProperties;

public PropertiesOpenFgaConnectionDetails(OpenFgaProperties openFgaProperties) {
this.openFgaProperties = openFgaProperties;
}

@Override
public String getApiUrl() {
return this.openFgaProperties.getApiUrl();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package dev.openfga.autoconfigure;

import org.springframework.boot.autoconfigure.service.connection.ConnectionDetails;

public interface OpenFgaConnectionDetails extends ConnectionDetails {

String getApiUrl();
}
17 changes: 4 additions & 13 deletions publish.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

publishing {
publications {
maven(MavenPublication) {
from components.java

pom {
group = 'dev.openfga'
name = 'openfga-spring-boot-starter'
version = '0.0.1'
description = 'This is the Spring Boot Starter for OpenFGA.'

url = 'https://openfga.dev'
licenses {
license {
Expand Down Expand Up @@ -47,14 +49,3 @@ signing {
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.maven
}

nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri('https://s01.oss.sonatype.org/service/local/'))
snapshotRepositoryUrl.set(uri('https://s01.oss.sonatype.org/content/repositories/snapshots/'))
username.set(System.getenv('MAVEN_USERNAME'))
password.set(System.getenv('MAVEN_PASSWORD'))
}
}
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = 'openfga-spring-boot-starter'
include 'openfga-spring-boot-starter'
Loading