I have a maven based project. There are four different projects like shown in the structure below. Each main project and the subprojects have their own pom.xml files.
ProjectA
|
--------subProjects
ProjectB
|
--------subprojects
ProjectC
|
--------subProjects
ProjectD
|
-------subprojects
I am running mvn site on ProjectC which is dependent on ProjectB which is inter-dependent on ProjectA and ProjectB
So when i run maven site all the test results for all these projects get created individually. What I would also like to do is to create a aggregation of all the test results in these projects and sub-projects and show it in one place.
So is it possible with maven site?
Yes. There are two options:
"You can do this by setting project.build.directory on all of your projects to a common folder."
You can add extra directories to the maven-surefire-report-plugin by adding an reportsDirectories element with reportsDirectory children (documentation).
So this should work:
<reportsDirectories>
<reportsDirectory>../ProjectA/target/surefire-reports</reportsDirectory>
<reportsDirectory>../ProjectA/module1/target/surefire-reports</reportsDirectory>
...
</reportsDirectories>
A bit different approach would be to see test results in specialized servers like Jenkins or Sonar. This way no need to modify existing projects.
See running examples at https://builds.apache.org/ and https://analysis.apache.org/
Two screenshot from Sonar:
Result by module and package
For Jenkins there is Dashboard View Plugin
Related
I have a root project and few sub projects.
The root project, in it's build.gradle file, adds some configurations, tasks, plugins and dependencies to subprojects.
In the subprojects's build.gradle file i have added additional deps, plugins, task and conf.
Now i want to know the effective build configuration of the subproject. Is it possible to get this info using any gradle command. If yes, is the same possible in intellij idea
(In maven I can get the effective configuration of any project using mvn help:effective-pom no matter if it's a submodule or has a parent pom. And in intellij idea i can right-click on the pom and choose to view the effective pom. It's quite simple. )
Edit:
Like Rob mentioned in comments - The below commands can be used to find any projects (parent or child/sub-project) dependencies in various scopes/configuration.
/gradlew :<sub-project-name>:dependencies
and
./gradlew :<sub-project-name<:dependencies --configuration <name-of-configuration>
And the Maven equivallent of the above would be mvn dependency:tree.
But I am interested in knowing other info also besides dependencies. Other info like: tasks, plugins, repositories etc that is applicable for the sub-project (i.e defined in the sub-project + inherited or applied from/by parent project.
maven mvn help:effective-pom == gradle ????
I have a Maven project with several modules, with a structure similar to:
project
module-1
pom.xml
module-2
pom.xml
..
module-N
pom.xml
pom.xml
I have defined the Artifactory Maven plugin in the parent pom.xml which is under project, like it is done in the examples they offer on their website and I've also tried the example they have in git.
My problem is that I don't want to publish to Artifactory all the artifacts generated by the parent pom, but only those under certain modules, so I tried defining the plugin in the parent pom with the tag <publishArtifacts>false</publishArtifacts> and then defining the plugin again on the modules which contain artifacts I really do want to deploy with <publishArtifacts>true</publishArtifacts>, however no artifact is deployed.
If I try the other way, only specifying I do not want to publish Artifacts on the modules I don't, it does deploy all ignoring that configuration.
How should this be done using this plugin?
You can use the publisher\excludePatterns in the artifactory plugin section of the pom.xml to exclude artifacts from being published.
you can declare multiple patterns with wildcards, and separate each with a comma.
For example, if you are using the sample from
"https://github.com/JFrogDev/project-examples/tree/master/artifactory-maven-plugin-example"
then, setting you're pom with
<excludePatterns>multi3*.war,multi2*.jar</excludePatterns>
would exclude those files from being published to Artifactory.
hope that helps...
I have my project code structure something like
module1
submodule1
submodule2
module2
submodule1
submodule2
module3
submodule1
submodule2
pom.xml
If I want to exlude the full directory module1 from sonar analysis, how to do that?
I tried multiple options like skiModules, exlusions, could not succeed.
Currently, the best option is to define a profile (in your POM) in which you redefine the list of modules that you really want to analyse (so in your example, you won't list module1). Then, when running a SonarQube analysis, you have to activate this profile:
mvn sonar:sonar -PsonarQubeAnalysisProfile
Note that we should soon implement a feature that will allow you to set a property "sonar.skip" in the POM of the modules that you want to exclude in order to make all this simpler. Please watch and vote for the following JIRA ticket: MSONAR-91
In your sonar-project.properties file add the following (to exclude multiple directories use comma separated folder paths)
sonar.exclusions=module1/**, module2/**
And while running the sonar runner I got the following in the log
Excluded sources:
module1/**
module2/**
There are multiple modules in my application . All of them are maven projects .
So I am working on creating a parent pom for all these projects and was able to create one and ran maven build on this parent pom and works fine build
But when I opened the project in eclipse , the parent pom was not included in the projects displayed so it was picking it up for the build process to take place . My project structure is as follows
ProjectA
|
--------subProjects
ProjectB
|
--------subprojects
ProjectC
|
--------subProjects
ProjectD
|
-------subprojects
Pom.xml
So what do I need to make an eclipse recognise this parent pom ? I created another maven module and made it parent pom . But is there any way i could avoid creating another project and achieve the above scenario ?
One thing you can do is to import the global structure as a maven project on its own and then import the subprojects one by one as maven project in eclipse.
you can use mvn eclipse:eclipse in the command line for all the project one by one, and then you can select by importing(Maven Project Type) all the maven projects if you select the directory on the top of your maven projects.
In this case you make all settings in the pom and no additional configs in eclipse.
I have a multi module maven project. One of the modules is a reusable part which is packaged into a jar, and the other is a war web-app which depends on the first module. When I use jetty:run-exploded on the second module, the packaged jar is taken from local maven repository whereas I want the first module to be rebuild and packaged into the resulting war. Is there any way to force such behavior instead of the default one?
From everything I can tell from reading documents about Maven's design and using Maven myself this cannot be done in the projects own directory.
Maven will not follow module paths UP a hierarchy. Using -amd (also make dependencies) will only work at the top level module that ties all the other multi-module pom's together. So what you can do is this:
At the TOP level directory
mvn -amd -pl jetty_module jetty:run-exploded
I think you can use maven Advanced Reactor Options to archive this.
http://www.sonatype.com/people/2009/10/maven-tips-and-tricks-advanced-reactor-options/
The -pl or –projects option allows you to select a list of projects from a multimodule project. This option can be useful if you are working on a specific set of projects, and you’d rather not wait through a full build of a multi-module project during a development cycle.
Maven -amd(also-make-dependents ) also help to build multi module project once. Using that you can build a project and any project that depends on that project.