This repository was archived by the owner on Apr 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy patheclipse-project-layout.gradle
124 lines (113 loc) · 3 KB
/
eclipse-project-layout.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import org.apache.tools.ant.filters.*
/*
* Since we use the Eclipse Style layout where sources and resources live in the same
* folders, we need to make some adjustments to Gradle's defaults.
*/
def isTestProject = name.endsWith('tests')
def isPlugin = new File("$projectDir/META-INF/MANIFEST.MF").exists()
def sourceDirs = ['src', 'src-gen', 'emf-gen']
sourceSets {
configure(isTestProject? test : main) {
java {
srcDirs = sourceDirs
srcDir 'xtend-gen'
include '**/*.java', '**/*.xtend'
}
resources {
srcDirs = sourceDirs
exclude '**/*.java', '**/*.xtend'
}
if (findProperty('compileXtend') == 'true') {
xtendOutputDir = 'xtend-gen'
}
}
configure(isTestProject? main : test) {
java.srcDirs = []
resources.srcDirs = []
}
}
if (isTestProject) {
task cleanupEcoreFiles(type: Delete) {
delete(fileTree(dir:sourceSets.test.output.resourcesDir, includes:['**/*.ecore','**/*.xtext']))
}
test.finalizedBy(cleanupEcoreFiles)
}
jar {
from ('.') {
include 'about*.*', 'plugin.xml', 'schema/**', 'model/**', 'plugin.properties'
exclude 'about.mappings'
}
from ('.') {
include 'about.mappings'
filter(ReplaceTokens, tokens: ['build': getBuildId()])
}
if (isTestProject) {
from sourceSets.test.output
}
}
/**
* Computes the build type from the project version.
* When property 'upstreamBranch' has been set the build type is 'I'.
*
* @return I,M,R (Integration, Milestone, Release)
*/
def String getBuildType () {
if (hasProperty('upstreamBranch')) {
return 'I'
}
def versionSplit = version.split('\\.')
if (version.endsWith('SNAPSHOT'))
return 'I'
else if (versionSplit.length == 4)
return 'M'
else
return 'R'
}
/**
* Computes a build identifier as a combination of the build type
* (Integration,Milestone/Release) and the build timestamp.
*/
def getBuildId () {
return getBuildType()+buildTime
}
sourcesJar {
from ('.') {
include 'about*.*'
}
if (isTestProject) {
from sourceSets.test.allSource
}
}
if (isTestProject || name.contains('testlanguage')) {
tasks.withType(Javadoc) {
enabled = false
}
javadocJar.enabled = false
} else {
artifacts.archives javadocJar
}
// Configuration of meta data required by the Eclipse IDE
eclipse {
classpath {
plusConfigurations += [configurations.optional]
file.whenMerged {
entries.each { source ->
if (source.kind == 'src' && source.path.endsWith('-gen') && !source.path.equals('xtend-gen') ) {
source.entryAttributes['ignore_optional_problems'] = 'true'
}
if (source.kind == 'output') {
source.path = 'bin/main'
}
}
}
}
project {
natures 'org.eclipse.xtext.ui.shared.xtextNature'
buildCommands.add(0,new org.gradle.plugins.ide.eclipse.model.BuildCommand('org.eclipse.xtext.ui.shared.xtextBuilder'))
if (isPlugin) {
natures 'org.eclipse.pde.PluginNature'
buildCommands.add(new org.gradle.plugins.ide.eclipse.model.BuildCommand('org.eclipse.pde.ManifestBuilder'))
buildCommands.add(new org.gradle.plugins.ide.eclipse.model.BuildCommand('org.eclipse.pde.SchemaBuilder'))
}
}
}