Spotbugs maven plugin output in a single XML - maven

I had run spotbugs using the spotbugs-maven-plugin and it creates an XML in target folder as spotbugsXml.xml when I run the command
mvn spotbugs:spotbugs
For multi-module projects, the project creates a target/spotbugsXml.xml for every module specified. Is there a way where I can get a single spotbugs xml in the parent build directory?

Related

Run testng.xml from command prompt. I have jar that is created from Maven Project. Surefireplugin is not solving my purpose

What i have
Jar created from maven project
TestNG.xml file
What i want
Want to run testng.xml from command prompt
What i tried
Used surefire plugin in pom then executed mvn test command.
What is problem then ?
Surefire plugin will need. src folder and every time it will build project.
Any solution available ? Using jar file and testng . I dont want to use src or bin
You could use a multi-module maven project.
For example with two modules, A and B. Module A will build the jar file, and in module B, you can specify A as a dependency, and run your tests from there.

Listing maven dependencies in a directory

I want to get all the maven dependencies list for a directory containing multiple projects. I can go inside each project and use command mvn dependency:tree and consolidate all of them manually.
Is there anyway (script or command) i can get consolidate list for all the project dependencies within parent directory.
Thanks for help.
You can define a dummy project, add all your projects as dependencies and then call dependency:list on this dummy project.

Maven: Get artifact list of sub modules

I have a root parent maven module which has lot of sub-modules that build jar files as artifacts.
I cannot change all sub-module pom.xml files.
From the root parent pom.xml is there a way I can get a list of all jars (artifacts) built by sub-modules?
Preferably after the package phase is complete?
PS: As a part of root module build I want to generate a report using a tool which requires this list of jar files.
There's a target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst in a Maven project.
You can use the GMavenPlus Plugin and Walking the File Tree to gather these files and put their content where you want.
Another option is to develop an own Maven plugin that does the same.

Build child jar using parent war using maven

I need to create a dependent maven project.
The child one should be a jar, that would be called by the parent project which should be a war file.
The steps should be like this. When I build the war, it should automatically build the jar file and include it and build the war and show output of the child jar (suppose a simple print statement).
Note: Build should be done only once and that is for building the final war.
Need to edit the pom.xml accordingly.
I am new to maven,so a bit elaborate solution would be very helpful.

How to add files to a maven project executing generate goal (mvn archetype:generate)?

I'm building a maven archetype project. As parameter (serviceDescriptor), I'm passing path to an xml file. When the generate goal is successfully executed, I would like to have the serviceDescriptor file in src/main/resources. Based on maven archetype documentation, it seems that is not possible but, there should be a way to do it.
I have spent couple of days on this and I think that I have found a reasonable solution.
As I mention in the question, I'm passing the file path as required property to the archetype:generate.
I had to implement a simple plug-in that is executed after archetype generate is finishing. This plug-in is coping the file into src/main/resources, read some data from the file and update the pom.xml setting some properties. In order to be able to modify the pom.xml file I'm using maven-model-2.0 archetype as dependency in maven plug-in. It offers Maven MvenXpp3Reader and MavenXpp3Writer classes that allows to safe modify pom.xml.
In order to tell to archetype project to execute plug-in at the end of generate phase of archetype:
mvn archetype:generate -goals=plugin_groupId:plugin_artifactId:goal
The downside is that the plug-in should be available in a accessible repository or local repo.

Resources