Repository navigation
118 lines (103 loc) · 5.02 KB
/
Copy pathmain.yml
File metadata and controls
118 lines (103 loc) · 5.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Build BlackBox VMecha AAR - Final v10
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Force Downgrade Wrapper
run: |
find . -name "*.gradle" -exec sed -i 's/jcenter()//g' {} +
find . -name "*.gradle" -exec sed -i 's/jCenter()//g' {} +
mkdir -p gradle/wrapper
wget -O gradle/wrapper/gradle-wrapper.jar https://github.com/gradle/gradle/raw/v8.0.0/gradle/wrapper/gradle-wrapper.jar
cat > gradle/wrapper/gradle-wrapper.properties << 'EOF'
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
EOF
wget -O gradlew https://github.com/gradle/gradle/raw/v8.0.0/gradlew
chmod +x gradlew
- name: Patch Repositories & Settings
run: |
find . -name "build.gradle" -exec sed -i "s|com.android.tools.build:gradle:[^'\"]*|com.android.tools.build:gradle:8.1.0|g" {} +
find . -name "build.gradle" -exec sed -i "s|org.jetbrains.kotlin:kotlin-gradle-plugin:[^'\"]*|org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10|g" {} +
if [ -f "settings.gradle" ]; then
cat > settings.gradle.tmp << 'EOF'
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.aliyun.com/repository/public' }
}
}
EOF
grep "include" settings.gradle >> settings.gradle.tmp
mv settings.gradle.tmp settings.gradle
fi
- name: Global Refactor & Targeted R Fix
run: |
# 1. Aktifkan AIDL & CMake Project
find . -name "build.gradle" -exec sed -i '/android {/a \ buildFeatures { aidl true }' {} +
find . -name "CMakeLists.txt" -exec sed -i '/cmake_minimum_required/a project(VMechaNative)' {} +
# 2. Namespace & Manifest Cleanup
find . -name "AndroidManifest.xml" | while read manifest; do
module_dir=$(dirname $(dirname $(dirname "$manifest")))
pkg_name=$(grep -oP 'package="\K[^"]+' "$manifest" || echo "")
if [ -n "$pkg_name" ] && [ -f "$module_dir/build.gradle" ]; then
sed -i '/namespace /d' "$module_dir/build.gradle"
sed -i "/android {/a \ namespace \"$pkg_name\"" "$module_dir/build.gradle"
sed -i 's/package="[^"]*"//g' "$manifest"
fi
done
# 3. SURGICAL R-FIX
# Ganti semua referensi R lama ke namespace baru
find . -type f \( -name "*.java" -o -name "*.kt" \) -exec sed -i 's/top\.niunaijun\.blackbox\.R/com.vmecha.vcore.R/g' {} +
# Gunakan awk untuk menyisipkan import hanya setelah baris 'package' yang sebenarnya di awal file
if [ -d "Bcore/src/main/java" ]; then
find Bcore/src/main/java -type f \( -name "*.java" -o -name "*.kt" \) | xargs grep -l "R\." | while read file; do
if ! grep -q "import com.vmecha.vcore.R" "$file"; then
# awk hanya akan menambahkan import setelah baris pertama yang diawali 'package '
awk '/^package / { print; print "import com.vmecha.vcore.R;"; next }1' "$file" > "$file.tmp" && mv "$file.tmp" "$file"
fi
done
fi
# 4. Refactor String Package Umum
find . -type f \( -name "*.java" -o -name "*.kt" -o -name "*.xml" -o -name "*.aidl" \) -exec sed -i 's/black\.habakuk\.core/com.vmecha.vcore/g' {} +
# 5. Fix AIDL Package Mismatch
find . -name "*.aidl" | while read aidl_file; do
relative_path=$(echo "$aidl_file" | sed -n 's|.*/aidl/||p' | xargs dirname | tr '/' '.')
if [ -n "$relative_path" ]; then
sed -i "s|^package .*|package $relative_path;|" "$aidl_file"
fi
done
- name: Finalize Module Config
run: |
if [ -d "Bcore" ]; then
cd Bcore
sed -i 's/com.android.application/com.android.library/g' build.gradle
sed -i '/applicationId/d' build.gradle
sed -i 's/namespace "[^"]*"/namespace "com.vmecha.vcore"/g' build.gradle
cd ..
fi
- name: Build Bcore AAR
run: |
./gradlew :Bcore:assembleRelease -x lint --stacktrace --no-daemon
- name: Upload VMecha AAR
uses: actions/upload-artifact@v4
with:
name: vmecha-blackbox-core
path: Bcore/build/outputs/aar/*.aar