This course will be retired on January 8, 2022.
Gradle in Action4:27 with Chris Ramacciotti
In the last video, you were introduced to Gradle as a dependency management tool. In this video, we'll see Gradle in action by listing the Spring Web Framework as a dependency, and having Gradle download it for us.
Gradle Assets in IntelliJ
If your project structure doesn't look exactly like mine in IntelliJ, just give it a minute or so. When you start a Gradle project, IntelliJ works in the background to download the Gradle wrapper and associated files. So at first, your Gradle project may lack the following:
- .gradle directory
- gradle directory
- gradlew file
- gradlew.bat file
If you were to go back to the previous video, you'd notice at the end of the screen cast portion, my project lacked these assets. But, by the beginning of this video, they've loaded. And yours will, too!
Finding 3rd Party Libraries on Maven Central
You can browse the Maven Central repository at search.maven.org directly, but I find searching on this site to be a bit overwhelming and cumbersome.
Instead, I either go to mvnrepository.com to find my Gradle dependencies, or I Google "library-name Maven", and click the first link in the search results that links to mvnrepository.com. Usually, it's the one I'm looking for.
Importing a Gradle Project into IntelliJ
If you've downloaded a Gradle project from Treehouse, Github, or another source, importing it into your IDE is usually as simple as choosing to import a project, selecting "Gradle Project", then choosing the build.gradle file. Such is the case for IntelliJ. Then, you can use your IDE (or the command line) to refresh dependencies to download all those third-party libraries. This allows developers (like you!) to distribute source code without having to pass around hefty JAR files. Among other advantages, it's a nice way to leave a smaller digital footprint.
You need to sign up for Treehouse in order to download course files.Sign up