Options for Attaching Source Code in Java

This article introduces additional options for attaching source code in Java, including:

Ant

To attach source code in Ant:

  1. 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
  2. Restart the OverOps Collector for changes to take effect.

Maven

To attach source code files in Maven:

  1. 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.
2. Restart the OverOps Collector for changes to take effect.

Eclipse

To attach source code in Eclipse:

  1. From Eclipse, right-click the project and select Export > JAR file.
  2. In the export window, select Export Java source files and resources.
526
  1. Restart the OverOps Collector for changes to take effect.

IntelliJ

To attach source code in IntelliJ:

  1. From File, click Project Structure.
  2. From the artifacts list, pick the Scala project JAR file.
  3. Click the green plus button and select the relevant src folder.
  4. Check the Build on make checkbox.
  5. Click Apply to build the project.
767
  1. Restart the OverOps Collector for changes to take effect.

To create a new JAR in IntelliJ:

  1. From Artifacts, click the green plus and select a JAR artifact.
  2. Drag the compile output from the Available Elements list to the proj.jar.
  3. Add the source folder as described above.
731
  1. Restart the OverOps Collector for changes to take effect.

Clojure

If you’re using Leiningen to manage your project, the sources are packed with your binaries. For the best OverOps experience, make sure the following options are used as part of project.clj:

:omit-sources false
:aot :all

Example project file:

(defproject guestbook "0.0.0"
  :dependencies []
  :min-lein-version "2.0.0"
  :source-paths ["src/clj"]
  :resource-paths ["resources"]
  :main helloworld.main 
  ;; Making sure your original .clj files are present near the binaries so that OverOps can find and use them when showing snapshots in the webapp. 
  :omit-sources false 
  :profiles {:uberjar {
     ;; This makes your Clojure app compile ahead of time which helps OverOps understand which bytecode is running.
     :aot :all 
     :uberjar-name "helloworld.jar"
     }
   }
 )