I have a maven project with a couple of child modules. One is a new maven plugin. Another one is a test module where I want to run my newly developed plugin to ensure that it works fine.
In the test module I do a normal reference to my plugin: build > plugins > plugin > <definition of my plugin>. And then if I executed mvn clean test it works fine. The plugin is being compiled and later, in the next module it is executed.
But there are a couple of problems with this setup:
When I do mvn clean execution fails with plugin cannot be resolved as the second module does not have even compiled version of the plugin.
In IDE (Intellij IDEA) reimport of maven modules fails with the same problem.
I do not want to do mvn install to have it locally so the dependencies are resolved as I do changes quite frequently and do not want to reinstall it every time.
I do not want to write integration tests instead of running the plugin directly as I want a realistic test and moreover, the plugin setup is quite tricky and would be hard to replicate that in a test.
I thought that I could use systemPath to reference the plugin but I am not sure if that will work and how to set it up.
Related
I inherited a multi-module Maven project that had been maintained using Eclipse, and now I really want to use VSCode instead.
It seems the VSCode best practice (based on this video) is to run mvn war:exploded and then right-click target/classes to launch each of the modules into Tomcat.
This is very laborious for a project with several modules, and also time-consuming considering I need to run mvn package before mvn war:exploded every time the code is changed.
Is there a way to setup VSCode to remove some or all of the recurring manual steps, and provide an experience that feels more like incremental compile & hot-deploy?
I have a java spring-boot project with maven as my build framework.
I do have several plugins configured that do annotation processing during the compilation phase (mapstruct, lombok, etc).
One of those plugins has a bug and doesn't work well within IntelliJ.
That causes my build to fail if I simply try to build a module (all of my annotation processors are properly configured as it worked fine in the past, it's the upgrade to jdk14 caused an avalanche effect, spring-boot along with a bunch of libs and plugins had to be upgraded).
I figured that there is an option to delegate all build/run actions to Maven. And it works pretty well.
Except that I used to select a SpringBootTest and run it, now, when I do that it initiates a maven sequence, that triggers clean and install goals.
It doesn't make sense in my case as I have plenty of other modules that are hooked to compile goals: Checktyle, PMD, SpotBugs, Surefire, etc.
I would like the execution of a test to compile source code and run that particular test class/case.
Is that doable?
I am currently working on a project that involves utilizing Gephi's backend tools and frontend visualizers. For this, I have cloned Gephi's repository, https://github.com/gephi/gephi.git. The following tutorial walks users through how to clone and modify Gephi's sourcecode so that you may add "circle creation logic" to Gephi's visualizer, https://seinecle.github.io/gephi-tutorials/generated-html/working-from-the-source-en.html. I have found that running the project through NetBeans is a straightforward process, build the dependencies and run.
Unfortunately, such an option doesn't exist in IntelliJ and the maven "Lifecycle" goals that I can run (clean, validate, compile, test, package, verify, install, site, and deploy) build successfully, but does not actually run the project within the environment unlike NetBeans does. I am wondering what I am missing here, or how NetBeans can simply run the maven project node, but such an option doesn't exist in IntelliJ? How do I perhaps edit my run configuration within the IntelliJ IDE so that I can run such an instance?
The equivalent in IntelliJ IDEA would be the following:
Run the compile goal
Run nbm:cluster-app
Run nbm:run-platform
The last 2 goals are provided by the nbm Maven plug-in.
In IntelliJ IDEA they are visible under the Plugins node of the module in the Maven tool window:
For a Maven-driven project in IntelliJ 2018, when should I choose to use…
The IntelliJ 2018.1 menu item Build > Rebuild Project
The Maven panel’s clean and install Lifecycle items
Under what circumstances is either appropriate?
My situation is a Vaadin 8 application using the vaadin-archetype-application-multimodule Vaadin archetype.
The Question, Does IntelliJ Build > Rebuild Project invoke maven? has a single Answer that says the Rebuild Project does not invoke Maven at all. But no guidance is given on when to use route versus the other.
Well, if you make substancial changes within a pom.xml file (new plugins, new modules within a multi-module project), you'd better run "mvn clean install". I personally never use the "Rebuild Project" within a Maven project. usually I just "make" the project so the class files are updated, or I start a real Maven build to get new / updated dependencies.
The third important option (for me) is the "Reimport all Maven projects" option, which is quite useful if a pure Maven build runs fine, but IntelliJ still thinks that there is something wrong within your project.
When you have a multi-module Maven project and:
Start your tests and application programmatically by IntelliJ (Main.java):
You do not need to use Maven at all, no clean, no install, only Make. And Rebuild when the project gets screwed up.
Click Reimport when you change dependencies or someone deploys a new dependency snapshot to your repo.
If IntelliJ refuses to download the snapshot, then try mvn clean install.
And why would you even do all that? It is faster and more user friendly.
Start your tests and application by Maven in IntelliJ (mvn jetty:run):
You have to install your modules which are as dependencies for the module on which you start your application (mvn jetty:run), because Maven does not use your compiled output for dependencies, but takes an artifact from your remote/local repository. For this case Make/Rebuild is useless, you have to use mvn (clean) install.
If you have made changes only in a module on which you run mvn jetty:run then you do not need to use package/install, but sometimes you have to use clean or Rebuild as Maven does not remove deleted resources.
Make is good for hot-swap - for that reason, it is a good idea to import all Maven projects you develop and on which you depend into a single IntelliJ project. Initial Rebuild comes handy, because without it, Make would compile the whole project instead of only changed classes, then possibly failing hot-swap or it would just take too long.
Or you could just click Make before you run your application, but it could leave some old resources created by Maven in compiled output, Rebuild would take care of that.
You can also configure your app-server to restart/reload when it detects updated files from Make or Rebuild - certainly faster than restarting the JVM or compiling by Maven, but you might like to disable that and use only hot-swap, which is still way faster if you do small changes.
Either way you might want to take a look at Maven Helper plugin for IntelliJ, it will make things way easier in big projects.
My team is regularly facing inconveniences when running a Maven project that depends on other Maven projects which were modified but not reinstalled to the local repository.
For the sake of simplification, let's say I have two Maven projects Business and Web. My Web project has in its dependencies the Business project, and a Jetty plugin which allows me to run a local web server for development.
In IntelliJ, both projects are opened on the same window using Maven Add project, so that I can navigate through the code easily between the two projects.
Currently, I have set up a Run Configuration in IntelliJ so that mvn clean install -DskipTests will run on the Business project, and then mvn clean jetty:run on Web. This allows me to run Web with the latest modifications made in Business. If I don't run clean install on the Business project, then Web will run on an older version of the source code of Business. In addition this will mess up the IntelliJ debugger as the source code being debugged will not match the runtime class.
In a real application, a Dependency Injection Bootstrap project may depend on Web, Business, Some Database Adapter X, Some Database Adapter Y, Some API Client Adapter... therefore the clean install may become costly. In addition it is easy to forget to build the dependee project, which is the reason why the Maven goals are always run before running Jetty.
Is there a way to be more efficient during development, so that a modification on a dependee project will be active when running the dependant projects without having to run any/many Maven goals?
Create a tiny parent project pom.xml which references both Business and Web as modules. Then tell Intellj to open the parent project - this will let Web access Business (if properly referenced) without having to install the artifacts locally.