Contact Us 1-800-596-4880

Adding Source Attachments to Studio

Often when troubleshooting applications you may stumble upon the need to step through third party code, which often lacks source files. This is no different in Anypoint Studio regarding code living inside Mule in any of its flavors. This document will walk you through how this applies to Studio and how it works.

The jar files held inside Mule runtimes can be split in three categories: * Mule open source libraries * Mule enterprise libraries * Third party open source libraries This is relevant because Mule’s treatment of source code attachments is different for each category.

Mule Open Source Libraries

For the open source components of Mule, Studio provides the source code as part of the installation of each runtime, therefore it will always be available out of the box. As an example, you may open the org.mule.api.MuleEvent class, and there you can check the source code without needing any further configuration.

Mule Enterprise Libraries

For modules which are part of the enterprise edition of Mule, source code is not available out of the box. If you need access to the source of these libraries, you can Contact MuleSoft Support, explain your use case and why you require it.

In order to make these available in Studio you need to:

  1. Open Anypoint Studio Preferences.

  2. Head over to the preferences page called Source Attachments, located under the Anypoint Studio section. There you are presented with a list of the runtimes installed and the current configuration for the Enterprise sources.

    import source
  3. Select the item that corresponds to the runtime you wish to attach the source code to, and click on the Edit button.

  4. Navigate to where you have downloaded the enterprise source code .zip file bundle in your local filesystem and it. After accepting the dialog, you will see the .zip file configured for that runtime in the preferences page.

  5. Click Ok in the preferences dialog.

    You can also unzip and search the source code files with other utilities such as grep or ack.

Third Party Open Source Libraries

For libraries that are open source dependencies of Mule, the standard mechanisms of Eclipse apply. This means that you can either configure these from the .jar file’s property pages, the Java Build path, or from the 'Change Attached Source…' button that appears upon opening a class file with no source attachment. These relationships are then saved in your workspace, meaning that if you have configured the sources for a certain .jar file, you don’t need to configure it again as long as you stay in the same workspace.

Leveraging Maven for Downloading Sources

When using Maven in Anypoint Studio as your project management tool, you have certain advantages like the option to download all of the source’s .jar files for your project’s direct and transitive dependencies. Studio is aware of this, and looks into your local Maven repository for sources when possible. You can turn on the feature of downloading sources when updating dependencies in the Maven Settings preferences page by selecting the checkbox labeled "Download sources when updating dependencies".

Even though Maven is able to download sources for most of your project, Studio might not always be able to automatically detect the source’s jar file corresponding to a given library, in those cases you must still attach the source files manually.