简体   繁体   English

如何使NetBeans项目更具可移植性?

[英]How can I make my NetBeans project more portable?

I have all my libraries in one directory. 我所有的库都放在一个目录中。 For each library, I first add them to NetBeans (Tools->Libraries...), then use it in all projects that need it. 对于每个库,我首先将它们添加到NetBeans(工具->库...),然后在需要它的所有项目中使用它。 The problem is this way if I give a copy of my code to someone, they have to add all dependencies again. 问题是这样的,如果我将代码的副本提供给某人,他们必须再次添加所有依赖项。 But more important, they can't compile it with ant (NetBeans uses absolute paths). 但更重要的是,他们无法使用ant进行编译(NetBeans使用绝对路径)。

So what can I do to make my project more easily portable? 那么,如何使我的项目更易于移植呢? Also is there a way to have NetBeans use relative paths in build.xml etc, so that my code can be compiled with ant on other machines? 还有一种方法可以让NetBeans在build.xml等文件中使用相对路径,以便可以在其他机器上使用ant编译我的代码吗?

Thanks 谢谢

Move from ant to maven or gradle. 从蚂蚁移动到Maven或Gradle。 They manage dependencies automatically by downloading them from public repository. 他们通过从公共资源库下载依赖关系来自动管理依赖关系。 So you do not have to care about dependencies and where they are located. 因此,您不必关心依赖项及其依赖关系的位置。

You can also "improve" your configuration by using environemnt variables into ant script, so each user can hold his libraries where he wants and configure this directory via environment. 您还可以通过在ant脚本中使用environemnt变量来“改善”您的配置,因此每个用户都可以将他的库保存在所需的位置,并通过环境配置此目录。 But this looks like re-inventiong the wheel. 但这似乎在重新发明轮子。

If you what for some reason to stay with ant at least us ivy - the dependency manager for ant that with some efforts does what maven and gradle just do for you. 如果您出于某种原因而与蚂蚁共处,至少可以使我们常春藤-蚂蚁的依赖项管理器通过一些努力即可完成maven和gradle的工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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