forked from LibraryOfCongress/bagit-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eclipse.gradle
43 lines (39 loc) · 1.45 KB
/
eclipse.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
apply plugin: 'eclipse'
eclipse.classpath.file.withXml { xml ->
def node = xml.asNode()
//make resources lib instead of src kind
Node resources = node.find {it.@path == "src/main/resources"}
if(resources != null){
resources.attributes().put("kind", "lib")
resources.attributes().put("exported", "true")
}
resources = node.find {it.@path == "src/test/resources"}
if(resources != null){
resources.attributes().put("kind", "lib")
resources.attributes().put("exported", "false")
}
}
eclipse.project.file.withXml { provider ->
ignoreDerivedResources(provider.asNode())
}
def ignoreDerivedResources(projectDescription, directories = ["build", "target", "test-output"]) {
def count = directories.count { file(it).exists() }
if (count > 0) {
def filter = projectDescription
.appendNode("filteredResources")
.appendNode("filter")
filter.appendNode("id", System.currentTimeMillis().toString().trim())
filter.appendNode("type", "26")
filter.appendNode("name")
def matcher = filter.appendNode("matcher")
matcher.appendNode("id", "org.eclipse.ui.ide.orFilterMatcher")
def arguments = matcher.appendNode("arguments")
directories.each {
if (file(it).exists()) {
def dirMatcher = arguments.appendNode("matcher")
dirMatcher.appendNode("id", "org.eclipse.ui.ide.multiFilter")
dirMatcher.appendNode("arguments", "1.0-projectRelativePath-matches-false-false-${it}")
}
}
}
}