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

oxsean pushed a commit to branch 3.3
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.3 by this push:
     new 067dc8dce9 Add build scripts for faster local compilation (#14618)
067dc8dce9 is described below

commit 067dc8dce9b65656991183dc39cad065caabb59b
Author: Sean Yang <[email protected]>
AuthorDate: Tue Sep 3 22:30:11 2024 +0800

    Add build scripts for faster local compilation (#14618)
    
    - Add MAVEN_OPTS to improve build performance
    - Implement incremental build and caching
    - Add options for clean, install, compile, test, and spotless goals
    - Allow specifying modules and profiles
    - Improve help messages and usage instructions
    - Unify build script behavior across Windows and Unix-like systems
---
 .mvn/extensions.xml                   |  24 +++++++
 .mvn/maven-build-cache-config.xml     |  33 +++++++++
 .mvn/wrapper/maven-wrapper.properties |   2 +-
 build                                 | 125 ++++++++++++++++++++++++++++++++++
 build.cmd                             | 113 ++++++++++++++++++++++++++++++
 5 files changed, 296 insertions(+), 1 deletion(-)

diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml
new file mode 100644
index 0000000000..6a0b72799a
--- /dev/null
+++ b/.mvn/extensions.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+  -->
+<extensions>
+    <extension>
+        <groupId>org.apache.maven.extensions</groupId>
+        <artifactId>maven-build-cache-extension</artifactId>
+        <version>1.2.0</version>
+    </extension>
+</extensions>
diff --git a/.mvn/maven-build-cache-config.xml 
b/.mvn/maven-build-cache-config.xml
new file mode 100644
index 0000000000..3e7fc5ddb4
--- /dev/null
+++ b/.mvn/maven-build-cache-config.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+  -->
+<cache xmlns="http://maven.apache.org/BUILD-CACHE-CONFIG/1.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/BUILD-CACHE-CONFIG/1.0.0 
https://maven.apache.org/xsd/build-cache-config-1.0.0.xsd";>
+    <configuration>
+        <enabled>false</enabled>
+    </configuration>
+    <input>
+        <global>
+            <includes>
+                <include>src/main</include>
+            </includes>
+            <excludes>
+                <exclude>pom.xml</exclude>
+                <exclude>.flattened-pom.xml</exclude>
+            </excludes>
+        </global>
+    </input>
+</cache>
diff --git a/.mvn/wrapper/maven-wrapper.properties 
b/.mvn/wrapper/maven-wrapper.properties
index ca5ab4bab1..b252b8d0e2 100755
--- a/.mvn/wrapper/maven-wrapper.properties
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -14,5 +14,5 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
 
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar
diff --git a/build b/build
new file mode 100644
index 0000000000..624d05d257
--- /dev/null
+++ b/build
@@ -0,0 +1,125 @@
+#!/bin/sh
+
+#
+# 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.
+#
+
+set -eu
+
+cd "$(dirname "$0")"
+
+export MAVEN_OPTS="\
+-Xms2g \
+-Xmx2g \
+-XX:+UseG1GC \
+-XX:InitiatingHeapOccupancyPercent=45 \
+-XX:+UseStringDeduplication \
+-XX:-TieredCompilation \
+-XX:TieredStopAtLevel=1 \
+-Dmaven.build.cache.enabled=true \
+-Dmaven.build.cache.lazyRestore=true \
+-Dmaven.compiler.useIncrementalCompilation=false \
+-Dmaven.test.skip=true \
+-Dcheckstyle.skip=true \
+-Dcheckstyle_unix.skip=true \
+-Drat.skip=true \
+-Dmaven.javadoc.skip=true
+"
+
+CMD="./mvnw -e --batch-mode --no-snapshot-updates --fail-fast -T 2C"
+ARGS=""
+MODULES=""
+PROFILES="sources,skip-spotless"
+DEFAULT_MODULES="dubbo-distribution/dubbo-all,dubbo-spring-boot/dubbo-spring-boot-starter"
+
+print_help() {
+    echo "Usage: $0 [options]"
+    echo "Fast local compilation with incremental build and caching"
+    echo "Options:"
+    echo "  -c    Execute clean goal (removes build artifacts)"
+    echo "  -i    Execute install goal (builds and installs the project)"
+    echo "  -p    Execute compile goal (compiles the source code)"
+    echo "  -t    Execute test goal (runs the tests)"
+    echo "  -s    Execute spotless:apply (format the code)"
+    echo "  -d    Execute dependency:tree (displays the dependency tree)"
+    echo "  -m    Specify modules, default is $DEFAULT_MODULES"
+    echo "  -f    Specify profiles, default is $PROFILES"
+    echo "  -h    Display this help message"
+    echo ""
+    echo "Examples:"
+    echo "  $0 -ci                    Execute clean, install goals"
+    echo "  $0 -s                     Execute spotless:apply"
+    echo "  $0 -t -m dubbo-config     Execute test goal for dubbo-config 
module"
+    echo "  $0 -cp -m dubbo-common    Execute clean, compile the dubbo-common 
module"
+    echo "  $0 -d                     Display the dependency tree"
+    exit 0
+}
+
+while getopts ":ciptdsm:f:h" opt; do
+  case $opt in
+    c)
+      ARGS="$ARGS clean"
+      ;;
+    i)
+      ARGS="$ARGS install"
+      ;;
+    p)
+      ARGS="$ARGS compile"
+      ;;
+    t)
+      ARGS="$ARGS test"
+      export MAVEN_OPTS=$(echo "$MAVEN_OPTS" | sed 
's/-Dmaven\.test\.skip=true/-Dmaven.test.skip=false/')
+      ;;
+    d)
+      ARGS="$ARGS dependency:tree"
+      ;;
+    s)
+      ARGS="$ARGS spotless:apply"
+      PROFILES="sources"
+      ;;
+    m)
+      MODULES="-pl $OPTARG -am"
+      ;;
+    f)
+      PROFILES="$OPTARG"
+      ;;
+    h)
+      print_help
+      ;;
+    *)
+      if [ "$OPTARG" = "m" ]; then
+        MODULES=" -pl $DEFAULT_MODULES -am"
+      else
+        echo "Error: Unknown option -$OPTARG" >&2
+        print_help
+        exit 1
+      fi
+      ;;
+  esac
+done
+
+shift $((OPTIND -1))
+
+if [ -z "$ARGS" ] && [ -z "$@" ]; then
+  ARGS="install"
+fi
+
+if [ -n "$@" ]; then
+  ARGS="$ARGS $@"
+fi
+
+set -x
+$CMD $ARGS$MODULES -P $PROFILES
diff --git a/build.cmd b/build.cmd
new file mode 100644
index 0000000000..64e94f44e0
--- /dev/null
+++ b/build.cmd
@@ -0,0 +1,113 @@
+@REM 
----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one or more
+@REM contributor license agreements.  See the NOTICE file distributed with
+@REM this work for additional information regarding copyright ownership.
+@REM The ASF licenses this file to You under the Apache License, Version 2.0
+@REM (the "License"); you may not use this file except in compliance with
+@REM the License.  You may obtain a copy of the License at
+@REM
+@REM     http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM Unless required by applicable law or agreed to in writing, software
+@REM distributed under the License is distributed on an "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM See the License for the specific language governing permissions and
+@REM limitations under the License.
+@REM 
----------------------------------------------------------------------------
+
+@echo off
+setlocal enabledelayedexpansion
+
+set MAVEN_OPTS=^
+-Xms2g ^
+-Xmx2g ^
+-XX:+UseG1GC ^
+-XX:InitiatingHeapOccupancyPercent=45 ^
+-XX:+UseStringDeduplication ^
+-XX:-TieredCompilation ^
+-XX:TieredStopAtLevel=1 ^
+-Dmaven.build.cache.enabled=true ^
+-Dmaven.build.cache.lazyRestore=true ^
+-Dmaven.compiler.useIncrementalCompilation=false ^
+-Dcheckstyle.skip=true ^
+-Dcheckstyle_unix.skip=true ^
+-Drat.skip=true ^
+-Dmaven.javadoc.skip=true
+
+set CMD=mvnw.cmd -e --batch-mode --no-snapshot-updates --fail-fast -T 2C
+set ARGS=
+set MODULES=
+set PROFILES=sources,skip-spotless
+set 
DEFAULT_MODULES=dubbo-distribution/dubbo-all,dubbo-spring-boot/dubbo-spring-boot-starter
+set TEST_SKIP=true
+
+goto parse_args
+
+:print_help
+echo Usage: %0 [options]
+echo Fast local compilation with incremental build and caching
+echo Options:
+echo   -c    Execute clean goal (removes build artifacts)
+echo   -i    Execute install goal (builds and installs the project)
+echo   -p    Execute compile goal (compiles the source code)
+echo   -t    Execute test goal (runs the tests)
+echo   -s    Execute spotless:apply (format the code)
+echo   -d    Execute dependency:tree (displays the dependency tree)
+echo   -m    Specify modules, default is %DEFAULT_MODULES%
+echo   -f    Specify profiles, default is %PROFILES%
+echo   -h    Display this help message
+echo.
+echo Examples:
+echo   %0 -c -i                    Execute clean, install goals
+echo   %0 -s                       Execute spotless:apply
+echo   %0 -t -m dubbo-config       Execute test goal for dubbo-config module
+echo   %0 -c -p -m dubbo-common    Execute clean, compile the dubbo-common 
module
+echo   %0 -d                       Display the dependency tree
+exit /b
+
+:parse_args
+set ARG=%~1
+if "%ARG%"=="" goto check_args
+if "%ARG%"=="-c" set ARGS=%ARGS% clean
+if "%ARG%"=="-i" set ARGS=%ARGS% install
+if "%ARG%"=="-p" set ARGS=%ARGS% compile
+if "%ARG%"=="-t" (
+    set ARGS=%ARGS% test
+    set TEST_SKIP=false
+)
+if "%ARG%"=="-s" (
+    set ARGS=%ARGS% spotless:apply
+    set PROFILES=sources
+)
+if "%ARG%"=="-d" set ARGS=%ARGS% dependency:tree
+    if "%ARG%"=="-m" (
+    if "%~2"=="" (
+        set MODULES= -pl %DEFAULT_MODULES% -am
+    ) else (
+        set MODULES= -pl %~2 -am
+        shift
+    )
+)
+if "%ARG%"=="-f" (
+    set PROFILES=%~2
+    shift
+)
+if "%ARG%"=="-h" goto print_help
+if "%ARG:~0,1%" neq "-" (
+    set ARGS=%ARGS% %ARG%
+)
+shift
+goto parse_args
+
+:check_args
+if "%TEST_SKIP%"=="true" (
+    set MAVEN_OPTS=%MAVEN_OPTS% -Dmaven.test.skip=true
+)
+if "%ARGS%"=="" (
+    set ARGS= install
+)
+
+@echo on
+%CMD%%ARGS%%MODULES% -P %PROFILES%
+
+endlocal

Reply via email to