xtext-core/gradle/eclipse-project-layout.gradle
2017-01-11 13:43:25 +01:00

76 lines
1.7 KiB
Groovy

/*
* 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 sourceDirs = ['src', 'src-gen', 'emf-gen']
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 = []
}
}
jar {
from ('.') {
include 'about*.*', 'plugin.xml', 'schema/**', 'model/**', 'plugin.properties'
}
if (isTestProject) {
from sourceSets.test.output
}
}
sourcesJar {
from ('.') {
include 'about*.*'
}
if (isTestProject) {
from sourceSets.test.allSource
}
}
if (isTestProject || name.contains('testlanguage')) {
tasks.withType(Javadoc) {
enabled = false
}
javadocJar.enabled = false
uploadArchives.enabled = false
} else {
artifacts.archives javadocJar
}
// Configuration of meta data required by the Eclipse IDE
eclipse {
classpath {
plusConfigurations += [configurations.optional]
plusConfigurations += [configurations.mwe2Runtime]
file.whenMerged {
entries.each { source ->
if (source.kind == 'src' && source.path.endsWith('-gen') && !source.path.equals('xtend-gen') ) {
source.entryAttributes['ignore_optional_problems'] = 'true'
}
}
}
}
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'))
}
}