Skip to content

Commit ccbc933

Browse files
committed
as-package.sh support --fast
1 parent 41f489c commit ccbc933

File tree

3 files changed

+82
-3
lines changed

3 files changed

+82
-3
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Please refer to [README.MD at killercoda branch](https://github.com/alibaba/arth
2727
2828
Recommend to use [`as-package.sh`](as-package.sh) to package, which will auto-install the latest Arthas to local `~/.arthas` and when debugging, Arthas will auto-load the latest version.
2929

30+
Tip: for faster local iteration, you can use `./as-package.sh --fast` (skip `clean` and skip documentation front-end build in `site` module). If you need to rebuild docs, run without `--fast` or use `./mvnw clean package -DskipTests -P full`.
31+
3032
* To support jni, cpp compiling environment support is required
3133
* mac needs to install xcode
3234
* windows need to install gcc
@@ -92,6 +94,8 @@ Tip: you can use `--versions` to list all available versions.
9294

9395
本地开发时,推荐执行`as-package.sh`来打包,会自动安装最新版本的arthas到`~/.arthas`目录里。debug时会自动使用最新版本。
9496

97+
提示:本地快速迭代可以执行 `./as-package.sh --fast`(跳过 `clean`,并跳过 `site` 模块的文档前端构建)。如果需要重建文档,请不要使用 `--fast`,或者执行 `./mvnw clean package -DskipTests -P full`
98+
9599
* 代码里要编译jni,需要cpp编译环境支持
96100
* mac需要安装xcode
97101
* windows需要安装gcc

as-package.sh

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,65 @@
22

33
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
44

5+
usage() {
6+
cat <<EOF
7+
Usage: $(basename "$0") [options] [-- <extra mvn args>]
8+
9+
Options:
10+
--fast 本地快速打包:不执行 clean + 跳过 site 前端构建 + Maven 并行构建(-T 1C)
11+
--no-clean 不执行 Maven clean(保留各模块 target 缓存)
12+
--skip-site 跳过 site 模块的前端构建(vuepress/yarn),不影响默认打包产物
13+
-T, --threads <arg> 传给 Maven 的并行线程数(如 1C/4)
14+
-h, --help 显示帮助
15+
EOF
16+
}
17+
18+
NO_CLEAN=false
19+
SKIP_SITE=false
20+
MVN_THREADS=""
21+
MVN_EXTRA_ARGS=()
22+
23+
while [[ $# -gt 0 ]]; do
24+
case "$1" in
25+
--fast)
26+
NO_CLEAN=true
27+
SKIP_SITE=true
28+
[[ -z "${MVN_THREADS}" ]] && MVN_THREADS="1C"
29+
shift
30+
;;
31+
--no-clean)
32+
NO_CLEAN=true
33+
shift
34+
;;
35+
--skip-site)
36+
SKIP_SITE=true
37+
shift
38+
;;
39+
-T|--threads)
40+
if [[ $# -lt 2 ]]; then
41+
echo "Missing value for $1" 1>&2
42+
usage 1>&2
43+
exit 2
44+
fi
45+
MVN_THREADS="$2"
46+
shift 2
47+
;;
48+
-h|--help)
49+
usage
50+
exit 0
51+
;;
52+
--)
53+
shift
54+
MVN_EXTRA_ARGS+=("$@")
55+
break
56+
;;
57+
*)
58+
MVN_EXTRA_ARGS+=("$1")
59+
shift
60+
;;
61+
esac
62+
done
63+
564
get_local_maven_project_version()
665
{
766
"$DIR/mvnw" org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate \
@@ -33,7 +92,21 @@ exit_on_err()
3392
}
3493

3594
# maven package the arthas
36-
"$DIR/mvnw" clean package -Dmaven.test.skip=true -DskipTests=true -Dmaven.javadoc.skip=true -f $DIR/pom.xml \
95+
MVN_ARGS=(-f "$DIR/pom.xml" -Dmaven.test.skip=true -DskipTests=true -Dmaven.javadoc.skip=true)
96+
if [[ -n "${MVN_THREADS}" ]]; then
97+
MVN_ARGS+=(-T "${MVN_THREADS}")
98+
fi
99+
if [[ "${SKIP_SITE}" == "true" ]]; then
100+
MVN_ARGS+=(-Darthas.site.frontend.skip=true)
101+
fi
102+
if [[ "${NO_CLEAN}" == "true" ]]; then
103+
MVN_GOALS=(package)
104+
else
105+
MVN_GOALS=(clean package)
106+
fi
107+
108+
# maven package the arthas
109+
"$DIR/mvnw" "${MVN_ARGS[@]}" "${MVN_EXTRA_ARGS[@]}" "${MVN_GOALS[@]}" \
37110
|| exit_on_err 1 "package arthas failed."
38111

39112
rm -r "$DIR/core/src/main/resources/com/taobao/arthas/core/res/version"
@@ -46,4 +119,4 @@ unzip ${packaging_bin_path} -d "${NEWEST_ARTHAS_LIB_HOME}/"
46119

47120
# print ~/.arthas directory size
48121
arthas_dir_size="$(du -hs ${HOME}/.arthas | cut -f1)"
49-
echo "${HOME}/.arthas size: ${arthas_dir_size}"
122+
echo "${HOME}/.arthas size: ${arthas_dir_size}"

site/pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<node.download.url>https://npmmirror.com/mirrors/node/</node.download.url>
1818
<node.version>v16.13.2</node.version>
1919
<yarn.version>v1.22.15</yarn.version>
20+
<arthas.site.frontend.skip>false</arthas.site.frontend.skip>
2021
</properties>
2122

2223
<build>
@@ -75,6 +76,7 @@
7576
</execution>
7677
</executions>
7778
<configuration>
79+
<skip>${arthas.site.frontend.skip}</skip>
7880
<nodeVersion>${node.version}</nodeVersion>
7981
<yarnVersion>${yarn.version}</yarnVersion>
8082

@@ -85,4 +87,4 @@
8587
</plugin>
8688
</plugins>
8789
</build>
88-
</project>
90+
</project>

0 commit comments

Comments
 (0)