nguyen tuan
01/04/2024, 1:56 AMtasks.register("yarnInstall") {
val yarnDownloadUrl = "<https://github.com/yarnpkg/yarn/releases/download/v1.22.21/yarn-v1.22.21.tar.gz>"
// Determine the target directory where Yarn will be installed
val yarnInstallDir = File(project.buildDir, "yarn") // Set your desired directory
// Set up the Yarn installation task
doLast {
val downloadFile = File.createTempFile("yarn-download", ".tar.gz")
ant.invokeMethod("get", mapOf("src" to yarnDownloadUrl, "dest" to downloadFile))
// Unzip the downloaded file to the installation directory
copy {
from(tarTree(downloadFile))
into(yarnInstallDir)
}
// Make Yarn executable (Linux/macOS only)
if (org.apache.tools.ant.taskdefs.condition.Os.isFamily(org.apache.tools.ant.taskdefs.condition.Os.FAMILY_UNIX)) {
val yarnExecutable = File(yarnInstallDir, "bin/yarn")
yarnExecutable.setExecutable(true)
}
}
}
but it still return error:
Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository ‘Yarn Distributions at https://github.com/yarnpkg/yarn/releases/download’ was added by unknown code.
Can you please help me.
Thanks.Adam S
01/04/2024, 11:59 AM