I have seen a few people struggle with this so I modified ICN's 2.0.2 Sample Plugin to do this minification. You can refer to this as a sample on how to do it for other plugins. This is not using the newest dojo build strategy but you should be able to adapt it to the newest one if you like.
2) Use the attached build.xml and place it into the root SamplePlugin directory. It contains two new targets to extract the necessary dojo/ecm files and then to perform the dojo build.
3) Modify the build.xml to provide values for "dojo_src_zip" and "icn_path". The build.xml will have more instructions.
4) Place the new samplePlugin.profile.js into the root SamplePlugin directory as well. This file contains the specification on the layers to create and the layers it needs to reference to do the dojo build.
5) Run the new "compress_js" target. The output is a gzipped SamplePlugin.js.jgz in the output directory. Put this file as the getScript() in SamplePlugin.java. Put SamplePlugin.js as the debug script.