AppMap is an open source IntelliJ IDEA plugin which helps you improve your code by showing you how it behaves, feature by feature, as you work. It does this by automatically generating interactive maps of architecture and code behavior right in your editor.
This 2 ¹/₂ minute video shows how to install the AppMap plugin, how to configure it to map your Java code, and how to navigate your code using the interactive diagrams.
It uses the Spring Pet Clinic as an example program.
Here are the step-by-step instructions that are demonstrated in the video, or you can follow the Quickstart for IntelliJ written instructions.
How it works
AppMap works by recording code execution paths of your app and visualizing them in interactive diagrams directly in your code editor. A good way to create AppMaps is by recording unit, functional or integration test cases. The Pet Clinic project uses JUnit tests, which will be a source of AppMaps in this demo.
Install the AppMap plugin
00:12
Installing AppMap from the JetBrains Marketplace takes only a moment:
- Open the IntelliJ IDEA preferences
- Select Plugins, click on the Marketplace tab and search for
AppMap
- Click on the
Install
button, then click onRestart IDE
.
When the IDE restarts, the AppMap plugin is installed and ready for viewing AppMaps.
Configure AppMap for the Pet Clinic recording
The AppMap framework uses a file called appmap.yml
to determine which code to map.
00:20
Create a new file appmap.yml
in the root folder of your project. You should add all the Java packages of your project. Here is an example for the Pet Clinic application that is used in this demo:
name: PetClinic
packages:
- path: org.springframework.samples.petclinic
Add Java recording agent to Maven configuration
To get a recording, run the tests with an AppMap maven plugin that sets up the JVM for AppMap recording. The popular jacoco
code coverage tool uses a similar approach in Maven projects.
00:54
Add the AppMap plugin to the build/plugins
section of the POM:
<!-- AppMap agent, default parameters -->
<plugin>
<groupId>com.appland</groupId>
<artifactId>appmap-maven-plugin</artifactId>
<executions>
<execution>
<phase>process-test-classes</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
Record AppMaps from tests
01:10
When you run the Maven test
phase, the AppMap recording agent will record AppMaps from the tests and save them in the $buildDir/appmap
folder of the project, one AppMap per each recorded test case.
$ mvnw test
Open a generated AppMap in IntelliJ IDEA
01:17
Open the AppMaps view - click on the AppMaps
tab in the UI. Or, press CTRL or COMMAND + SHIFT + A
, then type "AppMaps" in the search box and pick the `AppMaps View" from the list.
Select an AppMap from the list of all AppMaps found in the project folders, or search for an AppMap with a specific phrase in its name, for example "create owner".
Double click on an AppMap in the list, an interactive diagram viewer opens.
Interact with the AppMap diagram
01:25
Discover how the Pet Clinic application works in the AppMap diagrams.
- Start with the big picture of your software design and view all code components in the Dependency Map - Web Service endpoints, Java packages/classes/functions and SQL commands and their inter-dependencies
- Navigate to sources of classes and functions directly from the diagrams so you don't have to look for them manually
- Drill down the execution details of code and SQL in the execution Trace.
01:45
Or, you can use a bottom-up approach. Let's say you want to know what code modifies data in the database.
- Start with a SQL command of interest - like an INSERT
- View how it's connected to other calls in the Trace, then backtrack to its calling component and open its source file
- See how it is connected to other code and Web Service endpoints.
Learn more about AppMap
This is only a small demonstration of the AppMap capabilities. For more information, step-by-step instructions and practical how-tos, check out the AppMap documentation.
Acknowledgements
Thanks to Petr and Dan for all their hard work on this video!
Top comments (5)
Hey this is good for reverse engineering nice. 👍
The AppMap view doesn't show up for me, I have all the app map json files but it only show them as text files. How do you bring up the graphical view ?
Hey, if you have the AppMap extension for IntelliJ installed, then all you have to do is click on a file named *.appmap.json and it will open as visual maps. Or you can open the “AppMap” view on the left sidebar and it will list the AppMaps in the workspace. If you don’t see the AppMap extension when you search for it from inside IntelliJ, then you probably need to upgrade IntelliJ itself. Hope that helps.
This is what I did but the file just displays as text in Intellij with the AppMap plugin. Maybe AppMap depends on some other graphical component that I need to install ?
Hello @val09865 the files need to have the .appmap.json extension, i.e. test_upload.appmap.json. Can you share a screenshot of your IDE with the appmap files in the folders?