top of page
Search

AEMaaCS + Java 21 in a Dev Container: Debug and Sync in VS Code

  • Writer: Juan Ayala
    Juan Ayala
  • Jun 21
  • 3 min read

This week I received an email from FeedSpot. Informing me that my blog is one of the top 15 AEM blogs. I checked and sure enough, there I was. Right below Jörg Hoh. And then I realized I haven't blogged since the end of March!


So to keep my blog relevant, I need a topic for June. I remembered that in the last month I have seen a few posts from Ian Reasor on LinkedIn about the AEM Assets API. And so I began to research the Assets HTTP API. And these new OpenAPI-Based APIs.


Unfortunately I fell into a bit of a rabbit hole with these APIs. I will not finish my research by the end of June. In the process though, I had to spin up an AEM instance so I could take a look at the Assets HTTP API. I used the dev container I blogged about back in August. It has held up well! With a few minor tweaks I had AEMaaCS running on Java 21. I threw the WKND project on there. And was able to attach the debugger in VSCode. It took me 20 minutes only because there was a problem with the Maven feature. Otherwise I would have been up and running in 10.


Which brings me to the topic for this month. How to spin up the latest AEMaaCS version using Java 21 within a Visual Studio Code dev container. Attach the Java debugger. And push files using the repo tool.


I have created a video that captures all the steps, which I explain below.



Create a Dev Container

To create a dev container, first create a new folder. And open it in Visual Studio Code. Once in VS Code, use the Dev Containers: Add Dev Container Configuration Files... command. Follow the prompts. Choose the AEM template which I created. And the AEM SDK & Repo Tool features which I also created.


You will wind up with a .devcontainer/devcontainer.json. You will now update this so that the dev container also includes


Now use the Dev Containers: Rebuild and Reopen in Container. This will build the container and reopen VS Code inside of it. Your completed .devcontainer.json file will look like this:



Start AEM and Install WKND

The next thing you need to do is copy the AEM SDK into the .devcontainer folder (sdksDirectory). Then, open a terminal in VS Code and run start-aem author.


Once AEM is up proceed to clone the WKND project. And build it.


Attach the Java Debugger

The VSCode Extension Pack for Java contains several plugins. One of which is the Debugger for Java. To configure it, you add a launch config in launch.json. Set breakpoints, and attach. Below is the launch.json file.



Create Repo Tool Tasks

The repo tool is the simplest tool to sync with the JCR. It is nothing but a small shell script which I blogged about 3 years ago. And last year I created a dev container feature. The only thing you need to do is configure the tasks which you can run with the Tasks: Run Task command. Below is the tasks.json file.



Conclusion

I love dev containers. And I love Visual Studio Code. I love dev containers because of their modular approach. You start off with a simple base image. Then layer in the features you need. If something is missing, you can create your own feature and publish it. To prove the point, the Java 21 update took only a few config changes. I didn't have to build and publish container images to Docker Hub.


I love Visual Studio Code because of its command palette. You don't need to navigate through tool menus. Or remember key bindings. You type out commands as you remember them. Which makes built-in as well as extension commands easy to find. For example if I want to run the Dev Containers: Rebuild and Reopen in Container, I type something like >dev c rebui. Until the command I need filters into view.


I also love VS Code's cross-language and cross-platform support. In the past year, I have been using it for Java, as well as NodeJS on Adobe App Builder. As well as with Azure and GitHub.


If you're looking for a fast, modular AEM dev setup that works with the latest Java version, give this approach a try. Got questions or feedback? Drop a comment or reach out on GitHub!

Comments


bottom of page