Creating an Uber Jar for Antlr4-based Custom Language - antlr4

I have created my own simple DSLs using Xtext. Therefore, I know that an Uber Jar created by such a DSL, contains DSL Runtime, IDE, and Xtext dependencies.
My question is, what are the necessary steps that should be followed to create such an Uber Jar for a DSL created using ANTLR4? What are the necessary elements that should be included in the project that I'm intending to build the Uber jar from?
Thanks in advance!

Related

Cucumber Predefined steps usage

I have a project where I have written some per-defined steps and implemented.
Now I like to use the per-defined steps in another project in eclipse. Kindly let me know how could I do that?
Cucumber only knows how to read and execute your feature files because of the step definition files usually defined with in a steps directory. That is where your feature statements are captured by regular expressions and translated to Java code
The steps Cucumber will search for just live in a package, or a sub-package from the runner.
Suggestion would be to copy the step definitions from Project 2 into your steps directory in Project 1.
Also there is way to re-use steps is therefore to package the steps in a jar and add that jar as a dependency. You can use Maven for creating the jar.

Embed external JARs in Groovy project

I think I have some trouble understanding the concepts of the Groovy program structure...
I would like to write a program which has a dependency on an external JAR. I can use this JAR if I add it to Groovy's /lib folder. However I would like to create the program in such a way that others can use it including the JAR so they won't need to download it from the internet, place it somewhere, etc.
How can I include the JAR into my Groovy project?

Packaging a Groovy application

I want to package a Groovy CLI application in a form that's easy to distribute, similar to what Java does with JARs. I haven't been able to find anything that seems to be able to do this. I've found a couple of things like this that are intended for one-off scripts, but nothing that can compile an entire Groovy application made up of a lot of separate Groovy files and resource data.
I don't necessarily need to have the Groovy standalone executable be a part of it (though that would be nice), and this is not a library intended to be used by other JVM languages. All I want is a simply packaged version of my application.
EDIT:
Based on the couple of responses I got, I don't think I was being clear enough on my goal. What I'm looking for is basically a archive format that Groovy can support. The goal here is to make this easier to distribute. Right now, the best way is to ZIP it up, have the user unzip it, and then modify a batch/shell file to start it. I was hoping to find a way to make this more like an executable JAR file, where the user just has to run a single file.
I know that Groovy compiles down to JVM-compatible byte-code, but I'm not trying to get this to run as Java code. I'm doing some dynamic addition of Groovy classes at runtime based on the user's configuration and Java won't be able to handle that. As I said in the original post, having the Groovy executable is included in the archive is kind of a nice-to-have. However, I do actually need Groovy to be executable that runs, not Java.
The Gradle Cookbook shows how to make a "fat jar" from a groovy project: http://wiki.gradle.org/display/GRADLE/Cookbook#Cookbook-Creatingafatjar
This bundles up all the dependencies, including groovy. The resulting jar file can be run on the command line like:
java -jar myapp.jar
I've had a lot of success using a combination of the eclipse Fat Jar plugin and Yet Another Java Service Wrapper.
Essentially this becomes a 'Java' problem not a groovy problem. Fat Jar is painless to use. It might take you a couple of tries to get your single jar right, but once all the dependencies are flattened into a single jar you are now off an running it at the command line with
java -jar application.jar
I then wrap these jars as a service. I often develop standalone groovy based services that perform some task. I set it up as a service on Windows server using Yet Another Java Service and schedule it using various techniques to interact with Windows services.

Is it possible to use Java classes from the WEB-INF directory in Java agents

Currently I am busy with a brand new XPages project. I use Java and Managed Beans to access the data.
Till now I don't have to use Lotusscript ;-)
One of the last things is to create a scheduled agent to perform some backend stuff. There is already some logic in Java classes, who are in a directory in the WEB-INF directory.
I son't want rewrite these Java logic to Lotusscript, but reuse.
Is is possible to access these Java classes, from a (scheduled) Java agent??
Assuming that the WEB-INF directory that you are talking about is inside the NSF the answer is going to be NO.
Java Agents in Lotus Domino are self contained and can't see that part of the NSF. You could package those particular classes into a jar file and then attach the jar to the java agent or just copy the classes directly to the java agent. Either way you will have to maintain two sets of code.
Maybe another option for you. I'll post on Monday sample code how to use Eclipse jobs on Domino triggered from XPages. These jobs can run on behalf of the current user. The Eclipse jobs framework also allows scheduling them.
Both XPages and your Eclipse jobs run in the http process and you can access the jobs from your XPages. In other words jobs can use the same code in the WEB-INF directory.
Teaser: http://www.youtube.com/watch?v=uYgCfp1Bw8Q
Update: Posted the sample here http://www.openntf.org/Internal/home.nsf/blogEntry.xsp?permaLink=NHEF-8SJB2R
Yes, if the WEB-INF/classes is on the classpath when the java agent executes. The other way to do it would be to put the classes in there own jar, and distribute the jar with the webapp and the java agent code.

Creating own groovy library

Do anyone have an idea whats the best way of creating an own library for groovy.
I have several methods which i just dont want copy and paste into all my groovy scripts.
The perfect solution would be to do it by an
import myownmethods
How to create the library myownmethods.jar?
Thanks for any answer and solution
Cheers
The simplest method is to compile your groovy files with groovyc and then package them into a jar file with jar. For example:
groovyc -d classes myclasses.groovy
jar cvf myclasses.jar -C classes .
I'd also consider looking at gradle. To get started, you can use a build.gradle containing just:
apply plugin: 'groovy'
Then put your source files in a subdirectory called src/main/groovy and run gradle jar. It will build your source files into a jar file in build/libs.
You should follow the same process that you would for a Java library, i.e.
Create a project for the code
Configure your favorite build tool (Ant, Maven, etc.) to build a JAR for that project
Put the JAR somewhere where other projects can find it. If you're using a tool like Ivy or Maven that does dependency management you'll likely want to deploy it to a repository. Otherwise, you can probably just put it somewhere in source control †
Projects that depend on this library should either load it from the repository (if using dependency management), or have it copied into their lib directory (if not) †
† I know this sucks, but I can't remember how I used to manage dependencies without using a dependency management tool

Resources