sbt/sbt-eclipse

Support for Eclipse resource filters

Opened this issue · 2 comments

It would be very nice to have at least some support for Eclipse resource filters feature.
My use case - exclude target, project/project and project/target from Eclipse project view, right now resource filters are wiped out when project definition is re-generated.
That being said, surely this isn't the only use case for resource filters.

mkurz commented

@frozenspider You can do this already.
Here is an example of how I exclude/include some files/folders in Eclipse.

These resource filters will...
...exclude following files and folders:

.git
.project
.classpath
.settings
node_modules
project/project
project/target

...include only following files and folders inside the target folder:

target/scala-[0-9].[0-9][0-9]/classes_managed
target/scala-[0-9].[0-9][0-9]/classes_managed/.*
target/scala-[0-9].[0-9][0-9]/test-classes_managed
target/scala-[0-9].[0-9][0-9]/test-classes_managed/

Just put it in build.sbt (actually I created a eclipse.sbt to remove noise from build.sbt):

// Add eclipse resource filters to the .project file
EclipseKeys.projectTransformerFactories ++= Seq(transformNode("projectDescription", DefaultTransforms.Append(<filteredResources>
	<filter>
		<id>1440448189826</id>
		<name></name>
		<type>10</type>
		<matcher>
			<id>org.eclipse.ui.ide.multiFilter</id>
			<arguments>1.0-name-matches-false-false-.git</arguments>
		</matcher>
	</filter>
	<filter>
		<id>1440448189827</id>
		<name />
		<type>6</type>
		<matcher>
			<id>org.eclipse.ui.ide.multiFilter</id>
			<arguments>1.0-projectRelativePath-matches-false-false-.project</arguments>
		</matcher>
	</filter>
	<filter>
		<id>1440448189828</id>
		<name />
		<type>6</type>
		<matcher>
			<id>org.eclipse.ui.ide.multiFilter</id>
			<arguments>1.0-projectRelativePath-matches-false-false-.classpath</arguments>
		</matcher>
	</filter>
	<filter>
		<id>1440448189829</id>
		<name />
		<type>10</type>
		<matcher>
			<id>org.eclipse.ui.ide.multiFilter</id>
			<arguments>1.0-projectRelativePath-matches-false-false-.settings</arguments>
		</matcher>
	</filter>
	<filter>
		<id>1440448189830</id>
		<name></name>
		<type>10</type>
		<matcher>
			<id>org.eclipse.ui.ide.multiFilter</id>
			<arguments>1.0-projectRelativePath-matches-false-false-node_modules</arguments>
		</matcher>
	</filter>
	<filter>
		<id>1440448189831</id>
		<name></name>
		<type>26</type>
		<matcher>
			<id>org.eclipse.ui.ide.multiFilter</id>
			<arguments>1.0-projectRelativePath-matches-false-false-project/project</arguments>
		</matcher>
	</filter>
	<filter>
		<id>1440448189832</id>
		<name></name>
		<type>26</type>
		<matcher>
			<id>org.eclipse.ui.ide.multiFilter</id>
			<arguments>1.0-projectRelativePath-matches-false-false-project/target</arguments>
		</matcher>
	</filter>
	<filter>
		<id>1440448189833</id>
		<name>target</name>
		<type>29</type>
		<matcher>
			<id>org.eclipse.ui.ide.multiFilter</id>
			<arguments>1.0-projectRelativePath-matches-false-true-target/scala-[0-9].[0-9][0-9]|target/scala-[0-9].[0-9][0-9]/classes_managed|target/scala-[0-9].[0-9][0-9]/classes_managed/.*|target/scala-[0-9].[0-9][0-9]/test-classes_managed|target/scala-[0-9].[0-9][0-9]/test-classes_managed/.*</arguments>
		</matcher>
	</filter>
</filteredResources>)))

I'll use this workaround for now, thanks!
Still, I think the proper implementation of resource filters will be an asset and this issue stands.