Permit entire folder of JARs to be included as one classpath entry - #9545
Permit entire folder of JARs to be included as one classpath entry #9545michaelsembwever wants to merge 1 commit into
Conversation
3bed27e to
2b152ce
Compare
|
added a few labels and restarted CI |
2b152ce to
71419c3
Compare
|
@mbien , are the CI failures real ? looking like just timeouts ? |
|
those are known to fail from time to time. Esp during full moon or the release phase. |
| final URL entry = FileUtil.urlForArchiveOrDir(kid); | ||
| // Only archives yield a URL ending in '/'; skip anything that is not | ||
| // a valid classpath root (matches the java launcher's JARs-only rule). | ||
| if (entry != null && entry.toExternalForm().endsWith("/")) { // NOI18N |
There was a problem hiding this comment.
FileUtil.isArchiveFile(url) doesn't work here?
A <classpath> path token whose last component is a filename glob (containing '*' or '?') is now expanded to the archives in the directory it names; e.g. "build/lib/*" or "build/lib/*.jar" reference every JAR in "build/lib". This mirrors the wildcard classpath syntax of the java launcher and lets a freeform project point at a folder of libraries instead of listing each JAR by its versioned filename. Tokens without a glob keep their previous meaning. The directory backing each wildcard is watched, so JARs produced by a later build are picked up automatically without editing project.xml. Change notifications are coalesced and dispatched off the file-event thread to avoid inverting lock order with listener registration. The wildcard syntax is documented in freeform-project-java-5.xsd and covered by new ClasspathsTest cases. Closes apache#6044
c9969aa to
5acb405
Compare
|
just so I understand: for this to be useful, the free form build script would probably already do some globbing to produce a valid classpath during build. Since outside of the compact java file launcher, i don't think Isn't there the danger of duplicated impls where the IDE computes the classpath order differently than the script, causing inconsistent results between editor and build? I guess the confusing aspect to me is that there is a folder of jars in a project but no classpath. Usually whatever puts the jars into that folder is also able to create classpaths. |
|
The example need is here: https://github.com/apache/cassandra/blob/trunk/ide/nbproject/project.xml#L10-L11 (and so this script has to be manually run regularly: https://github.com/apache/cassandra/blob/trunk/ide/nbproject/update-netbeans-classpaths.sh ) With this fix that script can be removed, and the project.xml take the much simpler form as found here: https://github.com/thelastpickle/cassandra/blob/mck/netbeans-freeform/ide/nbproject/project.xml#L9 |
|
I think your build creates the property at https://github.com/thelastpickle/cassandra/blob/1f5ca77d79ae407623caf5ef56355cf962284442/build.xml#L468 for the build action. (You linked the place for the duplicated IDE config above, where you use a script to update it.) The ant doc says at https://ant.apache.org/manual/using.html#path
So it is technically already undefined in the build, so sorting the path like this PR does makes it at least stable - assuming the classpath is created via fileset globs. Usually this PR would go a little bit against what NB was always known for (it tries to integrates with build tools but doesn't try to replicate what a build tool does - if possible). I suppose the classic approach would have been to try to evaluate the ant script and get the canonical path directly from ant for the project config, avoiding the duplicated path configuration and computation entirely. I am not going to block this though if someone else wanted to take a look. Tested it a bit and it worked fine. Added NB32 milestone to keep it on the radar. |
I never figured out how to do that. We also can't put anything netbeans specific into build.xml With this patch, it makes the project.xml super simple (and always accurate). |
Permit entire folder of JARs to be included as one classpath entry
Fixes #6044
( Originally https://bz.apache.org/netbeans/show_bug.cgi?id=116185 )
Component: freeform
Minor enhancement to the freeform project (for external ant scripts).
The classpath requires full name for .jar files (since .jar files are folders themselves).
This is easily painful in many projects: as many software releases these days are putting version numbers as part of the .jar file names (e.g. javolution-5.2.3.jar). Any updates to these softwares gets .jar files renamed requiring update to project.xml.
I would like to suggest accepting folders containing .jar files in classpath and expanding it for use automatically on netbeans.
Use case/motivation
See https://github.com/apache/cassandra/blob/trunk/ide/nbproject/update-netbeans-classpaths.sh
This script only exists because of the lack of this improvement.
Click to collapse/expand PR instructions
If you're a first time contributor, see the Contributing guidelines for more information.
PR approval and merge checklist:
If this PR targets the delivery branch: don't merge. (full wiki article)