is it possible to run gradle in live mode - gradle

In sbt there is a live mode, if I use sbt ~run, then every time a java source changed, it will reload automatically. playframework also support that so that when change a source code, we don't reload manually. For gradle, I am running spring boot, but need to shutdown it and then startup after change some code, even if I am using --daemon, it still need some manually work. Anyway to load the code automatically?

A live mode for Gradle is in the works but not currently available. Plugins such as spring-boot may of course provide their own solution.

Related

Inconsistent run of springboot application when run in Eclipse

I have observed an inconsistent way properties are being read in Eclipse. I have a very simple Springboot web project with typical property files. Here is my project layout:
Notice the two property files: testapplication.properties and application.properties. They are identical at this point, the intention is to use them for test and non test environments.
When I try to run this application in Eclipse, I am getting an error about missing expected property values, for example:
Could not resolve placeholder 'min.thread.count' in value "${min.thread.count}"
When I run the same setup using gradle's bootRun task, it works fine.
When I run the same setup in InteliJ it works fine.
If I rename the testapplication.properties to application.properties the application runs fine in Eclipse. As such it is using property form test folder.
In addition, I am pretty sure when I started Eclipse this morning I was able to run the application with a proper application.properties and testapplication.properties files. I was working on a unit test and renamed the testapplication.properties to application.properties, did some work, then renamed it back to testapplication.properties the application refused to start. I have attempted to replicate it: shut down eclipse with two different property files (application and testapplication), start it again and run application. However, at this moment I have the same issue (complaining about missing property value).
As you can see this i weird behaviour. As it stands I find that I cannot use Eclipse as I am not sure what it will do. I've switch to community edition of InteliJ as it seems to be working correctly. But as a long time fan of Eclipse I am heartbroken :)
Does anyone have any clue what could be causing this?
EDIT:
I have checkin in my test project here:
https://github.com/twolak2003/CamelSpringBootEureka.git in branch PropertyFileIssue. Simply clone, switch to PropertyFileIssue branch, import to eclipse as gradle project.
It is a simple vanilla spring cloud boot project running a eureka server and eureka client. For the purpose of this issue we'll just concentrate on eureka-service.
I am using latest Eclipse Oxygen. I did notice the same issue in Eclise Neon. I switched to Oxygen hoping the issue will go away. Only plugin is the Spring IDE. Using Java 8 to run this.
Test 1: Start the EurekaService/src/main/hello.java as Java application.
It starts fine and will read the src/main/resources/application.property file.
Test 2: Rename the EurekaService/src/main/test/resources/restapplication.properties to EurekaService/src/main/test/resources/application.properties. Start the EurekaService application again.
Findings: It starts fine as well BUT it uses property file in the /src/test/resources. This to me is issue as well, it should not be using /test/ for running the application.
Test 3: Now rename the /src/test/resources/application.properties to /src/test/resources/testapplication.properties again. (this is repeat of test1). Once again run EurekaService/src/main/hello as java application.
Finding Despite this being a repeat of test1 the test failed due to "Could not resolve placeholder 'tomek.prop' in value "${tomek.prop}"".
Am I doing something really stupid or is there an issue?
For now with heavy heart I am switching to InteliJ to keep my project going. The behaviour of Eclipse is just too unpredictable for me to stomach for now :(
So far I don't have a correct answer for this other than stop using Eclipse :). But there is workaround.
DO NOT use more than one application.property file.
If you need test properties to override actual properties then name your file as anything else but "application.property". Otherwise you'll get unpredictable behaviour and your Eclipse runtime get's confused.

how to debug spring boot gradle projects faster in intellij idea?

When I develop spring boot gradle projects in intellij idea, if I want to change some code and restart the project, I have to click the Make Project menu item and this will trigger a gradle build.If the gradle deamon is dead, it will start first which is an upset process.
While in Spring Tool Suite, everything is so easy, just Ctrl S and STS will restart immediately witout the long gradle build. So is there any way to make intellij idea restart faster?
I know if the gradle deamon is alive, gradle build in intellij idea is not very slow and is acceptable. But on my computer, the deamon can usually live for only several minites. When I change some codes and want to see the effects, the deamon died. I have to start the deamon every time! Is there any other ways to make the deamon live longer?
Thanks a lot if there is any useful tips!
Well, thanks to #Gregg and #CrazyCoder 's comment, I found some useful links:
Developing/Debugging a Gradle-built Spring Boot app in IntelliJ IDEA
I accidently enable the delegate to gradle option in idea, which will trigger gradle build instead of idea's build, which is faster than gradle's. So disable the delegate to gradle option is a choice.
From another post, I get some idea to use the continuous build in gradle: open a terminal and run gradle assemble --continuous, when files are changed(for example save files or defocus window), gradle will compiles files automatically. Then run the spring boot app use gradle bootRun or from the tasks in idea, everything is ok. But this way will start two gradle so ram usages are larger.
Update:
I found another way to automatically compile. Fisrt, enable build project automatically option, then use ctrl shift a and input registry to open a dialog, and then enable compiler.automake.allow.when.app.running opiton. Finally, project will compile automatically and spring boot will also restart automatically.

what is debug mode and how do i turn it on using jboss in windows command console?

I would like to know what is debug mode in jboss. I've used django before and when I turned on debug mode, any change I make while the localhost is running will be detected and refreshing the page will show the changes. Is that the same in jboss debug?
I use maven to install the project then start jboss in windows command console. How do I turn on debug mode for jboss 5.1.1?
Maven clean install takes about 8 minutes, then restarting the server is another 5-7 minutes. I am wasting a lot of time for many small changes.
You can enable remote debugging on the JVM allowing you to connect via your IDE and you can from there run your app in bebug (stop the execution and go step by step). Look on the statup script, the remote debug option has been put in comment. Debug allow you to update some class (you need to connect the IDE to it and update your class via the IDE, the JVM and JBOSS won't detect the change them self). But if you update any container managed part (EJB, persistance context, servlet) you will need to redeploy the application. So I don't think it will give you what you need.
Why do you do a clean install each time? A simple install should create your package and prevent any compilation, file copy if the source is older than the build artifact. You can also redeploy your application without shutting down JBoss. There is Maven goal for that. By default I think, if JBoss detect that the application file (ear or war) has been change (the timestamp is lower than deploy time) it will redeploy the application (some time redeploy is unfortunately not enough, most of the time class loader issue. Never get issue with JBoss as 7 but class loading has been redone).
If you can upgrade to JBoss AS 7, it is far quicker and Java EE 6 make your application lighter impacting positively the build time. But this may require to much refactoring.

Reloading JSP Changes in Eclipse/STS

I'm just getting into GAE and I'm using STS (derivative of Eclipse). I'm currently getting a project set up to use Spring and Apache Tiles under GAE. I've got it mostly configured properly and it seems to work. My biggest problem is figuring out how others handle day-to-day developing in this kind of environment.
I make tons of changes to the front-end JSPs but so far it seems like I have to stop the GAE server and restart it every time I make a small change to a JSP. Having to restart when I make changes to the controller is fine, but having to restart it for a simple JSP change is driving me crazy.
Is there a way to have the GAE environment reload JSP changes in Eclipse/STS?
I'm using Maven for AppEngine project, so whenever I build the project, there will be a project target directory generated/updated which is where the server will load the files from. When I tried to update my jsp/css/js files, I always open the file in that directory and update it there. Once I'm satisfied with the it, I will copy the changes to my source file.
Essentially, I think for you, you can find out where is your target directory, and try to edit your files from there.
I'm not sure if my workaround is suitable for you but maybe you can get one or two here.
Apart from that, there are people using JRebel which is a hotdeploy tool. There is a AppEngine version of JRebel there, but I suspect it is not free...
I'd suggest to take a look at JRebel. Even if it is commercial software, it will save you a lot of nerves for this kind of development
You need to set parameter:
server.jsp-servlet.init-parameters.development=true
(Put it into application.properties if you use spring boot)

IntelliJ forcing me to restart my app on every code change

I am on Grails 1.3.5 and IntelliJ 9.0.4 on a Mac with the latest JDK
I have the simplest of Grails projects: a helloworld that simply renders a string directly from a controller. I created it through the New Project wizard in IntelliJ. That went fine and IntelliJ picks up the correct grails SDK.
The problem is that IntelliJ makes me restart the app to see any changes I make to my code, (e.g. changing the "hello world" string.
If I edit the same controller with a text editor (eg TextMate) and run the app from the command line with grails run-app I do get hot code replacement, which is obviously what I want...
Anyone got a clue?
Some points:
I strongly recommend using the latest IntelliJ X EAP (http://confluence.jetbrains.net/display/IDEADEV/IDEA+X+EAP) since Grails support has been improved a lot since 9.0.x
If your IntelliJ config files got messed up, you can easily recreate them with 'grails integrate-with --intellij'. N.B. this recreates the config files in and old format and IntelliJ suggest to upgrade them - follow this procedure
Make sure your run configuration has uses at least the same memory settings than Grails uses when run from the command line, I'm fine with setting the 'VM parameters' field to '-XX:MaxPermSize=256m -Xmx1G'
If build problems occur (in rare cases the IntelliJ's internal compiler is more strict than plain Groovy), disable the 'Make' checkbox in the run config dialog.
If the problem persists, paste a screenshot of the run configuration you're using.

Resources