Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a library to a netbeans gradle project

I have decided to try and use libgdx for graphics. However it uses gradle to manage the package; I however have very little experience with gradle.

My question is, if I have a library (.jar file) of my code. Normally in netbeans I can right click 'libraries' and choose 'add jar/folder' and it adds the library to my ant file and more importantly the ide now recognizes the .jar and exposes it to the auto-complete etc.

On gradle I have only gotten the file to show up in the 'dependencies' branch by putting the following in the build:

dependencies { runtime fileTree(dir: 'libs', include: '*.jar') }

However the libraries won't import, nor does the ide recognize their existence. The (absurdly large) online documentation for gradle seems to only want to deal with repositories and I can not find documentation for netbeans gradle. Any help would be greatly appreciated.

like image 434
Edward Armstrong Avatar asked Oct 31 '15 18:10

Edward Armstrong


1 Answers

This one stumped me for a while as well...

First manually add the dependency to your build.gradle script. Like your example:

dependencies {
   runtime fileTree(dir: 'libs', include: '*.jar')
}

Then, in Netbeans's "Projects" side-panel, right click on the project name and select "Reload project" from the context menu.

Your dependencies should then show up under the project's Dependencies folder, and code completion, compile error checking, etc. should work as usual.

If you cannot see the "Projects" side-panel click select from the menu bar Window -> Projects or press Ctrl + 1.

like image 88
John Marshall Avatar answered Sep 23 '22 19:09

John Marshall