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

make name for Eclipse resource filters configurable #1974

Closed
Vampire opened this issue May 9, 2017 · 10 comments
Closed

make name for Eclipse resource filters configurable #1974

Vampire opened this issue May 9, 2017 · 10 comments
Labels

Comments

@Vampire
Copy link
Contributor

Vampire commented May 9, 2017

With the newly introduced Eclipse resource filter DSL for eclipse, you can now configure resource filters for the generated project file. But the name tag is intentionally left blank always. This makes the feature useless for certain usecases. If you e. g. want to exclude everything in build except of build/classes/eclipse, you need a resource filter on the build directory that non-recursively INCLUDEs_ONLY FILES_AND_FOLDERS with 1.0-name-matches-true-false-classes and a second resource filter on the build/classes directory that non-recursively INCLUDEs_ONLY FILES_AND_FOLDERS with 1.0-name-matches-true-false-eclipse. The directory on which the resource filter is effective is configured by the name of the resource filter. So the config to be generated is

<filteredResources>
	<filter>
		<id>1</id>
		<name>build</name>
		<type>13</type>
		<matcher>
			<id>org.eclipse.ui.ide.multiFilter</id>
			<arguments>1.0-name-matches-true-false-classes</arguments>
		</matcher>
	</filter>
	<filter>
		<id>2</id>
		<name>build/classes</name>
		<type>13</type>
		<matcher>
			<id>org.eclipse.ui.ide.multiFilter</id>
			<arguments>1.0-name-matches-true-false-eclipse</arguments>
		</matcher>
	</filter>
</filteredResources>

This is currently not possible as there is no setting for the name and the code says filterNode.appendNode("name"); // always empty.

You can reproduce the wanted behavior with Eclipse by selecting the build directory and pressing Alt+Enter, then add the classes resource filter, then selecting the classes directory and pressing Alt+Enter, then add the eclipse resource filter.

@Vampire
Copy link
Contributor Author

Vampire commented May 9, 2017

Also related, existing resourceFilters are overwritten and not merged with the ones from the build file and neither in beforeMerged, nor in whenMerged the resourceFilters field is filled, even though there are resource filters defined in the build file.

@bmuschko
Copy link
Contributor

Could you please elaborate what you mean by "newly introduced Eclipse resource filter DSL for eclipse"?

@Vampire
Copy link
Contributor Author

Vampire commented May 11, 2017

#846

@oehme
Copy link
Contributor

oehme commented Sep 20, 2017

This might be due to my misunderstanding of the resource filter API. I had assumed that "name" is a human-readable name for the filter, but found out that Eclipse would just throw exceptions whenever I give it a value. Thanks for clarifying that.

Would you be interested in fixing this with a PR?

@oehme oehme added a:feature A new functionality and removed a:question labels Sep 20, 2017
@Vampire
Copy link
Contributor Author

Vampire commented Sep 20, 2017

@oehme I guess if it would be just the DSL for the name, I would have done it, not sure about the merging and filling in beforeMerged and whenMerged.

The main problem is, that I have a workaround. I did create this configuration even before this DSL. I mainly create PRs for stuff that really bugs me and for which I don't have a workaround, or that are easy to fix. :-)

@ams-tschoening
Copy link

There seems to be a workaround, because name is not the only matcher one can configure. projectRelativePath can be used instead, actually allowing the relative path otherwise managed by name. The following in build.gradle:

// Remove "buildSrc/build", "name" is not supported:  https://github.com/gradle/gradle/issues/1974
eclipse.project.resourceFilter
{
	appliesTo	= 'FOLDERS'
	type		= 'EXCLUDE_ALL'

	matcher
	{
		id			= 'org.eclipse.ui.ide.multiFilter'
		arguments	= '1.0-projectRelativePath-matches-false-false-buildSrc/build'
	}
}

Leads to the following filter properly only removing build in the one mentioned directory:

<filteredResources>
	<filter>
		<id>1</id>
		<name></name>
		<type>26</type>
		<matcher>
			<id>org.eclipse.ui.ide.multiFilter</id>
			<arguments>1.0-projectRelativePath-matches-false-false-buildSrc/build</arguments>
		</matcher>
	</filter>
</filteredResources>

The important thing to note is that recursive needs to be true for this filter to work for some reason. But that's the default value anyway.

My project contains code in a package using "[...].build.[...]" and without projectRelativePath that would be unnecessary difficult to implement.

@Vampire
Copy link
Contributor Author

Vampire commented Nov 26, 2018

@ams-tschoening I'm not fully sure, but I thought I tried using projectRelativePath but it didn't work for the descried use-case.
What you describe is a different use-case.
Did you try to do this with my use-case, which is excluding build except of build/classes/eclipse?

@ams-tschoening
Copy link

Did you try to do this with my use-case, which is excluding build except of build/classes/eclipse?

I don't have the same dir structure, but in the following example I can exclude everything in buildSrc/build except libs, which sounds like your use-case to me:

C:\Users\[...]\buildSrc>tree
C:.
├───build
│   ├───libs
│   ├───murks
│   ├───test
│   └───tmp
│       └───jar

INCLUDE_ONLY with only one individual directory doesn't work on the project root in this case, so one needs to use regular expressions to exclude everything except ... instead:

eclipse.project.resourceFilter
{
	appliesTo	= 'FOLDERS'
	type		= 'EXCLUDE_ALL'

	matcher
	{
		id			= 'org.eclipse.ui.ide.multiFilter'
		arguments	= '1.0-projectRelativePath-matches-false-true-buildSrc/build/(?!libs/?).+'
	}
}

projectRelativePath allows you to match the relative part of interest only within the project in the end, which should be exactly what you want and is otherwise implemented by using name.

clipboard02

@stale
Copy link

stale bot commented Jul 18, 2020

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added the stale label Jul 18, 2020
@stale
Copy link

stale bot commented Aug 8, 2020

This issue has been automatically closed due to inactivity. If you can reproduce this on a recent version of Gradle or if you have a good use case for this feature, please feel free to reopen the issue with steps to reproduce, a quick explanation of your use case or a high-quality pull request.

@stale stale bot closed this as completed Aug 8, 2020
@wolfs wolfs closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants