Viewing Scala Code

Create your account

When you open an event such as an exception or breakpoint Takipi overlays the run-time variable data on your code. Takipi displays a Java decompilation of your application's bytecode. This is fine if you're using Java. If you're using Scala, Ruby, Groovy or any non-Java language, you'll preferably want to see your source code in its original form. This can also be nice if you're writing in Java and want to see code comments or are using a code weaver (such as AspectJ) which adds a lot of synthetic code.

This is pretty easy to do and requires a minor customization to your usual build steps. Below is a simple guide showing what to tweak if you're using Eclipse, IntelliJ, Maven, Ant or SBT to add source files to your jars. We've also created sample projects for each of these, available on GitHub: https://github.com/takipi/attach-source-samples.

 

Play Framework

Takipi automatically supports displaying Scala source code compiled on your server by the Play framework. You're good to go!

 

SBT

You can add your sources to your jar with SBT, by adding this line to your build.sbt file (you may adjust the path to fit yours):

    unmanagedResourceDirectories in Compile <+= baseDirectory( _ / "src" )

You may add more than one directory by adding several lines, e.g.:

    unmanagedResourceDirectories in Compile <+= baseDirectory( _ / "src" )
    unmanagedResourceDirectories in Compile <+= baseDirectory( _ / "app" )

For example:

    name := "hello"
    version := "1.0"
    scalaVersion := "2.9.2"
    resolvers += "twitter-repo" at "http://maven.twttr.com"
    libraryDependencies ++= Seq("com.twitter" % "finagle-core" ...
    unmanagedResourceDirectories in Compile <+= baseDirectory( _ / "src" )
    unmanagedResourceDirectories in Compile <+= baseDirectory( _ / "app" )

 

Ant

In the project's build.xml file, make sure the javac tag contains the following attributes:

    debug="true"
    debuglevel="source,lines,vars"

Furthermore, in your jar tag add <fileset dir="src" /> to include the source files.

Here's a sample Ant build.xml file

 

Maven

In order to package your source files add the following resources to your build tag:

    <resources>
        <resource>
            <directory>${project.build.sourceDirectory}</directory>
        </resource>
        <resource>
            <directory>${basedir}/src/main/resources</directory>
        </resource>
    </resources>

Here's a sample Maven pom.xml file

 

Eclipse

1. Right click your project and select Export -> JAR file.

2. In the export window select "Export Java source files and resources".

 

IntelliJ

1. Open File | Project Structure () dialog.

2. Pick your Scala project's .jar file from the artifacts list.

3. Click the green plus button and select your 'src' folder.

4. Build the project.

Here's how to create a new jar in IntelliJ -

1. Click the green plus and add a JAR artifact.

2. Drag the compile output from the "Available elements" list to the JAR on the left.

3. Add your source folder as described above.

 

Source folders

You can also simply place a directory with your source code on the machine on which Takipi runs, and add the following startup argument to your JVM:

    -Dtakipi.sources.path=/your/source/dir/here

For example:

    java -Dtakipi.sources.path=/opt/my-app/src -jar myApp.jar

You may specify multiple directories, by separating the paths using ';' (Windows), or ':' (Linux):

    java -Dtakipi.sources.path=/opt/my-app/src:/opt/another-app/src/main/scala -jar myApp.jar

 

If you have any questions or run into issues, let us know at info@takipi.com, we're here to help.

Installs in 1 min. Zero configuration. Built for production (2% overhead)

Try it out
Free trial, no credit card required
Taki and Kipi