liferaycode-generationcode-cleanupliferay-service-builder

How to clean up old artifacts of Liferay Service Builder?


Based on service.xml, Liferay's Service Builder generates Java files, directories, other files and database tables. It also extracts interfaces from code written after this generation.

When I rename a method or delete a class, Liferay does not clean up anything, the methods/classes/tables just stay there.

How to clean these old artifacts from a portlet project, with the same effect as if I re-wrote it from scratch again?


Solution

  • Warning: First make backups.

    Clean the filesystem

    Temporarily move your implementation files from docroot/WEB-INF/src/yournamespace/service/impl out of the way, for instance move it to your home folder.

    Delete the following folders (and all of their sub-folders) from your portlet project:

    Clean the database

    1. Open your service.xml
    2. Take note of the content of the <namespace> tag, for instance MyNamespace
    3. In your Liferay database, drop all tables that start with that namespace plus an underscore, for instance MyNamespace_.

    Re-generate

    Feel free to add your tips and more things to clean!