Sonar 3.0 does no analysis but displays no errors/warnings - maven

Im using eclipse with m2e for developing and maven 3.0.4 with Sonar 3.0 for analysis.
On the console i get a "Build success" for mvn clean install and a "ANALYSIS SUCCESSFUL, you can browse..." for mvn sonar:sonar. I do not recognize any errors/warnings etc.
In sonar i can see my project, the actual version and build date but there is no analysis.
Are there any reported problems with sonar 3.0 or someone got an idea whats wrong?
Thanks a lot.
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>DungeonMasterTools</groupId>
<artifactId>DungeonMasterTools</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>${JDK_1_7_HOME}/bin/javac</executable>
<compilerArgument>-verbose</compilerArgument>
<source>1.7</source>
<target>1.7</target>
<meminitial>128m</meminitial>
<maxmem>512m</maxmem>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.2</version>
</dependency>
</dependencies>
</project>

Related

Maven in Jenkins : Doesn't find any test

I'm trying to run automatised test on Jenkins with Maven. However, when I use the command "mvn test" in a Maven Project Job, the console return me that's no test was found.
The path to my test files respect the convention (I think) and are at src/test/java/Gui/CameraTest.java
Here is my pom.xml :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>GoSecuri</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>13</maven.compiler.source>
<maven.compiler.target>13</maven.compiler.target>
<jenkins.e2eTests.reportsDirectory>target/protractor-reports</jenkins.e2eTests.reportsDirectory>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.google.firebase/firebase-admin -->
<dependency>
<groupId>com.google.firebase</groupId>
<artifactId>firebase-admin</artifactId>
<version>6.8.1</version>
</dependency>
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>opencv</artifactId>
<version>4.0.1-1.4.4</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.0.0-M5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.0.0-M5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Can anyone help me pls ?
maven-surefire-plugin
2.19
add this piece and try to build from testng.xml and don't forget to add your runner class to your testng.xml
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/java/runners/testNG/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>

How to execute maven project from command line

Below is the message I received every time when I ran MVN TEST on the project folder from command line.
[INFO] No tests to run.
[INFO] ----------------
[INFO] BUILD SUCCESS
My Testscripts location is below. I went to the below folder and ran mvn test from the command line.
/Copy of naukri/src/testScripts/NewTest.java
Below is the POM file of the project
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>naukri</groupId>
<artifactId>NewTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>NaukriUpdate</name>
<description>----------------</description>
<build>
<sourceDirectory>../src/testScripts/</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<testSourceDirectory>../src/testScripts/</testSourceDirectory>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<manifest>
<mainClass>testScripts.NewTest</mainClass>
</manifest>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<systemPropertyVariables>
<propertyName>firefox</propertyName>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.10</version>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Move your test in
src/test/java
Please look at see documentation https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html

Tomcat 7 deployment fails. org.apache.commons.codec.binary.Base64 not found

I am trying to deploy a web application to a Tomcat 7 instance using the tomcat7-maven-plugin's tomcat7:deploy goal. However, it continuously fails to deploy, citing that:
java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64
All of the posts I've read suggest adding the Apache commons-codec to pom.xml. I have done that and it doesn't do a bit of good. I tried manually downloading the JAR and placing it in the WEB-INF/lib folder but that also had no effect.
Here is my pom.xml file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edu.uta</groupId>
<artifactId>MavAppoint</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>MavAppoint Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>7.0.59</version>
</dependency>
</dependencies>
<build>
<finalName>MavAppoint</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>TomcatServer</server>
<path>/MavAppoint</path>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</build>
</project>
I have tried changing the scope for the commons-codec but nothing has worked so far. It's been driving me absolutely nuts! Any advice would be greatly appreciated.
I ended up using the "Run on Server" option in Eclipse to run the application instead of trying to deploy the application to the Tomcat installation on my computer.

Maven+ReportNG+Jenkins+Command Line

I would like to know how can I run a test built with maven to generate the report and then convert the report to ReportNG format using the command line.
To after that insert the report on Jenkins using the plugin HTML Reporter from Jenkins.
I want to do this because I am getting error when I put the listeners on test.
I am using this to execute the test by Jenkins:
mvn test (after using "mvn clean install" on first time)
I try use mvn install but I am getting the same error
Thanks
EDIT: So I finally manage to fix my POM file, the problem has some plugins that aren't specified like velocity, reportng and guice. Anyway I will left here my POM fixed so it can help someone else =)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>selenium.simple</groupId>
<artifactId>selenium-simple</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>selenium-simple</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.7</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.24.1</version>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>velocity</groupId>
<artifactId>velocity-dep</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<!-- specify UTF-8, ISO-8859-1 or any other file encoding -->
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<systemPropertyVariables>
<webdriver.ie.driver>src/main/resources/drivers/internetexplorer/iedriverserver_2.24.1_x64.exe</webdriver.ie.driver>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Based on the error message:
Some problems were encountered while building the effective model
forselenium.simple:selenium-simple:jar:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. # line 43,
column 12
You should pin the version for maven-surefire-plugin like the following:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
...
</plugin>
</plugins>
..
</build>
If don't do this as you you will use an old version (maven-surefire-plugin:2.10) which might be too old. I assume that after you put the version into your pom the problems with the listener will be gone.
BTW: Why not using up-to-date versions of maven-resources-plugin (2.6) and testng (6.8.7)..

axis2, Maven and IntelliJ

I am trying to generate Java classes for a Web Service client using axis2. I keep getting a Cannot resolve symbol 'wsname_ServiceStub' The java file is not being picked up. Meanwhile the 'wsname_ServiceCallbackHandler' the java file in the same directory is getting picked up and I can reference to it from the rest of my project.
The file is showing up as a "not a class file" for some reason
I'm using IntelliJ 11.1.2 and Maven 2.2.1
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>AnotherWS</groupId>
<artifactId>AnotherWS</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis-wsdl4j</artifactId>
<version>1.5.1</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-idea-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2code-maven-plugin</artifactId>
<version>1.6.2</version>
<configuration>
<!--<generateTestcase>true</generateTestcase>-->
<!--<outputDirectory>${project.build.directory}/generated-sources</outputDirectory>-->
<packageName>wsname</packageName>
<wsdlFile>src/main/resources/wsname.wsdl</wsdlFile>
<!--<generateAllClasses>true</generateAllClasses>-->
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2code</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Resources