Я хочу создать библиотеку Android для своего собственного проекта с использованием gradle, которая компилирует некоторые файлы машинописных текстов в JS и добавляет их в папку ресурсов Android.
Я не хочу, чтобы gradle это делал любая вещь Java.
Как мне сообщить gradle о необходимости сборки при каждом изменении файла в каталоге src?
plugins {
id "com.android.library"
}
// a wrapper closure around executing a string
// can take either a string or a list of strings (for arguments with spaces)
// prints all output, complains and halts on error
def runCommand = { strList ->
if(strList instanceof GString) strList = strList.toString()
assert (strList instanceof String ||
(strList instanceof List && strList.each { it instanceof String }) \
)
def proc = strList.execute()
proc.in.eachLine { line -> println line }
proc.out.close()
proc.waitFor()
print "[INFO] ( "
if (strList instanceof List) {
strList.each { print "${it} " }
} else {
print strList
}
println " )"
if (proc.exitValue()) {
println "gave the following error: "
println "[ERROR] ${proc.getErrorStream()}"
}
assert !proc.exitValue()
}
def src = new File(projectDir, "src").absolutePath
def build = new File(projectDir, "output").absolutePath
tasks.register('buildWeb') {
mustRunAfter tasks.build
group "Build"
description "Builds the web side of Sharing app"
doFirst {
runCommand "npm run build --prefix $src"
}
}
android {
compileSdk 34
namespace "src"
sourceSets {
main.assets.srcDirs += build
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... dir-change