I am new to Gradle and I have a source code location different than what Gradle expects.
Gradle expects to find the production source code under src/main/java
and your test source code under src/main/resources
. How do I configure Gradle to a different source code?
On android studio just go to File > Settings > Build Execution, Deployment > Gradle > Service directory path choose directory what you want.
In File Explorer right-click on the This PC (or Computer ) icon, then click Properties -> Advanced System Settings -> Environmental Variables . Under System Variables select Path , then click Edit . Add an entry for C:\Gradle\gradle-7.5.1\bin . Click OK to save.
An AndroidSourceSet represents a logical group of Java, aidl and RenderScript sources as well as Android and non-Android (Java-style) resources.
The default location for the files for a Windows user is under the Users directory on the C: drive. So a user called John Doe would have a folder at C:\Users\John Doe. This user directory is where the Windows . gradle folder is located.
You have to add few lines to build.gradle
:
To replace the default source folders, you will want to use srcDirs instead, which takes an array of the path.
sourceSets {
main.java.srcDirs = ['src/java']
main.resources.srcDirs = ['src/resources']
}
Another way of doing it is:
sourceSets {
main {
java {
srcDir 'src/java'
}
resources {
srcDir 'src/resources'
}
}
}
The same thing is applicable to test folder too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With