-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DAT-641] Add measurement proto file (#1)
* [DAT-641] Add measurement proto file * Follow Style Guide * Update readme * Add gradle files * Add byte size test * Remove fixme from proto * Explicitly set elevation.isNull to true if single elevations are unset * Fix CI build
- Loading branch information
Showing
14 changed files
with
1,314 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Standard CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- release | ||
pull_request: | ||
branches: | ||
- main | ||
- release | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
|
||
- name: Download & unzip protoc | ||
run: | | ||
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.17.0/protoc-3.17.0-linux-x86_64.zip \ | ||
-O protoc-3.zip | ||
unzip protoc-3.zip -d protoc-3 | ||
mv protoc-3/bin/protoc protoc | ||
- name: Compile java files from `proto` file | ||
run: | | ||
mkdir -p src/main/java | ||
./protoc --java_out=./src/main/java/ src/main/protos/de/cyface/protos/model/measurement.proto | ||
- name: Build with Gradle | ||
run: ./gradlew build | ||
env: | ||
USERNAME: ${{ github.actor }} | ||
PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Publish to GitHub Packages | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
|
||
- name: Download & unzip protoc | ||
run: | | ||
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.17.0/protoc-3.17.0-linux-x86_64.zip \ | ||
-O protoc-3.zip | ||
unzip protoc-3.zip -d protoc-3 | ||
mv protoc-3/bin/protoc protoc | ||
- name: Compile java files from `proto` file | ||
run: | | ||
./protoc --java_out=./src/main/java/ src/main/protos/de/cyface/protos/model/measurement.proto | ||
# Publish slim JARS to Github Package Registry | ||
- name: Publish package | ||
run: ./gradlew publish | ||
env: | ||
USERNAME: ${{ github.actor }} | ||
PASSWORD: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Automatically mark this tag as release on Github | ||
- uses: actions/create-release@v1 | ||
id: create_release | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ github.ref }} | ||
draft: false | ||
# Release tags of format `1.2.3-beta1 / -alpha1 / -test1` are considered a pre-release | ||
prerelease: ${{ contains(github.ref, 'test') || contains(github.ref, 'alpha') || contains(github.ref, 'beta') }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# | ||
# Copyright 2018 Cyface GmbH | ||
# | ||
# This file is part of the Cyface Data Collector. | ||
# | ||
# The Cyface Data Collector is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# The Cyface Data Collector is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with the Cyface Data Collector. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# Eclipse Files | ||
.classpath | ||
.settings | ||
bin | ||
.project | ||
|
||
# Intellij Idea Files | ||
.idea | ||
.editorconfig | ||
out | ||
*.iml | ||
|
||
# Gradle Temporary Files | ||
.gradle | ||
build | ||
local.properties | ||
gradle.properties | ||
|
||
# Ignore local test maven repositories | ||
**/repo | ||
|
||
# Vim Temporary Files | ||
**/*.swp | ||
|
||
# Cyface Temporary Files | ||
**/file-uploads | ||
**/.vertx | ||
**/conf.json | ||
**/*.log | ||
**/secrets | ||
*.json | ||
|
||
# Generated java classes from proto files | ||
src/main/java/ | ||
|
||
# Temporary Git Files | ||
**/*.orig | ||
|
||
# Ignore logging configurations | ||
**/logback.xml | ||
|
||
# Vertx Config files | ||
**/config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
= Cyface Protocol Buffer Messages | ||
|
||
This repository defines the Cyface Models as schemas such as Protocol Buffer Schemas. | ||
This allows to de-/serialize the Cyface Binary Data from in different programming languages. | ||
|
||
For more details on Protocol Buffers (short: Protobuf) check out it's link:https://developers.google.com/protocol-buffers[documentation]. | ||
|
||
|
||
== Message Format Definitions | ||
|
||
This is a collection of `.proto` files describe the data structure of the Cyface Models. | ||
|
||
- This allows Protobuf to automatically de-/encode the the data from/to binary files. | ||
- Supports later extensions of the format with backward-compatibility | ||
- Following the link:https://developers.google.com/protocol-buffers/docs/style[Style Guide] | ||
|
||
At the time of writing the latest release is link:https://developers.google.com/protocol-buffers/docs/proto3[Protocol Buffer Version 3]. | ||
|
||
|
||
=== Notes | ||
Reminders from the documentation which need to be considered for future updates: | ||
|
||
- optional fields are default in proto3, `required` fields have been removed. | ||
|
||
- link:https://developers.google.com/protocol-buffers/docs/proto3#updating[Updating A Message Type] | ||
|
||
- link:https://developers.google.com/protocol-buffers/docs/javatutorial#extending-a-protocol-buffer[Extending a Protocol Buffer] | ||
|
||
- Deprecated field link:https://developers.google.com/protocol-buffers/docs/proto3#options[annotations] | ||
|
||
- link:https://developers.google.com/protocol-buffers/docs/proto3#default[Default values] | ||
|
||
- Scalar message fields, once parsed, cannot tell if a field was not set or set the the default value afterwards. | ||
- Default values are not serialized on the wire. | ||
- Keep this in mind when defining e.g. booleans, make sure you want that "default" `false` behavior on. | ||
|
||
Other message types: | ||
|
||
- link:https://developers.google.com/protocol-buffers/docs/proto3#using_oneof[One-of] if only one of many fields can be set / should be interpreted. link:https://developers.google.com/protocol-buffers/docs/proto3#backwards-compatibility_issues[Be careful] with these fields. | ||
- link:https://developers.google.com/protocol-buffers/docs/proto3#maps[Maps] | ||
- link:https://developers.google.com/protocol-buffers/docs/proto3#json[JSON Mapping] | ||
- There are also "well known" message types from Google, e.g. for `JSON` | ||
- link:https://developers.google.com/protocol-buffers/docs/javatutorial#advanced-usage[Reflections] | ||
|
||
|
||
== Compiling the Message Definitions | ||
|
||
Generates serializer, deserializer, etc. in a chosen language, e.g. `.java` files for Java. | ||
|
||
Java classes can be compiled with link:https://developers.google.com/protocol-buffers/docs/javatutorial#compiling-your-protocol-buffers[protoc] (Protocol Buffers `v3.17.0`): | ||
|
||
protoc --java_out=./src/main/java/ src/main/protos/de/cyface/protos/model/measurement.proto | ||
|
||
However, the pre-compiled `JARs` are also published to the link:https://github.com/orgs/cyface-de/packages?repo_name=protos[Github Package Registry]. | ||
|
||
- how to use with link:https://github.com/protocolbuffers/protobuf/tree/master/java#gradle[Gradle] | ||
- how to use with link:https://github.com/protocolbuffers/protobuf/tree/master/java#use-java-protocol-buffers-on-android[Android] | ||
|
||
The serializers encode the data in an efficient way, the decision process is documented link:https://cyface.atlassian.net/wiki/spaces/IM/pages/1535148033/Datenformat+bertragungsprotokoll+2021[internally]. | ||
|
||
|
||
== Using the generated Code | ||
|
||
____ | ||
Protocol Buffers and Object Oriented Design Protocol buffer classes are basically dumb data holders (like structs in C); they don't make good first class citizens in an object model. If you want to add richer behavior to a generated class, the best way to do this is to wrap the generated protocol buffer class in an application-specific class. | ||
____ | ||
link:https://developers.google.com/protocol-buffers/docs/javatutorial#builders[Source] | ||
|
||
|
||
[#_licensing] | ||
== Licensing | ||
|
||
Copyright (C) 2021 Cyface GmbH - All Rights Reserved | ||
Unauthorized copying of this file, via any medium is strictly prohibited | ||
Proprietary and confidential |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Copyright 2021 Cyface GmbH | ||
* | ||
* This file is part of the Cyface Protocol Buffer Messages. | ||
* | ||
* The Cyface Protocol Buffer Messages is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The Cyface Protocol Buffer Messages is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with the Cyface Protocol Buffer Messages. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
/** | ||
* The root build gradle file. | ||
* | ||
* @author Armin Schnabel | ||
*/ | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
} | ||
} | ||
|
||
plugins { | ||
id 'java' | ||
id 'application' | ||
id 'eclipse' | ||
id 'idea' | ||
id 'maven-publish' | ||
//noinspection SpellCheckingInspection | ||
id 'com.github.johnrengelman.shadow' version '6.1.0' apply false | ||
} | ||
|
||
group = 'de.cyface' | ||
version = '0.0.0' | ||
|
||
tasks.withType(JavaCompile) { | ||
options.encoding = 'UTF-8' | ||
|
||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
|
||
ext { | ||
commonsLangVersion = '3.8.1' | ||
gradleWrapperVersion = '6.8.3' | ||
protobufVersion = '3.17.0' | ||
|
||
// Versions of testing dependencies | ||
junitVersion = '5.7.0' | ||
mockitoVersion = '3.3.3' | ||
hamcrestVersion = '2.2' | ||
flapdoodleVersion = '3.0.0' | ||
} | ||
|
||
wrapper { | ||
gradleVersion = "$gradleWrapperVersion" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
// Code Quality Checker | ||
dependencies { | ||
// Protobuf generated java files | ||
implementation "com.google.protobuf:protobuf-java:$protobufVersion" | ||
|
||
// Utility | ||
implementation "org.apache.commons:commons-lang3:$commonsLangVersion" // Using Validate | ||
|
||
// Testing Dependencies | ||
testImplementation(platform("org.junit:junit-bom:$junitVersion")) | ||
testImplementation "org.junit.jupiter:junit-jupiter-api" | ||
//testImplementation "org.junit.jupiter:junit-jupiter-params" // Required for parameterized tests | ||
testImplementation "org.hamcrest:hamcrest:$hamcrestVersion" | ||
testImplementation "org.mockito:mockito-core:$mockitoVersion" | ||
testImplementation "org.mockito:mockito-junit-jupiter:$mockitoVersion" | ||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine" | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
testLogging { | ||
events "passed", "skipped", "failed" | ||
} | ||
} | ||
|
||
// Definitions for the maven-publish Plugin | ||
publishing { | ||
// The following repositories are used to publish artifacts to. | ||
repositories { | ||
maven { | ||
name = 'github' | ||
url = uri("https://maven.pkg.github.com/cyface-de/protos") | ||
credentials { | ||
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME") | ||
password = project.findProperty("gpr.key") ?: System.getenv("PASSWORD") | ||
} | ||
} | ||
maven { | ||
name = 'local' | ||
url = "file://${rootProject.buildDir}/repo" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
gpr.user=<GITHUB_USERNAME> | ||
gpr.key=<GITHUB_ACCESS_TOKEN> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.