Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
208 lines (164 sloc) 4.94 KB
plugins {
id 'jacoco'
id 'org.jetbrains.intellij' version '0.4.7'
id 'de.undercouch.download' version '3.4.3'
id 'com.github.kt3k.coveralls' version '2.8.2'
}
apply plugin: 'org.jetbrains.intellij'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'checkstyle'
sourceCompatibility = javaVersion
targetCompatibility = javaTargetVersion
group pluginGroup
version = pluginVersion
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
sourceSets {
main {
java.srcDirs 'src', 'gen'
resources.srcDir 'resources'
}
test {
java.srcDir 'tests'
resources.srcDir 'testData'
}
}
intellij {
version System.getenv().getOrDefault('IDEA_VERSION', ideaVersion)
type ideaType
pluginName pluginName
downloadSources Boolean.valueOf(sources)
sameSinceUntilBuild Boolean.valueOf(isEAP)
alternativeIdePath idePath
patchPluginXml {
sinceBuild pluginSinceBuild
untilBuild pluginUntilBuild
}
plugins 'git4idea', 'hg4idea'
publishPlugin {
username publishUsername
token publishToken
channels publishChannel
}
}
idea {
project {
jdkName = javaVersion
languageLevel = javaVersion
}
module {
generatedSourceDirs += file('gen')
}
}
checkstyle {
configFile = new File(rootDir, "gradle/checkstyle.xml")
}
// Configurations
configurations {
bnf
jflex
}
repositories {
mavenCentral()
maven { url 'https://dl.bintray.com/jetbrains/intellij-plugin-service' }
}
test {
testLogging {
exceptionFormat = 'full'
}
}
jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
}
dependencies {
bnf files("$buildDir/tools/GrammarKit/lib/grammar-kit.jar")
bnf files("$buildDir/tools/light-psi-all.jar")
jflex files("$buildDir/tools/JFlex.jar")
testCompile group: 'junit', name: 'junit', version: '4.11'
}
import groovy.io.FileType
// Tasks
task downloadJFlexJar(type: Download) {
description 'Downloads JFlex.'
src 'https://jetbrains.bintray.com/intellij-third-party-dependencies/org/jetbrains/intellij/deps/jflex/jflex/1.7.0/jflex-1.7.0.jar'
dest "$buildDir/tools/JFlex.jar"
onlyIf { !file("$buildDir/tools/JFlex.jar").exists() }
}
task downloadJFlexSkeleton(type: Download) {
description 'Downloads JFlex skeleton.'
src 'https://raw.github.com/JetBrains/intellij-community/master/tools/lexer/idea-flex.skeleton'
dest "$buildDir/tools/idea-flex.skeleton"
onlyIf { !file("$buildDir/tools/idea-flex.skeleton").exists() }
}
task generateLexer(type: JavaExec) {
description 'Generates lexer sources with JFlex.'
dependsOn downloadJFlexJar, downloadJFlexSkeleton
main = 'jflex.Main'
args = [
'-skel',
"$buildDir/tools/idea-flex.skeleton",
'-d',
'gen/mobi/hsz/idea/gitignore/lexer/',
'src/mobi/hsz/idea/gitignore/lexer/Ignore.flex',
]
classpath = configurations.jflex
}
task downloadGrammarKit(type: Download) {
description 'Downloads GrammarKit.'
src 'https://github.com/JetBrains/Grammar-Kit/releases/download/1.2.0.1/GrammarKit.zip'
dest "$buildDir/tools/GrammarKit.zip"
onlyIfNewer true
}
task downloadGrammarLightPsi(type: Download) {
description 'Downloads GrammarKit Light Psi.'
src 'https://github.com/JetBrains/Grammar-Kit/releases/download/1.2.0.1/light-psi-all.jar'
dest "$buildDir/tools/light-psi-all.jar"
onlyIfNewer true
}
task unzipGrammarKit(type: Copy) {
description 'Extracts GrammarKit files.'
dependsOn downloadGrammarKit
from zipTree("$buildDir/tools/GrammarKit.zip")
into "${buildDir}/tools/"
include "GrammarKit/lib/*"
}
task generateParser(type: JavaExec) {
description 'Generates parser sources with GrammarKit.'
dependsOn unzipGrammarKit, downloadGrammarLightPsi
main = 'org.intellij.grammar.Main'
args = [ 'gen', file('resources/bnf/Ignore.bnf').absolutePath ]
classpath = configurations.bnf + configurations.compile
}
task pullResources(type: Exec) {
description 'Pulls gitignore resources from Git.'
workingDir 'resources/gitignore'
commandLine 'git', 'pull', 'origin', 'master'
}
task generateTemplatesList() {
description 'Generates templates list based on the gitignore submodule.'
dependsOn pullResources
def content = "";
file('resources/gitignore').eachFileRecurse (FileType.FILES) { file ->
if (file.name.endsWith(".gitignore")) {
content += relativePath(file).substring(10) + "\n"
}
}
file('resources/templates.list').write(content)
}
task generateSources() {
if (Boolean.valueOf(runGenerators)) {
dependsOn generateParser, generateLexer, generateTemplatesList
}
}
clean.doFirst {
delete 'gen', 'out'
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.incremental = true
options.fork = true
}
compileJava.dependsOn generateSources
You can’t perform that action at this time.