Automatically reload Java AppEngine Maven project after making changes - java

Is it possible to automatically reload a Java AppEngine project (which uses Maven) after making changes to the code? I.e. after making a change to the code (such as a JSP) I'd like to see those changes straight away in a web browser without having to re-run the project. Is this possible?
I have done the following:
Created a Maven project using the Google's tutorial
Imported it into Eclipse using Google's instructions.
Enabled the "Build Automatically" setting on my project in Eclipse (which this article suggests is required).
Run the dev server inside the ear project (mvm appengine:devserver)
However, changes to JSPs aren't automatically reflected when I view the page in a web browser. I can only see the changes by installing (mvn clean install) and then re-running the dev server.
Projects created using the Google Eclipse plugin reload automatically however, I'd prefer to use Maven as it'll make it easier to install other software (such as the Spring Framework).

I think I've got to the bottom of this:
Import only the web Maven project (not the main project) into Eclipse (as suggested in the Eclipse Web Tools documentation)
Create a server as per Google's documentation. The web site should automatically reload 15 seconds after you make a change to the code. To change this...
Open the "servers" tab, right-click on your server and select "open".
Expand the "Publishing" section and decrease the value for "Automatically public after a build event.
Note: the "auto scan for resources change setting" doesn't seem to make any difference.

Related

Eclipse Instantly detect external file change

I am using eclipse bndtools plugin to develop OSGi based web application.
I am using Eclipse IDE (because of bndtools) and Jetbrain Webstorm IDE to edit the html/css/js files.
When I change files in eclipse, the bndtools refresh the bundle and I can see the changes immediately, but when I edit files using Webstorm I need to refresh the project in eclipse in order to see the result.
NOTE: I have enabled the Eclipse workspace setting Windows > Preferences > General > Workspace > Refresh using native hooks or polling and Refresh on access
. But this will only enable eclipse to detect changes when I access the files in eclipse.
To speed up my development, I don't want to refresh the project using eclipse on every changes I make in Webstorm. I am asking if there is a way to avoid it.
Thanks
The option "Refresh using native hooks or polling and Refresh on access" just do what you are asking for.
The option "Refresh on access" only refresh the file when you access it (when opening the file, or if the file is open in an editor).
Tested in Eclipse Photon.

Spring boot devtools - Static content reloading does not work in IntelliJ

When building my first Spring Boot app, I discovered that I need to restart my app every time I make a change to a Javascript file in /resources/static/some-file.js
This is very time consuming.
When I move the files to the /webapps/ folder, it works as expected, but the files are not packaged in a JAR. The docs mention this, so I cannot continue this way.
I read all about spring-boot-devtools, and have installed it in my POM, but the hotswapping doesn't seam to be working. I still need to restart the entire app to see a Javascript or CSS file change.
When the app starts, I can see the line LiveReload server is running on port 35729, so spring-boot-devtools must be doing something...
What would be the steps to further investigate what is going wrong?
My guess is that when IntelliJ runs the app, the files are copied, so when I make a change, I'm actually changing the original files and not the ones used by the running app.
PS: I'm using Maven, IntelliJ IDEA 15 and Spring Boot 1.3.3 with the embedded Tomcat server. I'm not sure what command IntelliJ runs to start the app. The IDE is handling this "automatically". Perhaps I need to change my run configuration?
You need to turn on a couple of features in IntelliJ to make this work.
First, there's a project specific setting which you would need to apply on any project you want to use devtools in. Go to Preferences > Compiler and enable "Make project automatically."
The next setting is an IDEA registry setting that applies to all projects.
In macOS (OSX), press Shift+Command+A (Shift+Ctrl+A in Windows)
Type "Registry" in the search box that appears, and select the registry to open it.
Lookup compiler.automake.allow.when.app.running and enable it.
After that, restart your app. You will notice that the project keeps rebuilding with every change you make. When you check out the result in the browser, you will see both static files and code have been updated.
For Windows users the steps are:
1) Go to File->Settings, then to "Build,Execution,Deployment"->Compiler and enable the "Make project automatically" flag.
2) Press Ctrl-Alt-Shift-/ and select "Registry" from the menu that appears. Enable compiler.automake.allow.when.app.running flag.
3) Start/restart the app and observe static content reloading.
For IntelliJ 2021.2 version or above below are steps that you need to follow
Add spring-boot-devtools dependency if not already added.
Enable Build project automatically as shown below
Enable option in Advanced Settings as shown below
On Linux, press:
Ctrl-Alt-Shift-/
For mac users I had to press Command + Shift + A
And restart INTELLIJ after Step1 and Step2 without which the registry option was not appearing.
You can user like bellow:
First Open Preferences.../Settings... -> Build, Execution, Deployment -> Compiler and allow Build project automatically. Image will look like
Second, we change Registry configuration. Press command+shift+A for macOS or if you are using Windows press Ctrl+Shift+A, and search for Registry. enable compiler.automake.allow.when.app.running.Images look like bellow
Registry image look like..
compiler.automake.allow.when.app.running enable image look like
Then Enjoy..
The option is now in Advanced settings:

Eclipse formatting profiles in project

We have a team of java developers. We want all the formatting to be identical - and have our own formatting profile, which is not one of the internal ones - lets assume it's called MyProfile.
We have Java Code Style/Formatter, "Enable project specific settings" on. If someone happens to have a formatting profile called MyProfile, this works perfectly. If they don't - loading the project causes Enable project specific settings to be turned off.
How do we embed not just the choice of profile, but also the formatting profile itself into our project settings so that anyone who just opens the project gets the same formatting, without having to import our style xml?
You might be able to do what you want using the maven eclipse plugin (org.apache.maven.plugins:maven-eclipse-plugin) if you are using maven as your project/build management tool.
You can define a workspaceCodeStylesURL in you pom.xml or give the URL as a parameter when you run mvn eclipse:eclipse
Example:
<workspaceCodeStylesURL>
http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-eclipse-plugin/src/optional/eclipse-config/maven-styles.xml
</workspaceCodeStylesURL>
Source

Configuring angularjs with eclipse IDE

I want to start using AngularJs and Java Spring for development purpose.I am using Eclipse as IDE . I want to configure my Eclipse to have these frameworks working seamlessly.
I know I may be asking too much,but trust me I have done much research on my part and you guys are my last resort.Any help would be much appreciated.
You'd first wanna make sure you have the JSDT installed.
Next thing is to install some dedicated tools for the job, so check out AngularJS Eclipse Tools. The AngularJS Eclipse Templates might be of help, too, and here's a visual guide written for it to get you started.
Also see the AngularJS Eclipse getting started page.
Since this answer had been posted, the AngularJS Eclipse plugin was released, as other answers stated. You might wanna check it out first.
Install JavaScript Development Tools (JSDT) and AngularJS Eclipse plug-in in eclipse from Eclipse Marketplace or Update site angularjs-eclipse-0.5.0,
Right Click on your project --> Configure --> Convert to Angularjs Project (as shown below)
Now you can see the Angularjs tags available as shown below.
.
Make sure the project is extracted on your hard disk.
In Eclipse go to the menu: File->New->Project.
Select "General->Project" and click on the next button.
Enter the project name in the "Project name:" field
Disable "Use default location" Click on the "Browse ..." button and select the folder that contains the project (the one from step 1)
Click on the "Finish" button
Right-click with the mouse on you're new project and click "Configure->Convert to AngularJS Project.."
Enable you're project goodies and click on the "OK" button.
Netbeans 8.0 (beta at the time of this post) has Angular support as well as HTML5 support.
Check out this Oracle article: https://blogs.oracle.com/geertjan/entry/integrated_angularjs_development
Since these previous answers above, there is now a release of an Eclipse Plugin to assist with development using AngularJS:
https://marketplace.eclipse.org/content/angularjs-eclipse
https://github.com/angelozerr/angularjs-eclipse/wiki/Installation---Update-Site (take a look around the other Wiki pages for information on features)
The release at the time of the answer is 0.1.0.
Please also checkout JSDT (http://www.eclipse.org/webtools/jsdt/) and also Eclipse VJET (http://eclipse.org/vjet/). The VJET project appears to be an attempt to provide better feature sets to the editor without being encumbered by the JSDT project (open source politics at play I guess).
Download angular js from this link and add as new software in eclipse
http://oss.opensagres.fr/angularjs-eclipse/0.6.0/
Configuration worked with Eclipse Mars 4.5 version.
1) Install Eclipse Mars 4.5 from
https://eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/mars2
This comes with Tern and embedded Node.js server
2) Install AngularJS Eclipse plugin from Eclipse Marketplace
3) Configure node.js server to the embedded nodejs server within Eclipse (found in the eclipse plugins folder) at Windows-> Preferences -> JavaScript -> Tern -> Server -> node.js. No extra configurations are required.
4) Test configuration in a html or javascript file.
https://github.com/angelozerr/angularjs-eclipse
With current Angular 4 and 5 versions, there is an IDE for that.
Go to eclipse market place any search for 'Angular'. You will see the IDE and install it.
After that restart eclipse and follow the welcome messages to choose preferences.
How to start using eclipse with angular projects?
Considering you already have angular project and you want to import it into eclipse.
go to file > import > choose Angular Project
and It would be better to have your projects in a separate working set so that you will not confuse it with other kind of (like java)projects.
With Angular IDE You will have a terminal window too.
To open this type terminal in eclipse search box(quick access) on the top right corner.
Hi Guys if u are using angular plugin in eclipse that time is plugin is limited periods after that if u want to used this plugin then u pay it so i suggest to you used webstrome and visual code ide that are very easy and comfort to used so take care if u start and developed a angular app using eclipse

Google-Eclipse Plugin: Adding entry points to project

Using the Google-Eclipse plugin, I have successfully created, built and deployed (locally) a very basic GWT Web Application.
The thing is: I'm not a huge fan of the project structure GWT (or the Google-Eclipse plugin) set up by default. So I'm trying to set things up in a way that makes logical sense for me, but that still is able to run in DevMode and deploy locally.
So I created a 2nd project but did not set it up as a Web Application; instead I used a normal Java Application. I created my source directories, my EntryPoint implementation (TestModule implements EntryPoint), my TestModule.gwt.xml, my host page HTML, etc. All the artifacts that I did in the first (successful) project.
But now I am in Run Configurations trying to manually set up a run config similar to how the Web Application Wizard created one for me with the first app I built.
In the Run Configurations >> GWT tab it gives me a window where I can add Available Modules. When I click the "Add" button, no matter what I type, it doesn't provide me with an available list of options to choose from.
So I exited out of the Run Configurations dialog, assuming that I need to set up my project properties differently. So I right-clicked my project, went to Properties >> Goodle >> Web Toolkit, and sure enough, see a similar panel that allows me to add Available Modules. It is my belief that if I configure this section correctly, then a list of Available Modules will become available to me when inside the Run Configurations dialog, and I should be able to continue.
Here's what I'm seeing:
Any ideas as to how I can configure my project correctly so that this Available Modules dialog actually presents me with options? Thanks in advance!
Please note: I anticipate many answers to be along the lines of "just use the Web Application wizard, it's so much easier", etc. I understand this and am (temporarily) accepting the caveats of trying to configure my own GWT app without the help of the plugin's Web Application wizard. If I find it to be really, really difficult to "roll my own" here, then I'll cave in and go back to the wizard. But I want to give this my best shot before doing so!
Feel free not to use the Google Plugin for Eclipse (hereafter GPE)! There is no need - its all Java, or at least self contained enough to act like Java as far as Eclipse can tell. If you don't want the wizards, the JSNI autocomplete, UiBinder autocomplete, by all means, you can even leave the plugin out.
To run a GWT project in dev mode, you just need the basic moving parts of the SDK:
* gwt-dev.jar - Dev mode (code server and simply HTTP server), the compiler, and assorted other tools
* gwt-user.jar - GWT language runtime (JavaScriptObject, GWT, etc) and standard events, widgets, and other bits
* optional: gwt-servlet.jar - classes to run in a servlet container for some basic GWT servlets
* optional: requestfactory-*.jar - if you don't use RequestFactory, don't worry about it
You may also need a json.jar and the valdation-api.jar as well as its sources.
This gives you enough to have any project compile in plain Java. The gwt-user.jar and gwt-dev.jar do not belong in your server classpath - don't put them in a WEB-INF/lib/ dir, just keep them on hand to compile your code to JavaScript.
Both Dev Mode and the compiler itself are just classes with a main method, so a standard Eclipse Run/Debug Configuration can start either. Each will have its own options to get going, such as 'where do i find your sources', 'what module are you starting', and in the case of Dev Mode, 'where is the war/ dir for me to serve'.
Avoid GPE entirely:
DevMode:
Make a new Java Run Configuration, and verify that the above classes are on the classpath, as well as your source directories. Set the main class to com.google.gwt.dev.DevMode, add a few params:
-war path/to/war/dir/ my.package.to.ModuleToRun
Everything else is just extra flags to change out it works, and hints for where to start. Take a look at https://developers.google.com/web-toolkit/doc/latest/DevGuideCompilingAndDebugging#What_options_can_be_passed_to_development_mode for other options available to you
To debug this, run it as a Debug Configuration - Eclipse will complain a bit about how it can't hot swap classes, but ignore these and hit continue. When you make a change in a .java file, save, and refresh the browser - GWT's specialized Dev Mode classloader will pick up the changes.
Compiling:
As above, make a run config with the important classes and jars on the classpath. This time, use the com.google.gwt.dev.Compiler main class, and specify the module(s) to build under the program arguments. Again, there are many options at your disposal to change how it compiles and what additional output it provides, see https://developers.google.com/web-toolkit/doc/latest/DevGuideCompilingAndDebugging#DevGuideCompilerOptions for more options
Using GPE without the wizards:
The important thing to remember here is that GPE is just papering over a few details - you don't need to use the wizards, but at some level, its all wizards until you are just working in raw Java. Classpath, imports, etc - these are all Java concepts that more or less apply to GWT development, though it adds Modules to help set up deferred binding rules, etc.
The module selection dialog is not necessary, though two other pieces are. First, as you've done, under Google > Web Toolkit turn on "Use Google Web Toolkit", and ensure a valid SDK is selected. This does two things - it adds the necessary jars to the classpath (under 'GWT SDK'), and enables a few other options throughout the project - JSNI autocomplete, Dev Mode, assorted wizards (that we'll ignore). The other piece that is necessary is to go to Google > Web Application, indicate that "This project has a WAR directory", and give it the path to that directory so Dev Mode knows where to start Jetty.
Once this is done, the plugin should be able to let you start from an html file that points at a module with an entrypoint. I'm going to gloss over these details, as this is basic project setup - things that the wizards are good at, examples are full of, and you presumably have read these directions (else you wouldn't be skipping wizards...). From within the previously selected WAR folder, pick such an html file, right click it and select Run As... > Web Application. It is possible that GPE will ask once again for the WAR folder - help it out, and you'll be on your way. Dev Mode will add a View to eclipse rather than a standalone window, and you'll be able to monitor progress from there.
Compiling is then a matter of going to the G icon in your toolbar and selecting "GWT Compile Project...". A dialog will appear asking for the project to use, and the entrypoint(s) to start with, as well as a few other options. Note that if you compile into the war folder then start Dev Mode, you may find that Dev Mode overwrites part of your compiled output for easier Java debugging, thus requiring an additional compile.

Categories