I've a parent pom project with various submodules. I want to get a report of the unit tests results but using surfire plugin, I get an independent result for each module.
I mean, if I execute:
mvn surefire-report:report
from the parent directory where the parent pom is located, it creates a surefire-report.html for each subproject but what I want, is only one html with the results of all the subprojectes.
Is there any way to achieve this automatically? Using surefire or some other plugin.
To create the aggregate report please try to use the following command at theparent project.
mvn surefire-report:report -Daggregate=true
I hope this may help.
Related
I am using the swagger codegen maven plugin to generate a server stub from a swagger spec. If I run mvn compile then it generates properly and compiles the project. However, sometimes I want to run just the generate.
Specifically, I'd like to avoid both compiling the whole project and also running another plugin (checkstyles) which runs in the validate phase. Ideally, I'd like to generate the generated classes from the swagger spec and compile those classes but not the project as a whole.
The use case here is that while developing I may need to update the spec and re-generate at points when the project as a whole isn't valid (or won't be, with the new spec). I've read that you can use "prefix:goal". I've tried the following, but none work:
mvn swagger-codegen-maven-plugin:generate
mvn swagger-codegen:generate
mvn swagger:generate
mvn codegen:generate
It gives (e.g.)
No plugin found for prefix 'codegen' in the current project and in the
plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available
from the repositories
I also read that you could use "groupid:artificatid:version_goal" so I tried:
mvn io.swagger:swagger-codegen-maven-plugin:2.4.0-SNAPSHOT:generate
This seems to get further but gives an error
Failed to execute goal
io.swagger:swagger-codegen-maven-plugin:2.4.0-SNAPSHOT:generate
(default-cli) on project com.carus.api.base: The parameters
'inputSpec', 'language' for goal
io.swagger:swagger-codegen-maven-plugin:2.4.0-SNAPSHOT:generate are
missing or invalid
My pom structure is slightly complex. There are several APIs. Each is in some ways their own project. They have a common parent pom with the execution goal in, and the project pom only sets certain variables. The variable used as inputSpec is defined in the project pom, but the one for language in the base pom. (The .base project mentioned here is actually where the base pom is, and is an abstract package (<packaging>pom</packaging>). If I specify a specific project I get the same error but referring to that project.
Questions:
Can I even achieve what I want (generate code from the spec and
compile just that code but not the whole project) with a goal?
How to find out what "prefix" to use for the "prefix:goal" syntax?
The closest I have come is run mvn generate-sources -Dcheckstyle.skip=true. This generates but I don't think it compiles the generated classes. So I then have to clean the project in Eclipse to trigger it to recompile.
How to find out what "prefix" to use for the "prefix:goal" syntax?
The prefix for the plugin should be in this file: "swagger-maven-plugin-2.3.1.jar/META-INF/maven/com.github.kongchen/swagger-maven-plugin/plugin-help.xml".
<plugin>
<name>Swagger Maven Plugin</name>
...
<goalPrefix>swagger</goalPrefix>
...
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.
I have a multimodule Maven project, it is analyzed using the Sonar Maven runner and coverage is done with Jacoco. For our integration tests we want to see the coverage across all modules (because they are integration tests after all).
Therefore we configure the jacoco-it.exec file to be in ${user.dir}, with the appendproperty to true. This way all modules append their information to the same location and coverage is calculated over all modules.
But since append is true the file will still be there on a next run, since it isn't placed in a directory that maven cleans. This leads to incorrect coverage reports.
What is the best way to clean up this file after a sonar run? Ideally I would like to configure this in the same pom profile as our jacoco/sonar configuration, so that no other projects need to remember to set a clean step in Jenkins or whereever. The sonar/jacoco configuration is in a company wide parent pom file.
Since you are using Maven, you could try and use the maven-antrun-plugin to delete the file.
I don't know how you run Sonar Maven, but you can either bind the maven-antrun-plugin task to a phase after the one the Sonar Maven Runner is bound to (and you would have the file deleted automatically and the end of each run) or you can call the maven-antrun-plugin from the command line.
I am working on multimodule project, and my project include 7 modules . I am using clover to create aggregate report but first thing is that clover.db is creating for every module. And second thing is that it works fine when i use command like:
mvn clean install
but when i write command like :
mvn clover2:instrument clover 2:aggregate clover2:clover
its failing.After building 5 modules its fails and say that some dependency is not found. while when i build it works fine.
I am posting you the pom.xml file on which i am calling these commands
Actually aggregate doesn't work properly in multi module projects and it's still an open issue for clover team. If I create the reports without using aggregate goal it works fine and also a consolidated report.
so
mvn clover2:instrument clover2:aggregate clover2:clover
works fine.
I had a similar problem with PMD plugin. Try deleting (or renaming) your ~/.m2/repository directory and re-running the build. Alternatively, delete from your local repository just the jar that contains the class or dependency that is "not found."
Is it possible to combine the capabilities of an archetype and a normal Maven plugin into a single plugin?
I have a custom language which I can compile into Java source code. I've written a Maven plugin which does this in the generate-sources phase, adds the Java source to the project, and builds the project. It works as I'd expect.
However, to use it, I need to first write out a pom.xml file referencing my plugin and describing where the input files live. I'd like to be able to go straight from raw input files to compiled code in a single maven command.
For example, suppose I have this directory structure:
my-project/
some-input-file.dsl
I want to run
bash$ mvn com.waisbrot.plugin:generate -DgroupID=com.waisbrot package
and after Maven's done running have:
my-project/
some-input-file.dsl
pom.xml
target/
generated-sources/
plugin/
SomeInputFile.java
classes/
com/
waisbrot/
SomeInputFile.class
some-input-file-1.0.jar
Actually, the integration testing of the archetype allows you to declare the parameter and goals. So do this:
Pick the template project you want to create
mvn archetype:create-from-project. It will create a new archetype
Review src/test/resources/projects, especially goal.txt and archetype.properties (source: http://maven.apache.org/archetype/maven-archetype-plugin/integration-test-mojo.html). Tweak so install will be implicity
mvn verify will be able to build the archetype, run the it, and get it installed
Hope it helps