简体   繁体   中英

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.

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.

在 netbeans 11 中,重新加载项目选项似乎已移至右键单击项目根文件夹中的“配置”并选择“下载源”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM