Hello there, I would like to share my problem. It gives me creeps to think how can I solve my problem. Because I tried a lot of different approaches. My problem is I want to run a task which type is JavaExec. And my Java terminal program is inside of a different module and takes 7 arguments. How can I run this task in my app’s gradle? I tried a different approach below before I learn that you can execute Java programs within a task in Gradle.
task runIt(type: Exec){
workingDir='C:/dev/workspace/android/utopicminds/texture_atlas_generator/src/main/java/com/example/yekta/texture_atlas_generator'
commandLine 'cmd /c java -classpath "C:/dev/workspace/android/utopicminds/texture_atlas_generator/src/main/java" com.example.yekta.texture_atlas_generator.AtlasGenerator atlas 2048 2048 0 0 0 ../../../../../../../../app/src/main/assets/images/common'
}
But it gave me an error in line where commandLine property resides. Something like; there is no such directory. And finally, I tried JavaExec like below.
task execute(type:JavaExec){
classpath='C:/dev/workspace/android/utopicminds/texture_atlas_generator/src/main/java/com/example/yekta/texture_atlas_generator'
main=AtlasGenerator
args 'atlas', '2048', '2048', '0', '0', '0', '../../../../../../../../app/src/main/assets/images/common'}
And I gave me an error like;
Cannot cast object ‘C:/dev/workspace/android/utopicminds/texture_atlas_generator/src/main/java/com/example/yekta/texture_atlas_generator’ with class ‘java.lang.String’ to class ‘org.gradle.api.file.FileCollection’
And also, that Java program is inside of a different module.
How can I implement my idea? Thanks in advance.