-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdslExtensions.gradle
56 lines (49 loc) · 1.49 KB
/
dslExtensions.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
44
45
46
47
48
49
50
51
52
53
54
55
configurations.all {
resolutionStrategy {
ext.replaceName = { params, oldName ->
def newName = params.with
eachDependency { details ->
if (details.requested.name == oldName) {
details.useTarget group: details.requested.group, name: newName, version: details.requested.version
}
}
}
}
}
apply plugin: 'eclipse'
eclipse.project.file { file ->
ext.addFilteredResources = {
file.withXml { root ->
root.asNode().append new XmlParser().parseText('<filteredResources/>')
}
}
ext.ignoreSvn = {
file.withXml { root ->
addFilter(root, createFilter(type: 26, matcher: 'name', '.svn'))
}
}
ext.ignoreGradleOutputDir = {
file.withXml { root ->
addFilter(root, createFilter(type: 10, matcher: 'projectRelativePath', buildDir.name))
}
}
}
import groovy.xml.MarkupBuilder
def addFilter (projectRoot, xml) {
def filters = projectRoot.node.filteredResources.head()
filters.append new XmlParser().parseText(xml)
}
def createFilter (filter, matchFor) {
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
xml.filter() {
id(new Random().nextInt())
name()
type(filter.type)
matcher {
id('org.eclipse.ui.ide.multiFilter')
arguments("1.0-${filter.matcher}-matches-false-false-${matchFor}")
}
}
writer.toString()
}