I use gradle to build an Android project("projectA") that needs an external jar file for building.
I have a second project (Unity3d in this case, so let's call it "projectU") that creates a jar file, among other things. This external project is build via a separate build.gradle file.
Before projectA is built via gradle, I build projectU. Then, a few files are copied from the finished build of projectU into the gradle Android project directory of projectA.
Files that need to be copied from projectU to projectA:
1.) project data files that go into projectA/assets/ 2.) native libraries that go into projectA/src/main/jniLibs/ 3.) a file called unity-classes.jar that goes into projectA/libs/unity-classes.jar
When I copy those files manually and then build projectA it works well.
I now want to automate this via Gradle. I have a build.gradle for projectU, and one for projectA. The one in projectA has a task that copies the files mentioned above from projectU into the project directory of projectA.
When I build projectU manually via command line, and then after that projectA, it works perfectly:
gradlew :projectU:build gradlew :projectA:assemble
But when I set up projectU as a dependency of projectA inside of the build.gradle of projectA, the build of projectA fails, because it can't "see" the "unity-classes.jar" file. It's as if the file isn't in the build directory early enough.
If I run the same build for a second time (without cleaning before), it works fine, because the unity-classes.jar file is already there and is found by the gradle build of projectA.
Questions:
1.) How do I make sure that my build of projectU, and the task in projectA that copies the files over runs before ANY android task (or evaluation?) in projectA? Or
2.) Where do I have to copy the unity-classes.jar file so that it is included into the java compilation of projectA?
Or is there a different approach?
Thanks!