Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Working with build.gradle dependencies straight away in IDE

How do you add dependencies into build.gradle then work with those dependencies straight away in the IDE? (I've tried it with STS & Netbeans)

Here is the long story: I was following springs consuming rest tutorial (modifying it slightly to suit my own rest service and objects). I started a new gradle project, then added the dependencies to build.gradle. Then when I added RestTemplate into the main application file, I could not resolve it. I tried building the project and while I noted it downloaded the dependencies I still could not resolve RestTemplate (nor @JsonIgnoreProperties(ignoreUnknown=true)). In Spring Tool Suite I tried restarting the application and nothing changed. In Netbeans I tried restarting the application and it worked! But I'd rather have more control over this than trial'n'error. What's the proper procedure?

Edit Peter has answered STS in the comments. Netbeans anyone?

like image 232
Steve Avatar asked Oct 29 '13 04:10

Steve


2 Answers

I'm the developer of the NetBeans integration of Gradle. In NetBeans, if you edit your build script, you have to reload the project for NetBeans to detect the changes. You can reload the project by selecting "Reload project" in the context menu of the project. In practice, you should only reload, if you have adjusted the compile time dependencies.

Since plugin version 1.2.7, if you are using Gradle 1.9 or above (Gradle 1.8 does not work properly with NetBeans: debugging features will be broken), more exotic non-standard configurations are detected automatically as well (adding a new source set with different set of dependencies, provided dependencies, ect.).

I have set up a Wiki page which you might want to read if you would like to know more.

like image 58
Attila Kelemen Avatar answered Nov 15 '22 16:11

Attila Kelemen


It depends on your IDE. In IntelliJIDEA, you use the Gradle support to access the JetGradle plugin. You can use that to import dependencies and make sure the IDE is aware of any changes to your build script.

Personally, I find the Grade support in IntelliJ merely adequate. It isn't nearly as good as the Maven support. But I also prefer Gradle so much more to Maven that I live with it.

Note also that Gradle provides an IntelliJIDEA plugin. This enables you to build a project in IntelliJ from the build file. This is good but not as good as I would like.

Hopefully others can chime in on the pros and cons of other IDE's when it comes to Gradle.

like image 32
Vidya Avatar answered Nov 15 '22 16:11

Vidya