Migrate MuleSoft Projects from Anypoint Studio to Anypoint Code Builder Web IDE & Vice Versa
Importing MuleSoft Project into Anypoint Code Builder (ACB) and Locally test the imported project using REST clients
Introduction:
Anypoint Code Builder (or ACB in short) is the next generation Web based IDE released by MuleSoft. This is currently in Beta release but will be on GA release soon. This IDE facilitates API design, testing, validation, implementation, debugging and deployment from one single location. The IDE is accessible from the web and it is based on Visual Studio Code. This IDE is also maintained by MuleSoft which reduces a lot of IDE maintenance overhead for developers (which is a tedious task for developers with desktop IDE).
On the other hand Anypoint Studio is the desktop based IDE, used by all MuleSoft developers for decades. Anypoint Studio is a desktop based IDE and is based on eclipse. At the time of writing this blog Anypoint Studio is the IDE for all Production ready Mulesoft applications. However with growing demand for web based IDE and with the pace Anypoint Code Builder is getting matured day by day with new features, in near future it is highly possible to have a steep demand to migrate MuleSoft projects from Anypoint Studio to Anypoint Code Builder. In this blog we are going to explore how to migrate a MuleSoft Project from Anypoint Studio to Anypoint Code Builder and how to validate the migration. Also at the end this blog also discussed how to move MuleSoft projects from ACB to Anypoint Studio.
Steps to Migrate from Studio to Code Builder:
In this section we will explore the migration steps from Anypoint Studio to Anypoint Code Builder. Follow the detailed steps below.
1.From Anypoint Studio open the project and right click on the Project explorer and select Import (as depicted in the screenshot below).
2. Select “Anypoint Studio Project to Mule Deployable Archive” option
3. Next Export the archive file to the desired location and click on Finish
4. Next login to Anypoint Platform and launch the Anypoint Code Builder
5. Login to Home Directory of the Anypoint Code builder by navigate to File > Open Folder
6. Click ok to open the home directory
7. It will open the home directory on the Anypoint Code Builder Explorer
8. Open the MuleSoft project jar file from the local file explorer and then drag and drop the jar file on Anypoint Code Builder Explorer
9. This will upload the MuleSoft application jar file from local directory to the home directory of the Anypoint Code Builder.
10. Now close the home directory
11. Now press Shift+Cntrl+p (or Shift+Cmd+p on Mac) to open the command palette. Then select Import a Mule Project option.
12. Navigate to the already imported application jar file and select the same. press ok.
13. Select the target folder location and press ok
14. Now the project is imported to Anypoint Code Builder and further modifications on that application can be continued from ACB.
Migrating Workspace to Anypoint Code Builder:
To migrate the entire MuleSoft project workspace from local to Anypoint Code Builder, this is needed to open the home directory on Anypoint Code Builder. Then drag and drop the workspace root directory to ACB home directory (or inside a child directory created for housing the migrated workspace under the ACB home directory). As depicted in the below screenshot, the entire project workspace directory can be imported to Anypoint Code Builder by just dragging and dropping the folder.
Test the migrated Project in Anypoint Code Builder:
Once the MuleSoft Application Jar file gets imported to Anypoint Code Builder then the same can be tested using any standard REST client like Postman. The Application can be pinged using a Web Browser also to validate the migrated MuleSoft application.
However testing MuleSoft applications in ACB is a little bit different than Anypoint Studio as applications running locally on Anypoint Code Builder can not be called using localhost. Hostname can be found from Anypoint Code Builder central page. On the ACB Central Page, click on the Manage your IDE and then click on View IDE Details. A pop up will appear with the URL information (along with Image and Created at). This URL needs to be copied to use for pinging the application locally
Now click on Run > Start Debugging to make the application running on Anypoint Code Builder locally. Application running on ACB can be referred on the endpoint with following convention —
https://<URL Copied from ACB Central Page>/proxy/<port>/end point
For example : https://hyacinth-yu5in0.builder.code.com/proxy/8081/demo
And invoke the URL using Web Browser to validate the migrated application.
However to test the application using a standard REST client like Postman needs one more additional step to add cookie values as header.
To get the Cookie values, it is required to open the browser’s developer Tools by pressing F12 (function button) after opening the Anypoint Code Builder Web IDE page. Then go to the Application tab and then go to Storage and from there open Cookies. Copy the Name and Value for both the cookies. The two cookies are _auth_proxy.sig and _auth_proxy
Next, open the REST client and set the Cookies as HTTP header. Cookies name and value are set as header value as follow —
_auth_proxy.sig=hSTJNUh_QNJy4DfGyIYMi8GhBC4; _auth_proxy=eyJhdXRoX3NpZ25pbl91cmwiOiJodHRwczovL2FueXBvaW50Lm11bGVzb2Z0LmNvbS9jb2RlYnVpbGRlci9hdXRoIiwiZG9tYWluIjoiaHlhY2ludGgteXU1aW4wLmJ1aWxkZXIuY29kZS5jb20ifQ==
The Postman configuration to invoke the MuleSoft application will look like below —
So this is how very easily the migrated application to Anypoint Code Builder can be validated.
Migrating Application to Anypoint Code Builder to Anypoint Studio:
Now if this is required to migrate a MuleSoft project from Anypoint Code Builder to Anypoint Studio then the same can be done following the below steps.
Open the Project to be migrated to Anypoint Studio in Anypoint Code Builder. This project needs to be packaged from Anypoint Code Builder
Open Command Palette (by pressing Shift+Cntrl+p) and select Tasks: Run Task option.
Select mule next
Select Mule Package option (alternately mule: Package Only Sources option also can be selected for a lightweight jar creation which does not include any dependencies).
Once Build Success message appear on console then check for the jar file under the target folder of the project —
Now right click on the jar file and select download to download the jar file on local directory.
The application jar file is now available in the local download folder.
Now the jar file can be imported to Anypoint Studio using the import option and then the MuleSoft project will be available to Anypoint Studio.
Conclusion:
Once Anypoint Code Builder will be in GA release, there will be a natural demand to move MuleSoft application from Anypoint Studio to Anypoint Code Builder and vice versa. So that developer can start with any IDE and then migrate to another IDE of their choice seamlessly. This blog is an attempt to depict exactly how to move Mulesoft applications between Anypoint Studio and Anypoint Code Builder with the options available at the time of writing the blog. Hope this will help in considering the Anypoint Code Builder along with Anypoint Studio for MuleSoft development activities. Thanks for taking the time to read the content and please clap below if you like the blog.
Watch the video for a demo on how to import MuleSoft Application Jar to Anypoint Code Builder —