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

Cleaned up build.gradle structure #59

Merged
merged 1 commit into from
Nov 1, 2023
Merged
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
16 changes: 14 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
// Copyright (c) 2022 AlertAvert.com. All rights reserved.
// Author: Marco Massenzio ([email protected])

// Minimalist build file just to get things going.
// See jwt-opa/build.gradle for the "real" build.
plugins {
id 'java'
id 'jacoco'
}

ext {
// For the most recent version of the JWT-OPA library see:
// https://github.com/massenz/jwt-opa/releases
// This is likely to be the development, unreleased version.
jwtOpaVersion = "0.12.0"

awsSdkVersion = '2.17.102'
jsonpathVersion = "2.5.0"
lombokVersion = "1.18.30"
minCoverageRatio = 0.80
mockitoVersion = "3.6.0"
tcVersion = "1.19.1"
}
2 changes: 1 addition & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
opa:
container_name: "opa"
hostname: opa
image: openpolicyagent/opa:0.42.2
image: openpolicyagent/opa:0.58.0
command: run --server --addr :8181
ports:
- "8181:8181"
Expand Down
12 changes: 2 additions & 10 deletions jwt-opa/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
*/

plugins {
id 'io.spring.dependency-management' version '1.1.3'
id 'java'
id 'jacoco'
id 'io.spring.dependency-management' version '1.1.3'
id 'org.springframework.boot' version '3.1.5'

// To upload the Artifact to Maven Central
Expand All @@ -28,17 +28,9 @@ plugins {
id 'signing'
}

ext {
awsSdkVersion = '2.17.102'
jsonpathVersion = "2.5.0"
lombokVersion = "1.18.22"
minCoverageRatio = 0.80
mockitoVersion = "3.6.0"
tcVersion = "1.15.1"
}

group 'com.alertavert'
version '0.11.0'
version "${jwtOpaVersion}"

// OpenJDK 17 LTS is the only Java version supported
sourceCompatibility = JavaVersion.VERSION_17
Expand Down
10 changes: 9 additions & 1 deletion run-example.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# Copyright (c) 2021 AlertAvert.com. All rights reserved.
# Copyright (c) 2021-2023 AlertAvert.com. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# http://www.apache.org/licenses/LICENSE-2.0
#
Expand All @@ -13,6 +13,14 @@ OPA_SERVER=http://localhost:${OPA_PORT}
POLICY_API=${OPA_SERVER}/v1/policies/userauth

docker compose --project-name jwt-opa up -d

# Sometimes the OPA server takes a while to start, so we wait for it to be ready
READY=""
while [[ -z ${READY} ]]; do
echo "Waiting for OPA server to start..."
sleep 1
READY=$(docker logs opa 2>&1 | grep "Initializing server.")
done
if [[ $(curl -s ${POLICY_API} | jq .result.id) != "userauth" ]]; then
echo "Uploading userauth Policy"
curl -T "${WORKDIR}/webapp-example/src/main/rego/jwt_auth.rego" -X PUT ${POLICY_API}
Expand Down
31 changes: 10 additions & 21 deletions webapp-example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,29 @@
plugins {
id 'java'
id 'jacoco'
id 'org.springframework.boot' version '3.1.5'
id 'io.spring.dependency-management' version '1.1.3'
id 'org.springframework.boot' version '3.1.5'
}

group 'com.alertavert.opademo'
version = "0.4.0"
group 'com.alertavert'
version = "0.5.0"

repositories {
// Adding local repository for Gradle to find jwt-opa before it gets published.
// Use: ./gradlew :jwt-opa:publishToMavenLocal
// mavenLocal()
mavenLocal()
mavenCentral()
}

ext {
// This can be changed to an yet-unpublished version by using mavenLocal()
// for local tests.
jwtOpaVersion = "0.10.0"
lombokVersion = "1.18.22"
tcVersion = "1.15.1"
awsSdkVersion = '2.17.102'
}

bootJar {
mainClass.set('com.alertavert.opademo.JwtDemoApplication')
}

dependencies {
// We use the actual dependency here, instead of depending on the module in the repository so
// as to emulate an actual project using jwt-opa externally.
// Uncomment the following line (and comment out the one below) to use the local version
// while developing.
implementation project (':jwt-opa')
// implementation "com.alertavert:jwt-opa:${jwtOpaVersion}"
// ----- IMPORTANT -----
// If you modify the following line, make sure to also update the `build.gradle` file in the
// `test-released` branch, so that the CI tests can run against the released version.
// We depend here on the the local version here, so we can verify changes while developing:
implementation project (':jwt-opa')
// ----- SECTION ENDS -----

// For the @PostConstruct annotation
implementation 'javax.annotation:javax.annotation-api:1.3.2'
Expand Down
2 changes: 1 addition & 1 deletion webapp-example/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ keys:
# For a PASSPHRASE, the secret is simply read from SecretsManager/Vault
# The keypair is stored as a JSON-formatted secret, with two keys: "priv" and "pub".
location: keypair
name: private/ec-key
name: ../private/ec-key

logging:
level:
Expand Down
Loading