Jenkins JDepend Plugin reports JAR classes - maven

I am using 1.467 and Jenkins JDepend plugin 1.2.3.
When I build, it generates the JDepend report.
No problem.
THe problem is that I get reports on classes like:
org.apache.commons.fileupload
org.hibernate.ejb
Packages report on classes that I didn't write.
How I configure this so that it JDepend only run on classes that I write?
com.mycompany.myproject
for example.
Thanks.

JDepend Maven Plugin looks quite old and seems to be in beta. It does not support a way to exclude packages/classes. I assume jenkins JDepend Plugin uses the information from this to generate the report.
JDepend itself provides options to include/exclude classes/packages from analysis. JDepend ant task provides support for this as well.
One possibility would be to use jdepend ant task using maven antrun plugin (or directly invoke jdepend using maven exec plugin) to do the analysis and specify the report file to jenkins plugin for reporting.

i got it to work by setting the goal to "jdepend:generate" and setting the Pre-generated JDepend file to "target/jdepend-report.xml"

Related

Maven surefire plugin output test summary xml?

I am in a project that uses the Surefire and Failsafe maven plugins to run unit and integration tests respectively. The output of failsafe produces a summary of the test run in target/failsafe/failsafe-summary.xml. I would like to get a similar .xml summary report from surefire, however I can only seem to get an xml file per test suite there.
Is it possible to configure surefire to do this?
Is it possible to configure surefire to do this?
(create 1 report file/run instead of 1/test suite)
No, not without customizing surefire/surefire-report plugin.
Since the only (up-to-date) "output related" configuration options (of surefire-plugin:test) are:
encoding
redirectTestOutputToFile
reportFormat (default - "brief", alternatively - "plain" (*.txt files))
reportNameSuffix
reportsDirectory
And surefire-report plugin's only purpose is maven report (html!) generation.
For this special need, I'd recommend a custom script or (maven) plugin (basing on one of the above - they are open source). You can also try "to tackle the problem from source" by combining all of your test classes/suits into one!? :)

What is the purpose of the # symbol in <groupId>#project.groupId#</groupId>?

I'm trying to run 'mvn clean install' in a sub-module of a multi-module project. The project is Jacoco but I assume it's more an issue of me not understanding how Maven is being used here than an issue with Jacoco itself.
https://github.com/jacoco/jacoco/blob/master/jacoco-maven-plugin.test/it/it-site/pom.xml
I get the following error:
[ERROR] Plugin #project.groupId#:jacoco-maven-plugin:#project.version#
or one of its dependencies could not be resolved: Failed to read
artifact descriptor for
#project.groupId#:jacoco-maven-plugin:jar:#project.version#
I see the following in the pom:
<groupId>#project.groupId#</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
I'm not familiar with using the # symbol in #project.groupId# although i assume it is somehow supposed to get substituted at runtime.
I can run Maven from the top level pom and I even see [INFO] Building: it-site/pom.xml in the log but a target directory is not created there.
A nudge in the right direction would be appreciated.
This probably has something to do with the pom file here: https://github.com/jacoco/jacoco/blob/master/jacoco-maven-plugin.test/pom.xml
It is using a plugin called the maven invoker.
The Invoker Plugin is used to run a set of Maven projects. The plugin can determine whether each project execution is successful, and optionally can verify the output generated from a given project execution.
And if you read about filtering files with this plugin, it mentions:
POM files selected by the include/exclude patterns. The tokens to be filtered must be enclosed in #...# to avoid interferences with Maven's normal POM interpolation, i.e. use #project.version# instead of ${project.version}.
Regarding why the Invoker Plugin and filtering is being used here...
The Spring Boot documentation provides some relevant background on why that is. Although the docs are for Spring Boot, i think it applies to testing all plugins (which Jacoco is).
Multi-module Maven builds cannot directly include maven plugins that
are part of the reactor unless they have previously been built. ...
The standard build works around this restriction by launching the
samples via the maven-invoker-plugin so that they are not part of the
reactor.
The sample application are used as integration tests during the build
(when you mvn install). Due to the fact that they make use of the
spring-boot-maven-plugin they cannot be called directly, and so
instead are launched via the maven-invoker-plugin.

How to configure/use CheckStyle in Hudson/Jenkins?

I want to learn how to use CheckStyle.
I am doing static code analysis in Hudson, as first part, I installed Static Analyser and CheckStyle plugins in Hudson. But I am not able to find out how to use it in official Hudson checkstyple page also.
official page : http://wiki.hudson-ci.org/display/HUDSON/Checkstyle+Plugin
I saw some documents in Maven checkstyle plugin that we have to mention some configuration in pom file and run the targets.
Then, I got doubt, if I am doing with Maven, why we need the CheckStyle plugin install in hudson?
Is it possible to configure CheckStyle in Hudson job for a Java project instead of changing in pom or not? It here is both ways, then which one is better?
Do you have the steps to configure CheckStyle plugin in Hudson?
If you've installed the plugin in Jenkins/Hudson, you should now be able to add the checkstyle goal to your project/job.
In the goals section of your Jenkins Maven job, add "checkstyle:checkstyle" to enable the checkstyle plugin to analyse your project.

How to setup jenkins to run Selenium / Maven / TestNG

I'd like to be able to run by Jenkins a series of test from Selenium. I've see a lot of topic about the subject but it's not clear to me.
Do I need to call maven to run the project or can I directly call Testng ?
Also do I need with Jenkins to call my project using maven or using Ant ?
What is the best practice. Is there specific plugin that I need.
Do I need to call maven to run the project or can I directly call Testng ?
You can call testng through maven or ant. There is no direct runner plugin for Jenkins.
What is the best practice. Is there specific plugin that I need.
You might need the TestNG plugin to show the results inside Jenkins, but it is optional. Best practice is to use maven or ant. You can find a nice ant example here
You can use run TestNG scripts in Jenkins with or without Maven. Maven as a build tool, in my opinion, looks more robust and gives you more flexibility than Ant.
To run pure TestNg script in Jenkins, enter the following in the 'build' section:
D:>java -cp "Pathtolibfolder\lib\*;Pathtobinfolder\bin" org.testng.TestNG testng.xml
Click on Save button.
Note: The actual path of lib and bin folder need to add the in above
command.
After saving the command, Jenkins will build project in predefined
time, and this command will run using TestNG.
The result will be stored in custom report HTML file that can be sent via
email with a small Jenkins configuration

Publish JavaDoc on Jenkins with maven

I have maven project that is built by Jenkins-CI.
How to generate and publish JavaDoc on Jenkins?
Make sure Jenkins javadoc plugin is installed.
Go to http://yourjenkinsserver.com/jenkins/pluginManager/installed to see list of intalled plugins.
Plugin page https://wiki.jenkins-ci.org/display/JENKINS/Javadoc+Plugin
Configure Jenkins job:
In Build section, Goals and options line add:
javadoc:javadoc
That's all. No need to change pom.xml
The simplest thing to do is to create a separate task that runs thr javadoc command, and which runs after the compile task. You pass it the input and output directories.
I would run a separate tomcat for your CI website - it's easier.

Resources