I need to run sonar on a Zend project using maven.
Everything works fine except that Sonar ignores the unit tests completely and does not run them or show their results in the report.
No errors of any kind are reported in the log.
I am using:
PHPUnit 3.6,
Zend 1.11,
Sonar 3.7
here is my pom:
<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>quickstart</groupId>
<artifactId>quickstart</artifactId>
<name>quick start</name>
<version>1.0</version>
<!-- For the moment, specify pom as packaging for php projects -->
<packaging>pom</packaging>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</pluginManagement>
<sourceDirectory>${basedir}/web</sourceDirectory>
<testSourceDirectory>${basedir}/tests</testSourceDirectory>
</build>
<properties>
<sonar.projectKey>org.codehaus.sonar:quickstart</sonar.projectKey>
<sonar.projectName>PHP project quick start</sonar.projectName>
<sonar.projectVersion>1.0</sonar.projectVersion>
<sonar.language>php</sonar.language>
<sonar.sourceEncoding>UTF-8</sonar.sourceEncoding>
<sonar.dynamicAnalysis>false</sonar.dynamicAnalysis>
<excludesAppli>**/library/**</excludesAppli>
<sonar.exclusions>${excludesAppli}</sonar.exclusions>
<sonar.phpCodesniffer.argumentLine>--ignore=**/library/** </sonar.phpCodesniffer.argumentLine>
<sonar.phpDepend.argumentLine>--ignore=**\library\**</sonar.phpDepend.argumentLine>
<sonar.phpPmd.argumentLine>--exclude **\library\**</sonar.phpPmd.argumentLine>
<sonar.phpUnit.coverage.analyzeOnly>false</sonar.phpUnit.coverage.analyzeOnly>
<sonar.phpUnit.analyzeOnly>false</sonar.phpUnit.analyzeOnly>
<sonar.phpUnit.analyze.test.directory>true</sonar.phpUnit.analyze.test.directory>
<sonar.phpUnit.skip>false</sonar.phpUnit.skip>
<sonar.phpUnit.coverage.skip>false</sonar.phpUnit.coverage.skip>
<!--<sonar.phpUnit.mainTestClass></sonar.phpUnit.mainTestClass> -->
<!--<sonar.phpUnit.configuration>${basedir}/tests/phpunit.xml</sonar.phpUnit.configuration> -->
</properties>
any ideas what I am missing?
Solved I need to edit:
<sonar.dynamicAnalysis>false</sonar.dynamicAnalysis>
to
<sonar.dynamicAnalysis>true</sonar.dynamicAnalysis>
Related
I have an error in my karaf feature project wher I run my mvn install. Here is the 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.dmasoft.karaf.example</groupId>
<artifactId>assemblies-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.dmasoft.karaf.example.feature</groupId>
<artifactId>dmasoft-feature</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>feature</packaging>
<name>${project.groupId}/${project.artifactId}:${project.packaging}:${project.version}</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
When I run my mvn clean install I get this error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install (default-install) on project dmasoft-feature: NoFileAssignedException: The packaging plugin for this project did not assign a main file to the project but it has attachments. Change packaging to 'pom'. -> [Help 1]
The maven-install-plugin:3.0.0-M1 was released as of 01/10/2018
Since, I got the same error with flexmojos projects where packaging was set to .
Solution is to set the version for the maven-install-plugin to the previous version (2.5.2) explicitly so it won't resolve the version automatically.
Note: I had to do this for the maven-deploy-plugin too. There may be others.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</build>
Now you can change mule.tools.version to 1.7 1.7 instead of setting maven plugins version if you are using it.
I have a Java web application deployed using Tomcat. I want to package the Tomcat ROOT into .WAR file using Maven. Can someone guide me through the process?
Thank you
Create a pom.xml file in the ROOT directory with the following code.
<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>package</groupId>
<artifactId>artifactid</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>project</name>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
Then execute the following command in the command line mvn:clean install.
The war file will be generated to the target directory.
Is there a way to run a war module automatically when I run the parent project?
To make it clear, I did three separate maven project (db, core and presentation), then I made a parent project which include the 3 projects mentioned before.
I'd like to get the presentation module running when I run the parent project.
Also, I want to know if it's possible to save the hole work from the parent project to my git account.
<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>com.project.xxxxxxx</groupId>
<artifactId>parent-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parent-project</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<targetJdk>1.7</targetJdk>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<port>8080</port>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${targetJdk}</source>
<target>${targetJdk}</target>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>../project-db</module>
<module>../project-core</module>
<module>../project-presentation</module>
</modules>
<dependencies>
</dependencies>
</project>
You need to specify the sub-project under tag.
You may refer http://books.sonatype.com/mvnex-book/reference/multimodule-sect-simple-parent.html for example
Your modules should be unter your parent in the file structure. Like
parent-project
pom.xml
project-db
pom.xml
project-core
pom.xml
project-presentation
pom.xml
Then you have to change the parent pom:
<modules>
<module>project-db</module>
<module>project-core</module>
<module>project-presentation</module>
</modules>
I'm trying to build Xcode app with maven plugin, i worte pom.xml as shown in below
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yqlabsEnterprise.SampleMaven</groupId>
<artifactId>SampleMaven</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>xcode-lib</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>com.sap.prd.mobile.ios.mios</groupId>
<artifactId>xcode-maven-plugin</artifactId>
<version>1.14.0</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
i installed maven, and run with maven using terminal, but my app not build successfully, i got error
"Failed to execute goal com.sap.prd.mobile.ios.mios:xcode-maven-plugin:1.14.0:prepare-xcode-build (default-prepare-xcode-build) on project SampleMaven: Execution default-prepare-xcode-build of goal com.sap.prd.mobile.ios.mios:xcode-maven-plugin:1.14.0:prepare-xcode-build failed: A required class was missing while executing com.sap.prd.mobile.ios.mios:xcode-maven-plugin:1.14.0:prepare-xcode-build: Lorg/sonatype/aether/RepositorySystem"
will you please help me to solve this issue.
You'll need to downgrade to Maven 3.0.x since the plugin is not compatible with later versions of Maven. The reason is that the Java package org.sonatype.aether.* has been renamed to org.eclipse.aether.*.
I'm facing a problem with maven build. I have several ejb projects. After maven build the jar-file contains the maven descriptor in META-INF/maven twice, i.e. if I extract files to disk 7zip asks to overwrite files although extracted to a new folder. If a specify <addMavenDescriptor>false</addMavenDescriptor> in the archive-tag of the ejb plugin then the maven decriptor is still generated but only once. Is there another place where I can disable maven descriptor generation or does anybody know the reason for the duplicate generation?
Maven version is: 3.0.3
Project structure is like:
-pom
-ejb
Here is the pom.xml of the EJB module:
<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>
<parent>
<artifactId>TestMavenDescriptors</artifactId>
<groupId>de.test</groupId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>TestEJB</artifactId>
<packaging>ejb</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version>
<configuration>
<ejbVersion>3.1</ejbVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Here is the pom.xml of the parent project.
<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>de.test</groupId>
<artifactId>TestMavenDescriptors</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>TestEJB</module>
</modules>
</project>
I found out that this is a problem special to eclipse version (I have RAD 8 trial) and possibily of the m2e plugin version. The above behavior (duplicate generation of maven descriptors) occurs only if I have the EJB project in my workspace added. That means if I remove the EJB project from workspace (without deleting contents on disk) such that only the hierarchal parent maven project (pom packaged) is existing in the workspace (which contains the EJB project but EJB project is then not known to eclipse) then everything works fine. Strange, isn't it?!
BTW: on current eclipse (java ee package) this doesn't occur, all fine there.