This is an automated email from the ASF dual-hosted git repository.

jinsongzhou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/amoro.git


The following commit(s) were added to refs/heads/master by this push:
     new c6f319021 [AMORO-3968] Update the thrift api compile command to use 
amoro shaded thrift (#3967)
c6f319021 is described below

commit c6f319021cff99fb21d7db58c658a9e8cc6bb046
Author: Fei Wang <[email protected]>
AuthorDate: Tue Nov 25 00:24:44 2025 -0800

    [AMORO-3968] Update the thrift api compile command to use amoro shaded 
thrift (#3967)
    
    * relocate generated thrift code to use amoro shaded thrift
    
    * docs
    
    * save
    
    * profile
---
 amoro-common/pom.xml                   | 59 +++++++++++++++++++++++++++-------
 amoro-common/src/main/thrift/README.md | 45 ++++++++++++++++++++++++++
 2 files changed, 93 insertions(+), 11 deletions(-)

diff --git a/amoro-common/pom.xml b/amoro-common/pom.xml
index 8d13c5b6e..c637dc198 100644
--- a/amoro-common/pom.xml
+++ b/amoro-common/pom.xml
@@ -168,17 +168,6 @@
                 </executions>
             </plugin>
 
-            <!--Compile thrift api with commend: mvnw thrift:compile -pl 
amoro-common-->
-            <plugin>
-                <groupId>org.apache.thrift.tools</groupId>
-                <artifactId>maven-thrift-plugin</artifactId>
-                <version>${maven-thrift-plugin.version}</version>
-                <configuration>
-                    <outputDirectory>src/main/gen-java</outputDirectory>
-                    <thriftSourceRoot>src/main/thrift</thriftSourceRoot>
-                    <generator>java</generator>
-                </configuration>
-            </plugin>
             <plugin>
                 <groupId>com.diffplug.spotless</groupId>
                 <artifactId>spotless-maven-plugin</artifactId>
@@ -193,4 +182,52 @@
         </plugins>
         <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
     </build>
+
+    <profiles>
+        <!--Compile thrift api with commend: ./mvnw -pl amoro-common 
-Pthrift-gen generate-sources -->
+        <profile>
+            <id>thrift-gen</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.thrift.tools</groupId>
+                        <artifactId>maven-thrift-plugin</artifactId>
+                        <version>${maven-thrift-plugin.version}</version>
+                        <configuration>
+                            
<outputDirectory>src/main/gen-java</outputDirectory>
+                            
<thriftSourceRoot>src/main/thrift</thriftSourceRoot>
+                            <generator>java</generator>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>thrift-compile</id>
+                                <goals>
+                                    <goal>compile</goal>
+                                </goals>
+                                <phase>generate-sources</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-antrun-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>relocate-thrift-package</id>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                                <phase>generate-sources</phase>
+                                <configuration>
+                                    <target>
+                                        <!-- Rewrite Thrift classes to use 
shaded thrift package -->
+                                        <replace dir="src/main/gen-java" 
includes="**/*.java" token="org.apache.thrift" 
value="org.apache.amoro.shade.thrift.org.apache.thrift"></replace>
+                                    </target>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
 </project>
diff --git a/amoro-common/src/main/thrift/README.md 
b/amoro-common/src/main/thrift/README.md
new file mode 100644
index 000000000..9c2ec1f93
--- /dev/null
+++ b/amoro-common/src/main/thrift/README.md
@@ -0,0 +1,45 @@
+<!--
+ - 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.
+-->
+
+## Thrift API
+
+### Install Thrift
+
+To build and install the thrift compiler, run:
+
+```
+wget -nv https://archive.apache.org/dist/thrift/0.20.0/thrift-0.20.0.tar.gz
+tar xzf thrift-0.20.0.tar.gz
+cd thrift-0.20.0
+chmod +x ./configure
+./configure --disable-libs
+sudo make install -j
+```
+
+If you're on OSX and use homebrew, you can instead install Thrift 0.20.0 with 
`brew` and ensure that it comes first in your `PATH`.
+
+```
+brew install thrift
+export PATH="/usr/local/opt/[email protected]/bin:$PATH"
+```
+
+### Compile Thrift
+
+```shell
+./mvnw -pl amoro-common -Pthrift-gen generate-sources
+```

Reply via email to