简体   繁体   English

有没有办法让“相对路径”成为在netbeans中添加JAR文件的默认设置?

[英]Is there a way to make “Relative Path” the default for adding JAR files in netbeans?

In netbeans, if you right click on a project, go to Properties then click on Libraries , it shows you a list of current JAR files added to your project. 在netbeans中,如果右键单击项目,请转到“ Properties然后单击“ Libraries ,它会显示添加到项目中的当前JAR文件的列表。 Then you can add more libraries by clicking Add JAR/Folder . 然后,您可以通过单击Add JAR/Folder添加更多库。 However, when you click on a JAR file, it defaults to Absolute Path . 但是,当您单击JAR文件时,它默认为Absolute Path In my particular case, this is never what I want and I often just hit Open and add the file incorrectly. 在我的特定情况下,这绝不是我想要的,我经常只是点击Open并错误地添加文件。 When I check my project changes into SVN, the absolute path breaks the build for all of my team members. 当我检查我的项目更改为SVN时,绝对路径会破坏我所有团队成员的构建。

So, is there a way to make Relative Path the default? 那么,有没有办法让Relative Path成为默认值?

UPDATE: To clarify, I have multiple projects open in netbeans. 更新:为了澄清,我在netbeans中打开了多个项目。

Main - /lib/ contains all of my JAR files. Main - / lib /包含我的所有JAR文件。 Main refers to some of the JAR files in the lib folder, adding JAR files as described uses Relative Path by default. Main指的是lib文件夹中的一些JAR文件,如上所述添加JAR文件默认使用Relative Path

PluginA - Uses and refers to some of the JAR files inside Main/lib. PluginA - 使用和引用Main / lib中的一些JAR文件。 I'm adding the JAR files as described and they are defaulting to Absolute Path . 我正在按照描述添加JAR文件,它们默认为Absolute Path I'd like these to use Relative Path by default. 我希望这些默认情况下使用Relative Path

Sadly, I suspect the existence of this bug means the answer is that there is no way to make Relative Path the default. 遗憾的是,我怀疑这个错误的存在意味着答案是没有办法让Relative Path成为默认值。

Looking for alternatives: in the same bug there is this description of NB behaviour : 寻找替代方案:在同一个bug中有NB行为的描述

  1. If the JAR is considered "collocated" with the project basedir according to some provider of this information (generally a version control system which checks whether file paths are in the same checkout), then Relative is checked by default. 如果根据此信息的某个提供者(通常是检查文件路径是否在同一个检出中的版本控制系统),JAR被认为与项目基于“并置”,则默认情况下检查Relative。 (Since it can be assured that someone else checking out the same sources would indeed be able to use the same path.) (因为可以确保检查相同来源的其他人确实能够使用相同的路径。)

  2. If the JAR can be referred to using a named variable, that is used. 如果可以使用命名变量引用JAR,则使用该变量。

So, if the projects live in the same SVN repository, using a single woking copy (which I did until recently and why I never noticed the Absolute / Relative problem) could work. 所以,如果项目存在于同一个SVN存储库中,那么使用单个woking副本(我直到最近才这样做以及为什么我从未注意到Absolute / Relative问题)可以工作。

Otherwise maybe defining a variable for that /lib directory could be a workaround. 否则,为该/lib目录定义变量可能是一种解决方法。

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

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