From 98f3850c800bf1eb47fe31cf37ecd94c6fa20487 Mon Sep 17 00:00:00 2001 From: John Date: Wed, 10 Jul 2024 20:13:58 +0800 Subject: [PATCH] [Maven-project] Incorporate maven-proto-plugin into build of Maven projects (#535) * Add proto-maven-plugin for java-info * upgrade proto version adn patched optinal * split proto into a single package * modify proto java package name * use ascopes maven plugin and delete java code gen in buf.gen.yaml * Add ci for Java code-gen * modify code-gen command --- .github/workflows/format.yml | 124 ++++++++++++++++++----------------- .gitignore | 6 +- buf.gen.yaml | 4 +- format/adjacent_list.proto | 2 +- format/edge_info.proto | 2 +- format/enums.proto | 2 +- format/graph_info.proto | 2 +- format/property_group.proto | 2 +- format/vertex_info.proto | 2 +- maven-projects/info/pom.xml | 1 - maven-projects/pom.xml | 1 + maven-projects/proto/pom.xml | 81 +++++++++++++++++++++++ 12 files changed, 159 insertions(+), 70 deletions(-) create mode 100644 maven-projects/proto/pom.xml diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 0132b98ef..87f66de3c 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -1,59 +1,65 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -name: GraphAr Format - -on: - push: - branches: - - main - paths: - - 'format/**' - - '.github/workflows/format.yml' - - 'buf.gen.yaml' - - 'buf.yaml' - pull_request: - branches: - - main - paths: - - 'format/**' - - '.github/workflows/format.yml' - - 'buf.gen.yaml' - - 'buf.yaml' - -concurrency: - group: ${{ github.repository }}-${{ github.event.number || github.head_ref || github.sha }}-${{ github.workflow }} - cancel-in-progress: true - -jobs: - generate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - submodules: false - fetch-depth: 0 - - - uses: bufbuild/buf-setup-action@v1 - with: - version: "1.32.0" - - - name: Buf Generate - run: buf generate - \ No newline at end of file +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: GraphAr Format + +on: + push: + branches: + - main + paths: + - 'format/**' + - '.github/workflows/format.yml' + - 'buf.gen.yaml' + - 'buf.yaml' + pull_request: + branches: + - main + paths: + - 'format/**' + - '.github/workflows/format.yml' + - 'buf.gen.yaml' + - 'buf.yaml' + +concurrency: + group: ${{ github.repository }}-${{ github.event.number || github.head_ref || github.sha }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + generate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + submodules: false + fetch-depth: 0 + + - uses: bufbuild/buf-setup-action@v1 + with: + version: "1.32.0" + + - name: Buf Generate + run: buf generate + + - name: Java Code Generate + run: | + pushd maven-projects/proto + mvn protobuf:generate + popd + diff --git a/.gitignore b/.gitignore index 667cc9f7d..0d520ae44 100644 --- a/.gitignore +++ b/.gitignore @@ -68,4 +68,8 @@ venv.bak/ ### Scala ### *.bloop -*.metals \ No newline at end of file +*.metals + +### Java ### +target/ +maven-projects/proto/src/main/java \ No newline at end of file diff --git a/buf.gen.yaml b/buf.gen.yaml index 6405baa9f..9c4a91eb2 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -30,6 +30,4 @@ plugins: # Cpp - remote: buf.build/protocolbuffers/cpp:v27.1 out: cpp/proto - # Java - - remote: buf.build/protocolbuffers/java:v27.1 - out: maven-projects/info/src/main/java/ + # Java code well be generated by maven plugin \ No newline at end of file diff --git a/format/adjacent_list.proto b/format/adjacent_list.proto index da88ef2a5..8afb819e6 100644 --- a/format/adjacent_list.proto +++ b/format/adjacent_list.proto @@ -21,7 +21,7 @@ syntax = "proto3"; package graphar; option java_multiple_files = true; -option java_package = "org.apache.graphar.info.proto"; +option java_package = "org.apache.graphar.proto"; import "enums.proto"; diff --git a/format/edge_info.proto b/format/edge_info.proto index 12474545d..92bea800e 100644 --- a/format/edge_info.proto +++ b/format/edge_info.proto @@ -21,7 +21,7 @@ syntax = "proto3"; package graphar; option java_multiple_files = true; -option java_package = "org.apache.graphar.info.proto"; +option java_package = "org.apache.graphar.proto"; import "property_group.proto"; import "adjacent_list.proto"; diff --git a/format/enums.proto b/format/enums.proto index 234b9e863..9a132fe3d 100644 --- a/format/enums.proto +++ b/format/enums.proto @@ -21,7 +21,7 @@ syntax = "proto3"; package graphar; option java_multiple_files = true; -option java_package = "org.apache.graphar.info.proto"; +option java_package = "org.apache.graphar.proto"; enum DataType { BOOL = 0; diff --git a/format/graph_info.proto b/format/graph_info.proto index 7d11c956e..199a8dfcc 100644 --- a/format/graph_info.proto +++ b/format/graph_info.proto @@ -21,7 +21,7 @@ syntax = "proto3"; package graphar; option java_multiple_files = true; -option java_package = "org.apache.graphar.info.proto"; +option java_package = "org.apache.graphar.proto"; import "vertex_info.proto"; import "edge_info.proto"; diff --git a/format/property_group.proto b/format/property_group.proto index 23c28bcc6..bb3a70287 100644 --- a/format/property_group.proto +++ b/format/property_group.proto @@ -21,7 +21,7 @@ syntax = "proto3"; package graphar; option java_multiple_files = true; -option java_package = "org.apache.graphar.info.proto"; +option java_package = "org.apache.graphar.proto"; import "enums.proto"; diff --git a/format/vertex_info.proto b/format/vertex_info.proto index 99ec482f5..0efcd278f 100644 --- a/format/vertex_info.proto +++ b/format/vertex_info.proto @@ -21,7 +21,7 @@ syntax = "proto3"; package graphar; option java_multiple_files = true; -option java_package = "org.apache.graphar.info.proto"; +option java_package = "org.apache.graphar.proto"; import "property_group.proto"; diff --git a/maven-projects/info/pom.xml b/maven-projects/info/pom.xml index ea59280dd..f768e3c40 100644 --- a/maven-projects/info/pom.xml +++ b/maven-projects/info/pom.xml @@ -63,5 +63,4 @@ - \ No newline at end of file diff --git a/maven-projects/pom.xml b/maven-projects/pom.xml index 79d4b6617..bd2e0bc49 100644 --- a/maven-projects/pom.xml +++ b/maven-projects/pom.xml @@ -75,5 +75,6 @@ java spark info + proto diff --git a/maven-projects/proto/pom.xml b/maven-projects/proto/pom.xml new file mode 100644 index 000000000..6e95e77ad --- /dev/null +++ b/maven-projects/proto/pom.xml @@ -0,0 +1,81 @@ + + + + + 4.0.0 + + + org.apache.graphar + graphar-root + ${graphar.version} + ../pom.xml + + + proto + jar + 0.13.0.dev-SNAPSHOT + + proto + + + 11 + 11 + UTF-8 + 2.3.0 + 4.27.1 + + + + + com.google.protobuf + protobuf-java + ${protobuf.version} + compile + + + + + + + io.github.ascopes + protobuf-maven-plugin + ${protobuf-maven-plugin.version} + + + ${project.basedir}/../../format + + ${project.basedir}/src/main/java + ${protobuf.version} + + + + + generate + + + + + + + \ No newline at end of file