![]() Now we can select the latest stable version and add this to our project. With this option enabled, IntelliJ IDEA will exclude any dependencies that have no stable versions, and hide them from the list. If we uncheck this option, we see that the list of versions also includes the release candidates.įor production code, we probably want to use stable versions, so let's select the Only stable checkbox again. Since we have selected Only stable, only stable versions are shown in the list. We see that there are several versions available. You’ll see the project’s dependencies are updated with your new dependency. Go back to the Dependencies tool window and clear the search box by clicking the x on the right-hand side. Click Load Maven Changes so IntelliJ IDEA will update its dependencies based on the changes to the pom.xml or adle file. If the version number is shown in red, that means IntelliJ IDEA hasn’t downloaded this library before. ![]() When we click Add, we see that the dependency is added to the build file. In Maven, we can set the scope for a test dependency to test. Note that the names of scopes for Maven are different from Gradle. We can also select the version we want to use. Since this is a test dependency, and we are using Gradle in this project, we can set the scope to testImplementation. The names of the scopes are based on the build tool with which you are working. Note that we can select a scope for this dependency. In the Dependencies tool window, we can search for a dependency. ![]() There is no shortcut to open the Dependencies tool window, so we can either use Recent Files, ⌘E (on Mac) or Ctrl+E (on Windows/Linux), and type in "dependencies" to open the Dependencies tool window.Īlternatively, we can open it by clicking Quick Launch in the bottom-left and selecting Dependencies. Note that if we are using Gradle, we can do the same in our adle file.Īlternatively, we can open the Dependencies tool window directly. This will open the Dependencies tool window. In the build file, the pom.xml in a Maven project, invoke Package Search using ⌘N (on macOS) or Alt+Insert (on Windows & Linux) and in the menu that opens, select Add dependency. We can also use code generation from the build file to add dependencies. Since this is a test dependency, we need to add the test scope, still using code completion.Ĭode completion works in Gradle too, as you can see below.įrom the build file using code generation If needed, the version number will also be added. We see that IntelliJ IDEA autocompletes the dependency xml, and we can search for the dependency we want, in this example AssertJ. For example, let's add a new dependency to our pom.xml. We can also add dependencies to our build file using code completion. Or, if we are using Maven, we can copy the Maven xml format into our pom.xml.ĭid you know that if you copy-paste a Maven XML dependency into your adle file, IntelliJ IDEA automatically turns it into the correct format for Gradle? From the build file using code completion You have probably copied a dependency from Maven Repository (or another website) and pasted into your build file.įor example, we can copy the Gradle format for this dependency and paste it into our adle file. There are several ways to add new dependencies to your project.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |