gradle-project-setup-howto
gradle-project-setup-howto copied to clipboard
The `:app` project is special
Just how special :app
is not clear from the documentation.
Process to reproduce.
- [ ] clone the project's git repository
- [ ]
git mv app foo
- [ ]
./gradlew build
-> see error below
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':bespin:compileJava'.
> Could not resolve all dependencies for configuration ':bespin:compileClasspath'.
> Project with path ':app' could not be found in project ':bespin'.
Resolution:
- [ ] change
:app
to:foo
in two files- [ ] ./gradle/plugins/base-plugins/src/main/kotlin/org.example.consistent-resolution.gradle.kts
- [ ] ./gradle/plugins/base-plugins/src/main/kotlin/org.example.root.gradle.kts
This may be the intended behavior but it was not what I expected.
The documentation around :app
including dependencies should get some attention.
My specific issue was that I created an application with a different name.
It was unable to resolve any dependencies unless it shared that dependency with :app
.
Thanks for the feedback. It is indeed intentional. Do you have suggestion where I could put some more documentation? Inside the build scripts you needed to touch?
To explain:
-
org.example.root.gradle.kts - This is for making the build easier accessible. The assumption is that
:app:run
is the central method to run the application. So we add a lifecycle task for it to the root project. The idea is that if you run:tasks
you only see the tasks you usually need to work on the project to make the project easier to access for users working with it for the first time. This is completely optional. More explanation: https://www.youtube.com/watch?v=sOo0p4Gpjcc&t=1m17s -
org.example.consistent-resolution.gradle.kts - This follows the idea, that
:app
is special in so far that it provides the complete runtime classpath and with that the dependency versions that will be used "for real". So we pull that into all projects with consistent resolution to make sure we use these versions everywhere. More explanation: https://www.youtube.com/watch?v=YYWhfy6c2YQ&t=5m05s