Skip to content

Permit entire folder of JARs to be included as one classpath entry - #9545

Open
michaelsembwever wants to merge 2 commits into
apache:masterfrom
michaelsembwever:mck/6044
Open

Permit entire folder of JARs to be included as one classpath entry #9545
michaelsembwever wants to merge 2 commits into
apache:masterfrom
michaelsembwever:mck/6044

Conversation

@michaelsembwever

@michaelsembwever michaelsembwever commented Aug 7, 2026

Copy link
Copy Markdown
Member

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:

  1. Was this PR correctly labeled, did the right tests run? When did they run?
  2. Is this PR squashed?
  3. Are author name / email address correct? Are co-authors correctly listed? Do the commit messages need updates?
  4. Does the PR title and description still fit after the Nth iteration? Is the description sufficient to appear in the release notes?

If this PR targets the delivery branch: don't merge. (full wiki article)

@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Ant [ci] enable "build tools" tests ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Aug 7, 2026
@apache apache locked and limited conversation to collaborators Aug 7, 2026
@apache apache unlocked this conversation Aug 7, 2026
@mbien

mbien commented Aug 7, 2026

Copy link
Copy Markdown
Member

added a few labels and restarted CI

Comment thread nbbuild/javadoctools/apichanges.dtd Outdated
Comment thread nbbuild/templates/common.xml Outdated
  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
@michaelsembwever

Copy link
Copy Markdown
Member Author

@mbien , are the CI failures real ? looking like just timeouts ?

@mbien

mbien commented Aug 7, 2026

Copy link
Copy Markdown
Member

those are known to fail from time to time. Esp during full moon or the release phase.


private static final ErrorManager err = ErrorManager.getDefault().getInstance(Classpaths.class.getName());

/** Recomputes wildcard classpaths off the file-event thread; see {@code wildcardListener}. */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use /// comments for javadoc one-liners if you want. The formatter would break the line otherwise. Modules can be bumped to JDK 21 level.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in c9969aa

}

/** JARs produced after the project is opened are picked up without editing project.xml. */
@RandomlyFails // depends on asynchronous filesystem-event delivery + coalescing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how bad is it? @RandomlyFails is discouraged for new tests since CI won't run it - and if it doesn't run it will age.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in c9969aa

Comment on lines +510 to +518
switch (c) {
case '*': sb.append(".*"); break; // NOI18N
case '?': sb.append('.'); break;
default:
if ("\\.[]{}()+-^$|".indexOf(c) >= 0) { // NOI18N
sb.append('\\');
}
sb.append(c);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want you could set javac.release=21 and use the arrow syntax.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in c9969aa

Comment on lines +492 to +495
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FileUtil.isArchiveFile(url) doesn't work here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in c9969aa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ant [ci] enable "build tools" tests ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Permit entire folder of JARs to be included as one classpath entry

2 participants