Create a portlet inside of a custom theme in liferay 7

I know in Liferay it is possible to embed a predefined Portlet in a theme’s .ftl file by using following code:


But I’d like to create a new portlet (with all its Java classes) inside of a theme. For example, a sample skeleton of my theme project can be found in the below.

Liferay 7 Theme Skeleton

My question is, In Liferay 7 is it possible to have a complete portlet inside of a theme and end-users access to that portlet? (end-users should be able to add it to wherever they want by using add menu from the right side the admin page).

If yes, where should I place my Java code? How should I deploy and build it? Is there any example of it?

One of the benefits of it is having a theme with many different suitable custom theme in one package and you can share it with others.