Search code examples
liferayliferay-service-builder

How to Remove Entity Completely in Liferay (include class in JAR file)


I am using Liferay 6.2 GA5 Community Edition.

Sample case I have 2 entities in my service.xml, let's say entity A & B.

When I run Service Builder then it will generate many JAVA files in my source code, and also generate JAR file located in

".\my-app\liferay-plugins-sdk-6.2\portlets\my-app-portlet\docroot\WEB-INF\lib\my-app-service.jar"

I open it with 7-zip, and I can see in package com.mycompany.myapp.model contains classes of entity A & B.

Then I try to remove entity A in service.xml, and I have removed the corresponding JAVA files generated in my source code, then I run Service Builder again, but inside my-app-service.jar, entity A is still exist.

How do I completely remove it from JAR file? because in my case, Service Builder will not remove it, although I have remove generated JAVA files manually.


Solution

  • ServiceBuilder is a code generator, thus it only generates new code.

    If you want to get rid of the once generated code, there's a lot more than just the java classes to get rid of: Spring configuration, Hibernate configuration etc. are there as well for you to take care of. All of these will have to be deleted manually. And if the code still remains in the jar, good old ant clean (or whatever build environment you use) should get rid of the my-app-service.jar file (which you otherwise also can also just delete manually, so that it will be rebuilt next time a build process or ServiceBuilder runs)

    I recommend searching for occurrences of A in all your project's files to see if you still find leftovers, because otherwise some component might complain at runtime that a declarated class can't be found.