Skip to content

Commit ea64a29

Browse files
authored
Merge pull request #2 from appdevforall/feat/ADFA-3603-ndk-plugin
feat/ADFA-3603 ndk plugin
2 parents 556fd5d + cb2b4a2 commit ea64a29

54 files changed

Lines changed: 1804 additions & 2 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/update-libs.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ jobs:
7171
path: snippets/build/plugin/*.cgp
7272
if-no-files-found: error
7373

74+
- name: Upload ndk-installer CGP
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: ndk-installer
78+
path: ndk-installer-plugin/build/plugin/*.cgp
79+
if-no-files-found: error
80+
7481
- name: Commit updated jars
7582
run: |
7683
sha=$(git -C .cache/CodeOnTheGo rev-parse --short HEAD)

‎ndk-installer-plugin/.gitignore‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Gradle
2+
.gradle/
3+
build/
4+
gradle-app.setting
5+
!gradle-wrapper.jar
6+
.gradletasknamecache
7+
8+
# IDE
9+
.idea/
10+
*.iml
11+
*.ipr
12+
*.iws
13+
.project
14+
.classpath
15+
.settings/
16+
.kotlin/
17+
18+
# Local configuration
19+
local.properties
20+
21+
# OS
22+
.DS_Store
23+
Thumbs.db
24+
25+
# Logs
26+
*.log
27+
28+
# Test outputs
29+
test-results/
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
3+
import java.net.URL
4+
import java.security.MessageDigest
5+
import java.net.HttpURLConnection
6+
7+
8+
plugins {
9+
id("com.android.application")
10+
id("org.jetbrains.kotlin.android")
11+
id("com.itsaky.androidide.plugins.build")
12+
}
13+
14+
pluginBuilder {
15+
pluginName = "ndk-installer"
16+
}
17+
18+
android {
19+
namespace = "org.appdevforall.ndkinstaller"
20+
compileSdk = 34
21+
22+
defaultConfig {
23+
applicationId = "org.appdevforall.ndkinstaller"
24+
minSdk = 26
25+
targetSdk = 34
26+
versionCode = 1
27+
versionName = "1.0.0"
28+
}
29+
30+
buildTypes {
31+
release {
32+
isMinifyEnabled = false
33+
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
34+
}
35+
}
36+
37+
androidResources {
38+
noCompress += listOf("xz")
39+
}
40+
41+
compileOptions {
42+
sourceCompatibility = JavaVersion.VERSION_17
43+
targetCompatibility = JavaVersion.VERSION_17
44+
}
45+
46+
}
47+
48+
kotlin {
49+
compilerOptions {
50+
jvmTarget.set(JvmTarget.JVM_17)
51+
}
52+
}
53+
54+
dependencies {
55+
compileOnly(files("../libs/plugin-api.jar"))
56+
57+
58+
implementation("org.jetbrains.kotlin:kotlin-stdlib:2.1.21")
59+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
60+
}
61+
62+
fun httpDownload(url: String): ByteArray {
63+
val connection = URL(url).openConnection() as HttpURLConnection
64+
connection.instanceFollowRedirects = true
65+
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)")
66+
connection.connectTimeout = 15000
67+
connection.readTimeout = 30000
68+
69+
val code = connection.responseCode
70+
if (code != 200) {
71+
throw GradleException("Failed to download $url (HTTP $code)")
72+
}
73+
74+
return connection.inputStream.use { it.readBytes() }
75+
}
76+
77+
fun md5Of(file: File): String {
78+
val md = MessageDigest.getInstance("MD5")
79+
file.inputStream().use { input ->
80+
val buffer = ByteArray(8192)
81+
var read: Int
82+
while (input.read(buffer).also { read = it } != -1) {
83+
md.update(buffer, 0, read)
84+
}
85+
}
86+
return md.digest().joinToString("") { "%02x".format(it) }
87+
}
88+
89+
val downloadAssets by tasks.registering {
90+
val assetsDir = project.file("src/main/assets")
91+
val archiveFile = assetsDir.resolve("ndk-cmake.tar.xz")
92+
val md5File = assetsDir.resolve("ndk-cmake.tar.xz.md5")
93+
94+
outputs.files(archiveFile)
95+
96+
doLast {
97+
assetsDir.mkdirs()
98+
99+
val archiveUrl = "https://www.appdevforall.org/dev-assets/release/v8/ndk-cmake.tar.xz"
100+
val md5Url = "https://www.appdevforall.org/dev-assets/release/v8/ndk-cmake.tar.xz.md5"
101+
102+
logger.info("Downloading archive....")
103+
val archiveBytes = httpDownload(archiveUrl)
104+
archiveFile.writeBytes(archiveBytes)
105+
106+
logger.info("Downloading MD5…")
107+
val md5Bytes = httpDownload(md5Url)
108+
md5File.writeBytes(md5Bytes)
109+
110+
val expected = md5File.readText().trim()
111+
val actual = md5Of(archiveFile)
112+
113+
logger.info("Expected MD5: $expected")
114+
logger.info("Actual MD5: $actual")
115+
116+
md5File.delete()
117+
118+
if (!expected.equals(actual, ignoreCase = true)) {
119+
throw GradleException("MD5 checksum mismatch for ndk-cmake.tar.xz")
120+
}
121+
122+
}
123+
}
124+
125+
126+
127+
128+
129+
130+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
2+
android.useAndroidX=true
3+
android.nonTransitiveRClass=true
44.4 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)