Skip to content

Commit

Permalink
feat(codegen): Generate and publish Java Proto generated artifacts (#2)
Browse files Browse the repository at this point in the history
* initial addition

* fix workflow

* add sdk stub

* exclude idp plugin
  • Loading branch information
ttschampel committed Mar 13, 2024
1 parent 0eedeb1 commit 2328fd2
Show file tree
Hide file tree
Showing 11 changed files with 474 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: "Checks"

on:
pull_request:
branches:
- main
push:
branches:
- main
merge_group:
branches:
- main
types:
- checks_requested

jobs:
pr:
name: Validate PR title
if: contains(fromJSON('["pull_request", "pull_request_target"]'), github.event_name)
runs-on: ubuntu-22.04
permissions:
pull-requests: read
steps:
- uses: amannn/action-semantic-pull-request@e9fabac35e210fea40ca5b14c0da95a099eff26f
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


mavenbuild:
runs-on: ubuntu-latest
if: always()
needs:
- pr
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: bufbuild/buf-setup-action@382440cdb8ec7bc25a68d7b4711163d95f7cc3aa
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '20'
distribution: 'adopt'
server-id: github
- name: Extract version
run: |
VERSION_HASH=$(git rev-parse --short HEAD)
if [[ "${{ github.ref_type }}" == "tag" ]]; then
VERSION=${{ github.ref_name }}
elif [[ "${{ github.ref_name }}" == "main" ]]; then
VERSION="main-SNAPSHOT"
else
BRANCH_NAME=$(echo ${{ github.ref_name }} | sed 's/\//-/g')
VERSION="dev-${BRANCH_NAME}-${VERSION_HASH}-SNAPSHOT"
fi
echo "Version=${VERSION}, GIT_SHA=${GIT_SHA}, Branch=${{ github.ref_name }}"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
id: info
- name: Run Maven Versions Plugin
run: mvn versions:set -DnewVersion=$VERSION
- name: Compile Java SDK
run: |
mvn clean deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ github.token }}



4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
protocol/src/main/protogen
/.idea/
/protocol/target/
/sdk/target/
14 changes: 14 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: v1
managed:
enabled: true
java_package_prefix:
default: io.opentdf.platform
except:
- buf.build/bufbuild/protovalidate
- buf.build/googleapis/googleapis
- buf.build/grpc-ecosystem/grpc-gateway
plugins:
- plugin: buf.build/protocolbuffers/java:v25.3
out: protocol/src/main/protogen
- plugin: buf.build/grpc/java:v1.61.1
out: protocol/src/main/protogen
209 changes: 209 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.opentdf.platform</groupId>
<artifactId>sdk-pom</artifactId>
<version>1.0-SNAPSHOT</version>
<name>sdk-pom</name>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- TODO: Move to new version of Java-->
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<log4j.version>2.20.0</log4j.version>
<grpc.version>1.57.2</grpc.version>
<protobuf.version>3.25.3</protobuf.version>
</properties>
<modules>
<module>protocol</module>
<module>sdk</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.opentdf.platform</groupId>
<artifactId>platform-client</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<failFast>false</failFast>
<rules>
<dependencyConvergence/>
<requireUpperBoundDeps/>
<requireSameVersions/>
<banDuplicatePomDependencyVersions/>
</rules>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<inherited>false</inherited>
<configuration>
<failFast>false</failFast>
<rules>
<requireMavenVersion>
<version>3.6.0</version>
<level>ERROR</level>
</requireMavenVersion>
<requireJavaVersion>
<version>${maven.compiler.target}</version>
<level>WARN</level>
</requireJavaVersion>
<dependencyConvergence/>
<requireUpperBoundDeps/>
<requireSameVersions/>
<requirePluginVersions/>
<banDuplicatePomDependencyVersions/>
<reactorModuleConvergence/>
</rules>
</configuration>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.6.0</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>ghcr</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<distributionManagement>
<repository>
<id>github</id>
<name>ghcr</name>
<url>https://maven.pkg.github.com/opentdf/java-sdk</url>
</repository>
<snapshotRepository>
<id>github</id>
<name>ghcr</name>
<url>https://maven.pkg.github.com/opentdf/java-sdk</url>
</snapshotRepository>
</distributionManagement>
</profile>

</profiles>
</project>

18 changes: 18 additions & 0 deletions protocol/buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: bufbuild
repository: protovalidate
commit: f05a6f4403ce4327bae4f50f281c3ed0
digest: shake256:668a0661b8df44d41839194896329330965fc215f3d2f88057fd60eeb759c2daf6cc6edfdd13b2a653d49fe2896ebedcb1a33c4c5b2dd10919f03ffb7fc52ae6
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 7e6f6e774e29406da95bd61cdcdbc8bc
digest: shake256:fe43dd2265ea0c07d76bd925eeba612667cf4c948d2ce53d6e367e1b4b3cb5fa69a51e6acb1a6a50d32f894f054a35e6c0406f6808a483f2752e10c866ffbf73
- remote: buf.build
owner: grpc-ecosystem
repository: grpc-gateway
commit: 3f42134f4c564983838425bc43c7a65f
digest: shake256:3d11d4c0fe5e05fda0131afefbce233940e27f0c31c5d4e385686aea58ccd30f72053f61af432fa83f1fc11cda57f5f18ca3da26a29064f73c5a0d076bba8d92
22 changes: 22 additions & 0 deletions protocol/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: v1
deps:
- buf.build/bufbuild/protovalidate
- buf.build/googleapis/googleapis
- buf.build/grpc-ecosystem/grpc-gateway
breaking:
use:
- FILE
- PACKAGE
- WIRE_JSON
- WIRE
lint:
allow_comment_ignores: true
use:
- DEFAULT
except:
- PACKAGE_VERSION_SUFFIX
ignore_only:
PACKAGE_VERSION_SUFFIX:
- google/api/annotations.proto
- google/api/http.proto
- google/protobuf/wrappers.proto
Loading

0 comments on commit 2328fd2

Please sign in to comment.