Skip to content

Creating a BEAM JAR

Greg Macfarlane edited this page Jun 23, 2021 · 3 revisions

Building BEAM as a JAR through Gradle:

  1. Once your BEAM project is running on an IDE like IntelliJ, go to your build.gradle file.
  2. We're going to build a fatJar, which is an executable file that includes all of the dependencies in the jar.
  3. We will need an additional plugin for creating the fatJar. In build.gradle, put this plugin into the plugins section: [id "com.github.johnrengelman.shadow" version "5.2.0"] // Shadow helps create fatJars

Your plugins should look similar to this:

plugins {

    id "net.ltgt.apt" version "0.5"
    
    id "de.undercouch.download" version "3.2.0"
    
    id "org.scoverage" version "2.5.0"
    
    id 'maven-publish'
    
    id "me.champeau.gradle.jmh" version "0.5.0"
    
    id "com.github.johnrengelman.shadow" version "5.2.0" // Shadow helps create fatJars

}
  1. In the same build.gradle file, scroll down to under tasks.withType(scalaCompile){}
  2. Copy and paste this under tasks.withType(scalaCompile) [not the line of code, the entire section]
mainClassName = 'RunBeam'

shadowJar{

    zip64 true
    
    mergeServiceFiles('reference.conf')
    
    manifest{
    
        attributes 'Main-Class': mainClassName
    
    }
}
  1. Compile the jar using this command while in your BEAM project directory:

    gradle shadowJar

  2. Your new JAR should be in BEAM\build\libs

  3. To execute your jar, use this command while in your BEAM project directory:

    java -jar -Xmx8g .\build\libs\beam-0.8.0-all.jar --config test/input/beamville/beam.conf

This example is using the default scenario BEAMVILLE.

  1. You will need the additional input files for your scenario as well, otherwise you'll get a error for missing files.