Hot-deploy Liferay 7 webapp resource (JavaScript/CSS/HTML) - liferay-7

I am developing a Liferay 7 portlet with bundled Tomcat 7.
To deploying a portlet, I copy the war file into deploy folder under Liferay home folder, and then I have to wait a lot of minutes to see my file modified.
Usually I work only on javascript, css and html, I want to see immediately what I changed, then, is there a way to have hot deploy for webapp resource?
Thanks

You should use the Liferay workspaces and modules. If it is a theme, the gulp watch task will help.

Liferay cache all resources by default, because that you have to wait a lot of time to see the changes. You have 3 ways to force Liferay to delete this cache.
Before deploy the module you must delete the module cache folder. This is in the following path (this applies to js and jsp resources):
liferay-ce-portal-7.0-ga3/work/your_module_name
Delete the module cache servlet folder located in:
liferay-ce-portal-7.0-ga3/tomcat-8.0.32/work/Catalina/localhost/ROOT/css/http_/o
/your_module_name
The other option is enter in Liferay Control Panel and click the cache action tasks:

Related

Glassfish step by step hot deploy

Hello i would like ask how it is possible configure glassfish server for something like live, hot deployment:
every time when i change some code of my jsp,html,js or css file i always need to clean and build project than deploy project to glassfish and again, again and again. That cost a lot of my time. I waste time for that. It will be easy when i could work on files which already use a started glasfish (deployed). But this files is in WAR file "project.war" and through my IDE (Netbeans) i cant edit this files (jsp,css,html or js). Netbeans made this file non editable.
Do you have idea how to speed up my development? I Will grateful for help.
Here is my glasfish home folder and all of 2 deployed applications are empty
yes, you can. if you need change xhtml, js, css only you can do this after your war was deployed. You can find all the files in the folder of your application
****\glassfish-4.1\glassfish\domains\domain1\applications\MyWebApplication\
when you complete your changes you need copy them to project folder and rebuild war

How to deploy generated resources to tomcat with m2e-wtp?

I am pulling JavaScript from a jar as part of my build process. I wish this js to be part of my web resources for the app deployed on tomcat and I have updated my build process to allow this to happen. Doing a maven build (outside eclipse) works as expected and I can package up a war with everything in its proper order.
However, when building with eclipse I have run into some headaches. My understanding was in order to have web resources deployed to tomcat through an incremental build, I needed to put these build-time generated js files into the target/m2e-wtp/web-resources directory. However, when I publish these new files are ignored and the web-resources deployed to tomcat seem to be pulled from my source.
I also adjusted my project's deployment assembly settings. Through this I still don't have it working. I have the entry [source:/target/m2e-wtp/web-resources, DeployPath:/] which should find the newly generated files when I perform a "publish" to the server. However, the same thing happens where m2e-wtp seems to be pulling from source.
Am I missing something? How can I get standard behavior from m2e-wtp (i.e. make it comparable to a build done outside of eclipse)? Or can I have eclipse just build the war and deploy it as such (not do the incremental builds, I can sacrifice some speed)?
FYI (versions):
eclipse: (Using Spring Tool Suite) 3.2.0
m2e: 1.3.1
m2e-wtp: 0.17.0
tomcat: 7.0
Experiment added later:
After deleting my target dir, I performed a publish to Tomcat and all the web-resources were copied from my source. I also got a popup about files not found, most of which are compiled classes. However, it was looking for three files in the /target/m2e-wtp/web-resources/META-INF. Does the m2e-wtp plugin only look for specific files in a folder rather than the entire specified folder?
The problem is that the target directory was not being refreshed. Eclipse (or m2e plugin for that matter) doesn't recognize or care that files change in the target directory during a build, something that I was assuming. For now I have the auto-refresh (for the workspace) option on. The refresh on access option didn't working as it seemed to trigger the refresh only when I was publishing to tomcat for the first time.

Technical details of serve modules without publishing in Eclipse WTP and Tomcat?

Eclipse's Web Tools Platform (WTP) allows you to configure Tomcat to "Server modules without publishing":
Web content will be served directly from the "WebContent" folder of the Dynamic Web Project. A customized context is used to make the project's dependencies available in the Web application's classloader.
In a 5 step process (just joking, you pick the # of steps), what happens technically and where are the files that Eclipse generates? I did notice that Eclipse generated a org.eclipse.jst.server.tomcat.runtime.70.loader.jar file in the Tomcat lib directory.
The idea is to serve a web application directly from the scattered directory structure of the development workspace, without packaging modules into JARs which then end up in WEB-INF/lib in a WAR.
The main benefits are:
You don't need to build archives.
When you change a resource in your workspace, the change is reflected in the running webapp without redeploying the webapp or restarting the server.
With Servlet 3.0, web resources may also be bundled in library JARs in META-INF/resources, so classes and resources may come from multiple workspace directories.
Tomcat 7.0 supports a VirtualWebappLoader and a VirtualDirContext to configure a web application based on a collection of scattered resource and class directories.
To serve your web app directly from your Eclipse workspace, WTP generates a suitable Tomcat configuration matching your project structure
in $WORKSPACE/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/conf/server.xml
For some reason, WTP does not directly use the Tomcat loader and context implementations but has its own WtpDirContext and WtpWebappLoader which are slightly different but similar. (I believe this approach is older than the current solution in Tomcat. There is some special logic for TLD scanning - I'm not sure if this is still required with the latest Tomcat versions.) These helper classes are contained in the org.eclipse.jst.server.tomcat.runtime.70.loader.jar you noticed.
Without Serve modules without publishing, when you change a web resource in META-INF/resources in a library module, this change will not be directly visible in the running application after reloading the current page in the browser.

How to call an ant target / maven after JBoss Tools Deploy?

Is there any possibility to run ant after, let's say a clean of a jboss tools server?
e.g. i plan to move some directories after having deployed them to a different directory to speed up things in jboss start up.
Another solution which came to my mind was to make jboss tools call a specific "start jboss" task/bat/something which would result in first calling my own 'move files' target then starting jboss
[EDIT - solved]
So the working solution for me was a comination of ant and jboss tools.
I use jboss 6.0.0 and jboss tools 3.2 i think
So double click the jboss 6.0.0 server, click on the tab deployment (it's a usability fail imho that this important tab is at the bottom of the view/window).
Now click on your dynamic web app module name in the list. Redirect the deployment location to yourwebappname.ear/yourwebappname.war
Use the jboss deploy folder
Move all lib files from the war/web-inf/lib to yourweappname.ear/lib
I could move all of them except spring-web-2.5.6.jar
Delete them in web-inf
eventually create and fill the meta-inf directory in yourwebappname.ear/META-INF (i did it at least) with application.xml and manifest.mf
thanks # sir Andersen
You do not reveal what kind of moves you exactly want to do and no, there is no direct support to call out to Ant or similar after a clean in JBoss Tools deploy.
But depending on what you actually want to do one or more of the below options might work for you:
Use custom deploy directory for the server
If you just need all deployments go to a specific directory then just set a custom deploy directory for the server - no need to move anything.
This is done by double clicking on the server and in the server editor under the deployments tab you can control the root directory.
Use custom deploy directory and name for specific deployments
If you need more finegrained control then you can also use the Deployments page described above to set the relative directory and name for deployment for each individual module.
Have a Ant task setup as eclipse external tool builder
If none of the above works then you could setup an Ant task as external tool builder under Project Properties. This ant launcher you can even limit to only run when certain resources changes inside the eclipse workspace - you might be able to use that to control when you want to do the "move some directories".

Liferay Hooks plugins folder

I am using Liferay 6 version.
I am trying to Learn Liferay, due to its importance.
I am into the Liferay Hooks concept, for this I am following this site:
http://kamalkantrajput.blogspot.com/2009/05/using-hooks-in-liferay-for-customizing.html
In this the author mentions about this below:
Go to plugins/hooks create a folder with any name. eg asset-publisher-hook
Please tell me where can i find the plugins folder?
Because inside the Liferay Tomcat, I found 6 folders with the name plugins and no folder hooks under this .
Please guide me.
You might also want to read the documentation in the Liferay Wiki:
http://www.liferay.com/community/wiki/-/wiki/Main/Portal+Hook+Plugins
In a Nutshell: once you have created the hook plugin (as described by adarshr) you can simply deploy the portlet like any other portlet.
If you want to remove the hook, make sure to undeploy it while Tomcat is running. Otherwise Liferay will not be informed about it and the original JSPs won't be restored.
Un-deploying can be done by simply deleting the portlet's directory in the Tomcat webapps folder.
You need to install the Plugins SDK which can be downloaded from http://www.liferay.com/downloads. Select "Plugins SDK" in the dropdown and click download.
Once you extract it, open a command prompt in the hooks folder. Then you execute the command create asset-publisher-hook "Asset Publisher Hook" and it will create the basic hooks project for you.