0

When I create a Xtext Language server, I can build it and get a .jar file. When it comes to Antlr, how do I generate a binary file with all dependencies?

I created an Antlr project in Eclipse and this is the file structure that is generated. I once created a DSL using Xtext and Gradle, and when I built the shadowJar, I got a .jar file created in *.ide/build/libs directory.

My question is, how do I build a similar .jar or whatever file that will contain all dependencies from my new Antlr project? It is an ANTLR project, not Xtext.

Can I simply compy and paste a gradle.build into the antlr project directory? I used the below build.gradle code I extracted from a tutorial: -

buildscript {
    repositories {
        maven {
            name 'JFrog OSS snapshot repo'
            url  'https://oss.jfrog.org/oss-snapshot-local/'
        }
        jcenter()
    }
    dependencies {
        classpath 'me.champeau.gradle:antlr4-gradle-plugin:0.1.1-SNAPSHOT'
    }
}
repositories {
    mavenCentral()
    jcenter()
}
apply plugin: 'java'
apply plugin: 'me.champeau.gradle.antlr4'
antlr4 {
    source = file('src/main/antlr')
    output = file('build/generated-src/me/tomassetti/pythonast/parser')
    extraArgs = ['-package', 'me.tomassetti.pythonast.parser']
}
compileJava.dependsOn antlr4
sourceSets.main.java.srcDirs += antlr4.output
configurations {
    compile.extendsFrom antlr4
}
task fatJar(type: Jar) {
    manifest {
        attributes 'Implementation-Title': 'Python-Parser',
                   'Implementation-Version': '0.0.1'
    }
    baseName = project.name + '-all'
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
}

and built a .jar file. But when I tried to use in in eclipse che as a language server, I get a timeout error. Here is the Git repo of my complete directory: https://github.com/SharkJ/AntlrProject

SharkJ
  • 49
  • 1
  • 12

1 Answers1

0

Use the New Xtext Project Wizard. it has options to

  • create ls with maven or gradle
  • in fat jar or application with start script style

and if you want to use something as language server you actually have to implement a language server. you can do that either by using xtext or your have to implement your own version using https://github.com/eclipse/lsp4j

Christian Dietrich
  • 11,778
  • 4
  • 24
  • 32