Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davidmoten/flatbuffers
Maven artifacts containing compiled flatbuffers binaries and flatbuffers-java runtime library
https://github.com/davidmoten/flatbuffers
Last synced: 17 days ago
JSON representation
Maven artifacts containing compiled flatbuffers binaries and flatbuffers-java runtime library
- Host: GitHub
- URL: https://github.com/davidmoten/flatbuffers
- Owner: davidmoten
- License: apache-2.0
- Created: 2016-02-21T08:50:59.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-22T09:51:19.000Z (3 months ago)
- Last Synced: 2024-10-14T07:45:56.195Z (30 days ago)
- Language: Java
- Homepage:
- Size: 36.3 MB
- Stars: 56
- Watchers: 6
- Forks: 14
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# flatbuffers
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.davidmoten/flatbuffers-parent/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/com.github.davidmoten/flatbuffers-parent)Maven artifacts for use with [flatbuffers](https://github.com/google/flatbuffers).
For years the Google flatbuffers project team did not publish artifacts of any sort for flatbuffers to repositories like Maven Central. Users were expected to build from source. In May 2021 Google started publishing the built artifacts as downloads from their [releases](https://github.com/google/flatbuffers/releases) page but did not wrap them as Maven artifacts. This project shortcuts these actions for you and allows you to do all using Maven artifacts from Maven Central.
* Supports flatbuffers 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.10, 1.12, 2.0.3
* Supports Java 1.6+ (Java 8 for 1.10+)Status: *released to Maven Central*
## Versioning
The artifacts carry versions like 1.6.0.3 which correspond to a 0.3 release of the flatbuffers [1.6.0 release](https://github.com/google/flatbuffers/releases/tag/v1.6.0) (from google).Current versions:
| flatbuffers-compiler, flatbuffers-java | Supports |
| ----------------------------------------- | -------- |
| 1.3.0.1 | 1.3 |
| 1.4.0.1 | 1.4 |
| 1.5.0.3 | 1.5 |
| 1.6.0.3 | 1.6 |
| 1.7.0.1 | 1.7 |
| 1.8.0.1 | 1.8 |
| 1.10.0.2 | 1.10 |
| 1.12.0.1 | 1.12 |
| 2.0.3.2 | 2.0.3 |
| 2.0.8 | 2.0.8 |## flatbuffers-compiler
Contains compiled binaries to generate java classes (and other) from flatbuffers schema files:* linux (x86 64-bit) (*tar.gz* artifact)
* osx (*tar.gz* artifact) (from 1.6, 1.7 will be supported in 1.7.0.2+)
* windows (*zip* artifact)This artifact is used with *maven-dependency-plugin* to unpack, *maven-exec-plugin* to execute and *build-helper-maven-plugin* to add the generated source to the build path. See [example project](example) for details.
## flatbuffers-java
Runtime library artifact for use with flatbuffers generated java classes.```xml
com.google.flatbuffers
flatbuffers-java
2.0.3```
## Example usage
See [example project](example) which is also used to unit test the artifacts.Essentially you add this block of xml to the build/plugins section of your pom.xml to generate flatbuffers classes (java):
```xml
org.apache.maven.plugins
maven-dependency-plugin
2.10
unpack
generate-sources
unpack
com.github.davidmoten
flatbuffers-compiler
2.0.3.1
tar.gz
distribution-linux
true
${project.build.directory}
org.codehaus.mojo
exec-maven-plugin
1.6.0
exec
generate-sources
${project.build.directory}/bin/flatc
${fbs.sources}
--java
--gen-mutable
-o
${fbs.generated.sources}
monster.fbs
org.codehaus.mojo
build-helper-maven-plugin
3.1.0
add-source
generate-sources
add-source
${fbs.generated.sources}
```
If you run the build on different operating systems, you can use kr.motd.maven:os-maven-plugin Maven extension to make
Maven download binaries specifically for your operating system.```xml
kr.motd.maven
os-maven-plugin
1.7.1
org.apache.maven.plugins
maven-dependency-plugin
2.10
unpack
generate-sources
unpack
com.github.davidmoten
flatbuffers-compiler
2.0.3.1
tar.gz
distribution-${os.detected.name}
true
${project.build.directory}
```
There are a couple of properties mentioned in the xml block above. I set them to these values for my projects:
```xml
${basedir}/src/main/fbs
${project.build.directory}/generated-sources/java```
To use the generated classes you'll need the runtime dependency *flatbuffers-java*. Add the following to the dependencies section in pom.xml:
```xml
com.github.davidmoten
flatbuffers-java
1.12.0.1```
## How to build the binaries that are placed in this artifact
You don't need to do this (it's why this artifact exists!):Note that google now makes available the binaries for each platform at [https://github.com/google/flatbuffers/releases]. Just download them from there and replace the zip files in flatbuffers-compiler/bin.
```bash
sudo apt-get install cmake
git clone https://github.com/google/flatbuffers.git
git checkout vN.N.N## for flatbuffers < 1.9.0
cd flatbuffers
mkdir build
cd build
cmake ..## for flatbuffers >= 1.9.0 on xenial
cmake .
make
mkdir bin
cp flat* bin
cp libflat* bin
```
The `flatbuffers/build/bin` directory now contains the binaries that are placed in the bin directory of this artifact.In addition, the java source classes need to be copied from `flatbuffers/java`(google repo) into `flatbuffers/flatbuffers-java/src/main/java`.
To generate java sources manually here's an example:
```bash
cd src/fbs
../../bin/flatc --java --gen-mutable -o ../../target/generated-sources/java monster.fbs
```### For project maintainers
To update this project with executables for a new version of flatbuffers:
* copy the files in `flatbuffers/build/bin` above to `flatbuffers-compiler/bin/linux/`
* download `flatc_windows_exe.zip` from [releases](https://github.com/google/flatbuffers/releases), unpack it and copy `flatc.exe` to `flatbuffers-compiler/bin/windows/`
* update the google flatbuffers-java dependency in example/pom.xml to latest
* build and release!