Gradle skip task X because it has no source files

I created a gradle.build file that compiles an Android project. It creates the correct APKs and as a post-build step I want to copy them to another folder with a more meaningful name.

I wrote this task to achieve this goal:

task copyBundle(type: Copy) { def versionCode = android.defaultConfig.versionCode def buildDate = new Date().format("yyyy-MM-dd'T'HH-mm") def outputFile = 'HexPath-android-release-' + buildDate + '-' + versionCode + '.apk' println "Copying file to " + outputFile from('HexPath-android/build/apk/') into('output/android/') include('HexPath-android-release.apk') rename ('HexPath-android-release.apk', outputFile) } 

The problem I am facing is that she skips this task by saying β€œSkip task”: HexPath-android: copyBundle since it does not have source files.

Any ideas on what I'm doing wrong?

The folder from the folder is correct and has several .apks. The correct include file name. The output folder does not exist when running the script. Renaming is a valid file name.

+6
source share
1 answer

You said that there are several APK files in the folder, but here you include only one possible file, which you need to name exactly "HexPath-android-release.apk". Do you have this file?

If you want this file to be copied every time, I suggest rewriting the end like this:

 from('HexPath-android/build/apk/HexPath-android-release.apk') { rename { outpuFile } } into('output/android/') 

But if you want to copy multiple files, go to the "include" segment to have some wildcards, and possibly closure to create your output names. Hope this helps.

In addition, this is not the HexPath android project itself. Shouldn't you start the path only with 'build ...'?

0
source

Source: https://habr.com/ru/post/955365/


All Articles