How to pass on changements on server without to be forced to build manually all sub-modules changed? - maven

Hello all !
In my team we currently use Eclipse but I am not satisfied and I wanted to discover netbeans (8 version). It seems very nice. There is a good management of webprojects( angularJS, requirejs). There is a full integration of maven project and Java EE project, it's free ( not like intelliJ) and it seems more intuitive than eclipse et less strange/magic , more compréhensible (because full integration of maven)
There is a lot of points who could push my team to adopt this IDE but there is a problem,a need that I can not satisfy.
I have maven modules projects with dependency mangement. A parent project (called 'webParent' that contains a reference of a big parent project of the team. 'webParent' also contains a sub project 'WebProject' that is a java Webproject that contains web resources( html, js, css) and a java rest webservice management.
'WebProject' use service by injection dependency of an other project called 'business'. 'business' is a part of an other parent project called 'core'. 'core' contains modules that are 'business' (business services of application), 'dataAccess' (gather all DAO), 'External' (gather all external webservice) and 'Authent' (authentication ..).
All these core modules are linked.
'business' need => 'dataAccess' , 'External', 'Authent'
'External' need => 'dataAccess'
'Authent' need => 'dataAccess'
Netbeans has perfectly integrated my project, no problem with that.
I could perfectly use my previous jboss install. Netbeans and jboss work perfectly together. but my problem is that my modifications are not take in account by jboss on redeploy.
I have installed this plugin in my webproject https://docs.jboss.org/jbossas/7/plugins/maven/latest/
Indeed it work fine. When I need to redeploy my project I launch jboss-as:redeploy and a war is regenerated and sent to jboss. Jboss restart speedly and it's cool. But if I modify the java code
in my sub-modules (ex: business) I am forced to click on build button (the hammer) on each sub project I modified. Wait that build say "nothing to compile (indeed the compile on save is checked for all project), regeneration of the jar module"
And I stop on this detail. The "jar". Indeed when I verify my local repository my module jar is not changed with compile on save, it's just the target folder of the project that is modified.
So when I launch the redeploy, the plugin launch the build of my webproject who search my modules jars on my local repository. And take a version not modified ..
This problem slowed a lot the developpement and because of it my team will never use netbeans in the future..
The other problem is that I am forced to lauch jboss-as:redeploy to redeploy web ressource (html, css, js) . For me its should be automatically repercuted on my server. But the problem is that jboss use a war that is generated on install.. What's the solution ? With eclipse it's not based entirely on maven (not cool) but the repercution of modification is very speed ( cool)
Help me to stay on netbeans ! ;)

Related

How to setup multiproject structure with maven?

I'm fairly unexperienced and all new to the whole world of build tools so here's my situation: I am developing a webapp with JSF, PrimeFaces and Hibernate on wildfly-9.0.2-final. All java files (incl. ManagedBeans, DAOs, Model classes, etc.) are currently in a regular eclipse java project called MyApp-CORE. There is no html or any other resources in that project, but all the third-party libraries like PrimeFaces, commons-xy, etc. Then I got two dynamic web projects with all the .xhtml files and stuff. Both web projects include the CORE in their build path (all done via eclipse built-in tools). Basically I followed Structure for multiple JSF projects with shared code so far. All projects are versioned using Git. I was now asking myself how to mavenize the whole thing and also how to properly include tests. The final result should be:
I want a build file for each web project that includes the CORE dependency and all of it's transitive dependencies, creates a .war file and deploys it either on the production system or locally (Depending on some parameters I want to be able to maintain).
This buildfile could then for instance test and build the CORE and then the .war file.
Since I'm using JSF, mostly the only option for testing is JSFUnit. Should I test each web project individually and put all the test cases there (which would be highly redundant because they're mostly the same, just a few features are different) or should I rather create a separate web project called MyApp-TEST which tests the CORE.jar and also - depending on some configuration - each web project.
I've already created a structure that makes it possible to include the core in the web project but unfortunately I loose the perks of hot deployment in wildfly when just including it as a dependency from my local maven repository.
So, to summarize it:
What would be a best practice for this setup, eventually leading to a continuous integration scenario?
How should I include the test cases (full integration tests that test actual UI behaviour)?
Which Tool (Maven, Gradle, Ant, etc.) would be best for that task?
Keep using hot deployment for smooth development?
Thanks in advance for any comments, hints or shared experience!

Library development/debug with Maven

I am in the processing of integrating Maven into my my projects. While maven has plenty of pros i'm finding it difficult to figure out how to maintain my current development process, which is as follows:
For creating SDKs I will create a sample app, which will depend on and directly reference the SDK source code, all from within the same code project. This means that I can make easily change/debug the SDK code with one click run/debugging.
I fear this won't really be possible with Maven. Can I create some type of Hybrid approach, where I continue my normal development approach and then push builds to Maven when it is appropriate.
Update - For Clarity
My problem is that when everything is done through maven, the dependencies are built and published to Maven. Then, the dependent project pulls down compiled references and uses them. My issues is that I don't want to go through this whole process every time I make a small change to a dependency.Thanks.
You should try creating parent level pom.xml with two modules - your library and simple app to test it. In simple app's pom.xml provide a dependency on library module.
Then open in your IDE parent pom as maven project. This should be sufficient for normal debug.
Other possible approach - install you library artifact into maven repo with sources. In this case you will be able to debug it, but test app still have to load use jars from repo.

Integrating JRebel with custom Ant/Ivy/Tomcat web application with Spring MVC

I am trying to get JRebel working with a fairly large enterprise web application which uses Ant + Ivy for building/dependency management, Spring 2.0 framework and Spring MVC, and all this has to be built and deployed to Tomcat.
I have JRebel enabled on Tomcat and the Project itself. Remoting is not enabled as I assume that if Tomcat and the project are on the same machine, this is not needed. When I start the Tomcat server from within STS, JRebel appears to load fine and I see no (apparent) significant errors.
However, any changes to the project do nothing with regard to deployment, and I see no JRebel messages in the console. The project itself is a somewhat nonstandard layout and does not have the traditional WEB-INF/src structure. When I enabled JRebel on it within STS, it just dumped a rebel.xml file in the root directory.
For reference, the project is based on this codebase and has the same general structure: https://github.com/NCIP/c3pr/tree/master/codebase
While the JRebel guides are good, they only show JRebel being used with very simple projects and do not go into very much depth into exactly how the service works.
Any suggestions, resources, or ideas are greatly appreciated.
thanks
Did you actually recompile (doesn't matter if you use Eclipse or javac) those classes that you changed? It might be a good idea to check if you have "Build automatically" enabled under the "Project" menu.
They way how JRebel works is that it actually monitors the compiler output folder (usually "bin" folder or "build/classes" or something similar).
This folder (or folders) is specified in the rebel.xml file and the file must be in the classpath of your application while you run it (WEB-INF/classes or on the jar file root or in the exploded dir).
Can you make sure, that rebel.xml is actually in the applications classpath?
Also, you should see the message in the console that says something like:
"JRebel: Directory '/path/to/project/bin' will be monitored for changes.".
And also, if you see the JRebel banner in your console, it is useful to check if the license is found (if it is not found then JRebel will not work).
Sometimes there may also be some mismatch when your Eclipse compiles classes to the "bin" folder and your build scripts compile them to under "build/classes" and only one of these locations is specified in the rebel.xml file. In this case, JRebel will monitor only one of them and then it is confusing too.
Wishing the best,
Sigmar

Update dependencies while in hosted mode in GWT

I have a GWT webapp split into two Maven projects where one is a dependency to the other. Each time I change something in the dependency and I'm running webapp in hosted mode I have to rebuild the subproject and restart hosted mode for changes to apply. It takes a lot of time so I'd like to ask you if there is any way to make GWT using "live" version of the dependency?
There are 2 cases:
for server-side code, assuming you use the DevMode's embedded server, rebuilding the app and then refreshing the server should be enough
for client-side code, AFAICT, you have to use the source and output directories of the dependency module rather than the JAR containing them (GWT will load the source from the classpath, but apparently it'll only see the modified sources if it comes from a folder rather than a JAR; at least that's what I found in my tests). This goes against The Maven Way™ but the only solution so far is to use a special profile that will import the sources of the dependency project as sources of the project you're running. You can see examples of that in my archetypes.
There's actually a bug opened for the gwt-maven-plugin, MGWT-332, to do that automatically when running a reactor build. I also mused about what's really needed, for the forthcoming official gwt-maven-plugin (rewritten from scratch, independent from the CodeHaus Mojo plugin).
If your dependency does not come from a reactor build, then you're out on your own: you chose to make it totally distinct, so that's how it'll behave: you'll have to release it (even a snapshot) each time you make a change to it, and use the new version in your app (which means re-launching the DevMode).
This can be circumvented by running DevMode on your own, without the help of the gwt-maven-plugin. You're left on your own managing the classpath though (using the Google Plugin for Eclipse, I suppose you could simply edit the launch configuration to add the source folders of your dependency project to the classpath, before the classpath provided by Maven, that would reference the JAR).
Remove the dependent other application jar file from the primary application lib folder under webapp.
Eclipse should then resolve the dependency using the other project in the workspace if you have added it to your primary application classpath.
As GWT build takes ages, we invested some money in a JRebel license. We have two separate Eclipse projects for our back-end and our GWT front-end. JRebel reloads the classes automatically and I never need to restart my local server while writing code. It proved to be a wonderful time saver. Definitely worth the investment.

osgi projects with several poms in intellij idea

I have two maven projects with 2 poms (type). Some components from project 1 are depending on projects 2. Almost all components (maven) are osgi components.
The question is: since IntelliJ IDEA does not support multi-projects it is impossible to open two projects at the same time in one IDE instance.
Then, I believe, I'm going to have an issue to deploy my osgi components (they have are associated to OSGI Facets in IDE) to my osgi container from IDE (because it supposed to be handled by IDE, using those facets while deploying component to the osgi server, and if I can not see project 2 in my IDE then it could not handle it.. in terms of deploying and ide integration).
For example if I open two IDEs with project 1 in one, and project 2 in second ide, then if I change something in project 2 (1 depends on 2) .. should I configure the same (one) osgi sever in both IDEs, and deploy it separately?
Does someone have the same project structure, and what is the way to work with this in IntelliJ IDEA?
You can have only one IDEA project per window, but a single project can contain multiple Maven projects, see my answer in another post.
Open your first pom.xml via File > Open to create a new IDEA project, then open the Maven Projects view on the right, click on the green plus to add your second Maven project, and voila!
Once this is configured, you can create a new run/debug configuration which will deploy both artifacts on the same tomcat instance.

Resources