In my project: https://github.com/pc-magas/sercommH300sVoipCredentialsRecovery source is seperated into 2 parts:
- The core library where no android dependencies are placed.
- The android app iself.
Core Logic is in app/src/main/java/pc_magas/vodafone_fu_h300s/logic/
and the tests for the core logic is in: app/src/test/java/pc_magas/vodafone_fu_h300s/logic/
Therefore, I want to split my build process into these phases:
- Build a .jar out of the
app/src/main/java/pc_magas/vodafone_fu_h300s/logic/
- place it into
./app/libs
- Build the app itself using the generated .jar
Therefore how I can configure the gradle.build
to build my library first?
Advertisement
Answer
Well based upon this answer you’ll need you create a new Java/Kotlin library in order to do this you’ll need to follow these steps:
- In android studio select File -> New -> New Module
- Then select Java or Kotlin Library.
- Use the default settings.
This step creates a new folder with its own build.gradle
. I’ll assume that the folder’s name is settings_fetcher
. The folder name is the one you choose in this window:
Also, this name mentioned above is the name you’ll need to place into the application’s dependency as well. So in the window shown above used settings_fetcher
as Library Name then you’ll need to place the following dependency into your build.gradle
located into
Once you created the module place into app/build.gradle
the correct dependency as stated in this answer.
Then move the files located in app/src/main/java/pc_magas/vodafone_fu_h300s/logic/
into the settings_fetcher/src/main/java/pc_magas/vodafone_fu_h300s/logic/
also move any tests, related to the library, located in app/src/tests
into settings_fetcher/src/tests
(Assuming the new library is named settings_fetcher
)
Then try to run the tests and build the application as well in order to ensure the correctness of the application’s functionality as well.