Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle hide empty generated folders #4525

Merged

Conversation

lkishalmi
Copy link
Contributor

When added the support of Generated source directories in Gradle project, the project view become a bit crowded, as the generated folders are always generated by Gradle.

Here there are two empty folder one for java and one for groovy.
image

Same project with the new code.
image

While implementing the change, I discovered a bug which prevented the freshly opened project to listen on resource changes. That one is the fist commit.

@lkishalmi lkishalmi added the Gradle [ci] enable "build tools" tests label Aug 22, 2022
@lkishalmi lkishalmi added this to the NB16 milestone Aug 22, 2022
@lkishalmi lkishalmi requested review from mbien and sdedic August 22, 2022 01:42
@lkishalmi lkishalmi force-pushed the gradle-hide-empty-generated-folders branch from a2358fe to 8e4582e Compare August 22, 2022 04:23
@@ -159,7 +160,7 @@ public synchronized SourceGroup[] getSourceGroups(String type) {
for (SourceType st : stype) {
Set<File> processed = new HashSet<>();
for (String group : gradleSources.keySet()) {
Set<File> dirs = gradleSources.get(group).getSourceDirs(st);
Set<File> dirs = filterEmptyGeneratedDirs(gradleSources.get(group).getSourceDirs(st));
Copy link
Member

Choose a reason for hiding this comment

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

Is it OK to filter the empty dirs from the data layer ? I'd rather leave them discoverable (as they are valid source roots), but filter them from the UI only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good insight! Thanks! Moving it to the UI!

@lkishalmi lkishalmi force-pushed the gradle-hide-empty-generated-folders branch from 25b1a51 to 7ea9599 Compare August 27, 2022 19:13
@lkishalmi lkishalmi requested a review from sdedic August 27, 2022 19:14
@@ -79,7 +97,8 @@ public List<SourceGroup> keys() {
ret.addAll(Arrays.asList(srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)));
ret.addAll(Arrays.asList(srcs.getSourceGroups(GradleSourcesImpl.SOURCE_TYPE_KOTLIN)));
ret.addAll(Arrays.asList(srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_RESOURCES)));
ret.addAll(Arrays.asList(srcs.getSourceGroups(GradleSourcesImpl.SOURCE_TYPE_GENERATED)));
generatedGroups = Arrays.asList(srcs.getSourceGroups(GradleSourcesImpl.SOURCE_TYPE_GENERATED));
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: generatedGroups access is unsynchronized; here, the value should be assigned first to local, then to generatedGroups + added to ret, to be consistent (within this thread). generatedGroups could be possibly volatile

@lkishalmi lkishalmi force-pushed the gradle-hide-empty-generated-folders branch from 7ea9599 to a049d85 Compare September 3, 2022 19:14
@lkishalmi lkishalmi merged commit dd6be41 into apache:master Sep 3, 2022
BradWalker pushed a commit to BradWalker/netbeans that referenced this pull request Sep 4, 2022
* Fix Gradle resourche watchers not attached on project open

* Hide empty generated source dirs

* Move the SourceGroup filtering to the UI

Cleanup a bunch of raw type error msgs related to TreeSet.
BradWalker pushed a commit to BradWalker/netbeans that referenced this pull request Sep 4, 2022
* Fix Gradle resourche watchers not attached on project open

* Hide empty generated source dirs

* Move the SourceGroup filtering to the UI

Cleanup a bunch of raw type error msgs related to TreeSet.
Chris2011 pushed a commit to Chris2011/netbeans that referenced this pull request Dec 15, 2022
* Fix Gradle resourche watchers not attached on project open

* Hide empty generated source dirs

* Move the SourceGroup filtering to the UI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gradle [ci] enable "build tools" tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants