I have a rather large project (with quite a large stack including Spring and Hibernate) that I build through Netbeans using Maven.
Unfortunately, every time I make a change to a class, I need to rebuild. This means
This can take up to 5 minutes to check if a small change made a difference. Perhaps I have the wrong approach?
Please advise...
Creating a Maven Based NetBeans Platform Application Project. In this section you use the New Project wizard to create a NetBeans Platform Application from a Maven archetype. The wizard creates the Maven module projects that you need to develop an application on the NetBeans Platform.
mvn clean: Cleans the project and removes all files generated by the previous build. mvn compile: Compiles source code of the project. mvn test-compile: Compiles the test source code. mvn test: Runs tests for the project.
Okay, I'm also working on quite similar setup so here are my 2 cents.
First off, get your feet wet with Maven-Jetty Plugin. Make it scan the files for changes so that you don't have to rebuild/deploy the entire project for every changes. Also configure it to store session so that with every (automatic) deploy you don't have to relogin and get to the state you were at before making changes:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.24</version>
<configuration>
<stopPort>9669</stopPort>
<stopKey>myapp</stopKey>
<!-- Redeploy every x seconds if changes are detected, 0 for no automatic redeployment -->
<scanIntervalSeconds>3</scanIntervalSeconds>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<webAppConfig>
<contextPath>/myapp</contextPath>
<sessionHandler implementation="org.mortbay.jetty.servlet.SessionHandler">
<sessionManager implementation="org.mortbay.jetty.servlet.HashSessionManager">
<storeDirectory>${project.build.directory}/sessions</storeDirectory>
</sessionManager>
</sessionHandler>
</webAppConfig>
</configuration>
</plugin>
Now, go to project Properties
(by right clicking project)> Build
> Compile
> Compile on save
and select For both application and text execution
.
Also go to Options
> Miscellaneous
> Maven
> and check/select Skip Tests for any build executions not directly related to testing
, so that test are only run when you actually Run 'Test'.
Following these simple steps, I can code and test changes live, quickly and without needing a redeploy. That said, I have faced a few minor issues/annoyances:
You still have to clean-build at times when something does not work (for example, you deleted something and changes do not reflect)
Keeping it running long time can give PermGen exception (Out of space), which is reasonable and you can always increase the memory using jvm opts
you will hate to develop/test projects on containers like jboss/websphere once you get used to this setup
Give JRebel a try. http://www.zeroturnaround.com/jrebel/
BTW I'm not paid by zt - only a satisfied user.
Why do you need to run the Tests on each change? That's a huge cost, when making trivial changes. Switch it off using -DskipTests=true
Take a look at : http://wiki.netbeans.org/HotDeploymentWebApplicationWithMaven
Also, setup Netbeans to hot deploy on Tomcat (use Jetty). See this post : Incremental hot deployment on Tomcat with Maven and NetBeans.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With