xtext-core/gradle/eclipse-project-layout.gradle

130 lines
3 KiB
Groovy
Raw Permalink Normal View History

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']
2016-06-13 09:40:40 +00:00
sourceSets {
configure(isTestProject? test : main) {
java {
srcDirs = sourceDirs
include '**/*.java', '**/*.xtend'
}
resources {
srcDirs = sourceDirs
exclude '**/*.java', '**/*.xtend'
}
if (findProperty('compileXtend') == 'true') {
xtendOutputDir = 'xtend-gen'
} else {
java.srcDir 'xtend-gen'
}
}
configure(isTestProject? main : test) {
java.srcDirs = []
resources.srcDirs = []
}
}
if (isTestProject) {
task cleanupEcoreFiles {
doLast {
fileTree(dir:sourceSets.test.output.resourcesDir, includes:['**/*.ecore','**/*.xtext']).each {
it.delete()
}
}
}
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
}
}
2016-06-15 14:40:42 +00:00
/**
* 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
}
2016-11-08 13:56:11 +00:00
sourcesJar {
from ('.') {
include 'about*.*'
}
if (isTestProject) {
from sourceSets.test.allSource
}
2016-11-08 13:56:11 +00:00
}
if (isTestProject || name.contains('testlanguage')) {
tasks.withType(Javadoc) {
enabled = false
}
javadocJar.enabled = false
} else {
artifacts.archives javadocJar
}
2016-12-23 07:45:26 +00:00
// 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'
}
2016-12-23 07:45:26 +00:00
}
}
}
2016-12-23 07:45:26 +00:00
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'))
}
2016-12-23 07:45:26 +00:00
}
}