Sonar Squid Error while sonar analysis with jenkins job through maven - maven

I am using jenkins for continous integration build process through maven and using sonar for code review as well. jenkins job is working fine for creating build but when sonar analysis starts, it throw below error..
[ERROR] [19:19:47.494] Squid Error occurs when analysing :D:\Jenkins_New\jobs\Sample_Maven_Project\workspace\src\main\java\software\bean\UserBean.java
org.sonar.squid.api.AnalysisException: The source directory does not correspond to the package declaration software.bean
"
I'm stucked in this issue.
below is my project 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nuc</groupId>
<artifactId>nuc</artifactId>
<version>0.1</version>
<packaging>war</packaging>
<name>nuc</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>neutrino-central-repository-Nexus</id>
<name>Neutrino Central Repository</name>
<url>http://10.1.50.56:9081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>neutrino-central-plugin-repository-Nexus</id>
<url>http://10.1.50.56:9081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>WebContent</directory>
<targetPath>/${project.build.directory}/${project.build.finalName}</targetPath>
<includes>
<include>**/*.*</include>
</includes>
</resource>
<resource>
<directory>src/META-INF</directory>
<targetPath>/${project.build.directory}/META-INF</targetPath>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
<webXml>WebContent/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</project>

This error means that the ".java" source files are not located in a correct folder.
If your project is a Maven project, chances are that the ".java" source files are located in <project>/src/main/java - like the convention suggests it.
However, from what I see in your POM, you have set the source folder to be "src" instead of "src/main/java". This is why you get this error.

Related

Issue in Compiling SOA 12C project with Maven

I am trying to build my SOA 12.2.1.0.0 project with Maven3.2.5 and using the default Maven local repository.I have done the below steps:
1.Installed the Maven synchronisation plugin to the local respository(mvn install)
2.Pushed all the required libraries to the local repository using Push goal
3.Updated the archetype to reflect the newly installed libraries.
When I am trying to compile the project using Maven, I am getting the below errors like:
1.0-SNAPSHOT: Failed to collect dependencies at com.oracle.adf.library:BC4J-Service-Runtime:pom:12.2.1-0-0' 'No
versions available for
com.oracle.legacy_oc4j_xml_schemas:com.oracle.webservices.fmw.web-common-schemas-impl:jar:[12.2.1,12.2.2)
within specified range
The com.oracle.legacy_oc4j_xml_schemas of the repository contains a folder(com.oracle.webservices.fmw.web-common-schemas-impl) with a single file resolver-status.properties having the content:
maven-metadata-central.xml.error=
maven-metadata-central.xml.lastUpdated=1468297090681
Below is the effective pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.oracle.soa</groupId>
<artifactId>sar-common</artifactId>
<version>12.2.1-0-0</version>
<relativePath></relativePath>
</parent>
<groupId>MavenIntegrationApplication</groupId>
<artifactId>TestProjectMaven</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>sar</packaging>
<description>Oracle FMW Common Parent POM</description>
<url>http://www.oracle.com/us/products/middleware/overview/index.html/sar-common/TestProjectMaven</url>
<inceptionYear>2012</inceptionYear>
<properties>
<password></password>
<scac.input>D:\JDEVWorkspace-12C\TestProjectMaven/SOA//composite.xml</scac.input>
<oraclePassword></oraclePassword>
<overwrite>true</overwrite>
<composite.partition>default</composite.partition>
<regenerateRulebase>false</regenerateRulebase>
<scac.error>D:\JDEVWorkspace-12C\TestProjectMaven/target/error.txt</scac.error>
<oracleServerUrl>http://localhost:7003</oracleServerUrl>
<scac.output.dir>D:\JDEVWorkspace-12C\TestProjectMaven/target</scac.output.dir>
<composite.revision>1.0</composite.revision>
<oracleHome>${env.ORACLE_HOME}</oracleHome>
<forceDefault>true</forceDefault>
<scac.displayLevel>1</scac.displayLevel>
<composite.name>TestProjectMaven</composite.name>
<input>TestProjectMaven</input>
<keepInstancesOnRedeploy>false</keepInstancesOnRedeploy>
<scac.output>D:\JDEVWorkspace-12C\TestProjectMaven/target/out.xml</scac.output>
<scac.input.dir>D:\JDEVWorkspace-12C\TestProjectMaven/SOA/</scac.input.dir>
<oracleServerName>soa_server1</oracleServerName>
<oracleUsername></oracleUsername>
<serverUrl>http://localhost:7003</serverUrl>
<scatest.result>D:\JDEVWorkspace-12C\TestProjectMaven/target/testResult</scatest.result>
<oracleMiddlewareHome>/home/myhome/Oracle/Middleware</oracleMiddlewareHome>
<user></user>
</properties>
<dependencies>
<dependency>
<groupId>com.oracle.adf.library</groupId>
<artifactId>SOA-Designtime</artifactId>
<version>12.2.1-0-0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.adf.library</groupId>
<artifactId>SOA-Runtime</artifactId>
<version>12.2.1-0-0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.adf.library</groupId>
<artifactId>BPEL-Runtime</artifactId>
<version>12.2.1-0-0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.adf.library</groupId>
<artifactId>Mediator-Runtime</artifactId>
<version>12.2.1-0-0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.adf.library</groupId>
<artifactId>MDS-Runtime</artifactId>
<version>12.2.1-0-0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>D:\JDEVWorkspace-12C\TestProjectMaven\src\main\java</sourceDirectory>
<scriptSourceDirectory>D:\JDEVWorkspace-12C\TestProjectMaven\src\main\scripts</scriptSourceDirectory>
<testSourceDirectory>D:\JDEVWorkspace-12C\TestProjectMaven\src\test\java</testSourceDirectory>
<outputDirectory>D:\JDEVWorkspace-12C\TestProjectMaven\target\classes</outputDirectory>
<testOutputDirectory>D:\JDEVWorkspace-12C\TestProjectMaven\target\test-classes</testOutputDirectory>
<resources>
<resource>
<directory>D:\JDEVWorkspace-12C\TestProjectMaven\src\main\resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>D:\JDEVWorkspace-12C\TestProjectMaven\src\test\resources</directory>
</testResource>
</testResources>
<directory>D:\JDEVWorkspace-12C\TestProjectMaven\target</directory>
<finalName>TestProjectMaven-1.0-SNAPSHOT</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.oracle.soa.plugin</groupId>
<artifactId>oracle-soa-plugin</artifactId>
<version>12.2.1-0-0</version>
<extensions>true</extensions>
<configuration>
<compositeName>TestProjectMaven</compositeName>
<composite>D:\JDEVWorkspace-12C\TestProjectMaven/SOA//composite.xml</composite>
<sarLocation>D:\JDEVWorkspace-12C\TestProjectMaven/target/sca_TestProjectMaven_rev1.0-SNAPSHOT.jar</sarLocation>
<serverUrl>http://localhost:7003</serverUrl>
<user></user>
<password></password>
<compositeRevision>1.0</compositeRevision>
<revision>1.0</revision>
<scacInputDir>D:\JDEVWorkspace-12C\TestProjectMaven/SOA/</scacInputDir>
<input>TestProjectMaven</input>
</configuration>
</plugin>
<plugin>
<groupId>com.oracle.maven</groupId>
<artifactId>oracle-maven-sync</artifactId>
<version>12.2.1-0-0</version>
<configuration>
<serverId>internal</serverId>
<oracleHome>D:\OracleSOA12C\Oracle_Home</oracleHome>
<testOnly>false</testOnly>
</configuration>
</plugin>
<plugin>
<groupId>com.oracle.adf.plugin</groupId>
<artifactId>ojdeploy</artifactId>
<version>12.2.1-0-0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<ojdeploy>${env.ORACLE_HOME}/jdeveloper/jdev/bin/ojdeploy.exe</ojdeploy>
<workspace>D:\JDEVWorkspace-12C\TestProjectMaven/../MavenIntegrationApplication.jws</workspace>
<project>TestProjectMaven</project>
<profile>TestProjectMaven</profile>
<outputfile>D:\JDEVWorkspace-12C\TestProjectMaven\target/TestProjectMaven-1.0-SNAPSHOT.jar</outputfile>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>D:\JDEVWorkspace-12C\TestProjectMaven\target\site</outputDirectory>
</reporting>
</project>
Can someone help me solve this issue, if I have missed to do some steps.
I think you should remove <type>pom</type> of your dependencies.
If I understand your problem correctly, you have Oracle libs (most likely JARs) provided somewhere so you don't want Maven to include these libs in your packaging. But as you indicate <type>pom</type>, Maven is trying to get the POM of these dependecies and it's not working.
This issue is resolved.It was because not all dependent jars were getting installed using the PUSH command(reason is unknown).After few more trials(deleting and reexceuting the commands), all the jars got installed and now the all the goals are hetting executed successfuly.
Thanks for all the help!

Where to specify the repository element for Artifactory release?

I am trying to release a project in the Artifactory repository. It’s a project which is a dependency of my main project, so I would like to put the pom, the .jar and the sources.jar in the artifactory repository.
The settings.xml file is stored in the maven directory :
D:\...\...\maven\apache-maven-3.3.1\conf
I have already tagged the version using following maven command :
mvn clean release:prepare
Then, if I try :
mvn clean release:perform –Partifactory
, I get the error :
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project ........ : Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
What should I do to use the artifactory profile ? Is it possible without changing the pom ?
I have tried without success to copy the settings.xml in my local maven repository.
If I have to change the pom, can I first come back before the state obtained after the mvn release:prepare command ? In the following link, I didn’t understand if I have to do something manually or not (remove tag from the SCM) :
http://maven.apache.org/maven-release/maven-release-plugin/examples/rollback-release.html
The settings.xml file :
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>D:\...\...\maven\repository</localRepository>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://x/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://x/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://x/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://x/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
The pom :
<?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">
<parent>
<groupId>....</groupId>
<artifactId>my-parent</artifactId>
<version>1.0.6</version>
<relativePath />
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>....</groupId>
<artifactId>myproject</artifactId>
<packaging>jar</packaging>
<version>1.9.6-SNAPSHOT</version>
<name>myproject</name>
<url>${wiki.url}</url>
<scm> <developerConnection>scm:svn:http://x/svn/main/y/Development/Components/trunk/myproject</developerConnection>
<url>http://x/svn/main/y/Development/Components/trunk/myproject</url>
</scm>
<ciManagement>
<system>${ciManagement.system}</system>
<url>${ciManagement.url}/${project.artifactId}</url>
</ciManagement>
<properties>
</properties>
<dependencies>
<! - - my dependencies - - >
</dependencies>
<build>
<plugins>
<plugin>
<inherited>false</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.1</version>
<configuration> <tagBase>http://x/svn/main/y/Development/Components/tags</tagBase>
</configuration>
</plugin>
</plugins>
</build>
</project>
The parent pom :
<!-- language: lang-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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>....</groupId>
<artifactId>my-parent</artifactId>
<packaging>pom</packaging>
<version>1.0.6</version>
<name>my-parent</name>
<url>${wiki.url}</url>
<scm>
<developerConnection>scm:svn:http://x/svn/main/y/Development/Components/tags/my-parent-1.0.6</developerConnection>
<url>http://x/svn/main/y/Development/Components/tags/my-parent-1.0.6</url>
</scm>
<ciManagement>
<system>${ciManagement.system}</system>
<url>${ciManagement.url}/${project.artifactId}</url>
</ciManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
</plugin>
</plugins>
</build>
</project>
Two things. You should declare a <distributionManagement> section in your POM:
<project>
...
<distributionManagement>
<repository>
<id>my-artifactory</id>
<name>Artifactory Release Repo</name>
<url>http://x/artifactory/libs-release</url>
</repository>
<snapshotRepository>
<id>my-artifactory</id>
<name>Artifactory Release Repo</name>
<url>http://x/artifactory/libs-snapshot</url>
</snapshotRepository>
</distributionManagement>
</project>
The <id> tags must match an entry in your settings.xml for the credentials to match:
<settings>
...
<servers>
<server>
<id>my-artifactory</id>
<username>bob</username>
<password>secret</password>
</server>
</servers>
</settings>
Now, that being said, since mvn release:prepare has already tagged the release in your VCS, you don't need to cut a new release, but I would advise you to add the <distributionManagement> section to the POM. One way to deploy the artifacts is to simply get the tag from the VCS and do an mvn deploy, like so:
svn co <the url to your tag>
mvn -DaltDeploymentRepository=my-artifactory::default::http://x/artifactory/libs-release deploy

Maven release process consistently failing : svn: E175013: Access to '/svn/tester/!svn/bc/170' forbidden

I have been banging my head for quite a while now and I have actually learnt lots of this issues on stackoverflow an pretty sure I covered some of the common mistakes(besides,I have done several releases with bitbucket and github) that were starring at me. But still I have not been able to release anything. I feel like it's time to shout for a little help :)
I use a self hosted subversion managed by usvn and a sonatype private nexus repository. I have a multi module maven project arrange in a parent and sub module model.
Below is the snippet of the parent pom that is relevant
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<excludes>
<exclude>**/*ITest.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>${project.build.sourceEncoding} </encoding>
<meminitial>128m</meminitial>
<maxmem>512m</maxmem>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<encoding>${project.build.sourceEncoding} </encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<preparationGoals>clean verify -DenableIT=true</preparationGoals>
<tagBase>https://repo.mysvnserver.com/svn/tester/tags</tagBase>
</configuration>
</plugin>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>maven-apt-plugin</artifactId>
<version>1.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<distributionManagement>
<repository>
<id>dal</id>
<url>http://nexus.mynexusserver.com/nexus/content/repositories/releases</url>
</repository>
</distributionManagement>
<scm>
<connection>scm:svn:https://username#repo.mysvnserver.com/svn/tester</connection>
<developerConnection>scm:svn:https://username#repo.mysvnserver.com/svn/tester</developerConnection>
<url>https://repo.mysvnserver.com/usvn/project/tester/browser</url>
<tag>tester</tag>
</scm>
Below is my settings.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<settings >
<localRepository>/home/joseph/.m2/repository</localRepository>
<servers>
<server>
<username>username</username>
<password>password</password>
<id>nexus</id>
</server>
<server>
<username>username</username>
<password>password</password>
<id>dal</id>
</server>
</servers>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>central</mirrorOf>
<url>http://nexus.mynexusserver.com/nexus/content/repositories/public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>dal</id>
<url>http://nexus.mynexusserver.com/nexus/content/repositories/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
Since it would probably too much to put the output here , please find it on paste.ee .
I am more convince this is either configuration issue on subversion side because things looks fairly ok to me. Can anyone point out something I am missing?
Thanks
The SCM part of your POM looks not related to an actual SVN branch (or the trunk) of a project. For the SCM-linked part of the release plugin to work, I guess an SCM configuration closer to what is described in the SCM plugin should be made. A project POM SCM information should describe where to get the source code related to that exact project version, not the root project location.
I guess that without this, SVN can trigger unexpected authorization issues as you are in fact trying to access an URL where you might not have set permissions.

ant task retrieve maven profile dependency

i have a java project with a automatically generated ant files. so i'm forced to use ant to build the project. I needed to add some new libraries and i used the below maven pom file. i then use an ant task to retrieve the pom dependencies and copy them into a lib folder. however the following ant task misses the profile dependencies in the pom.
what i want to do is an ant task so that based on current os it will include the corresponding xurlrunner jar for the os. this is done by maven in the pom but how can i do it with ant ?
---ant target task----
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="urn:maven-artifact-ant"
classpathref="maven-ant-tasks.classpath"/>
<target name="retrieve-dependencies">
<artifact:dependencies filesetId="dependency.fileset"
sourcesFilesetId="profiles.dependency.fileset"
versionsId="dependency.versions">
<pom file="${basedir}/nbproject/pom.xml"/>
</artifact:dependencies>
<delete dir="${lib.dir}/browser"/>
<copy todir="${lib.dir}/browser">
<fileset refid="dependency.fileset"/>
<mapper classpathref="maven-ant-tasks.classpath" classname="org.apache.maven.artifact.ant.VersionMapper"
from="${dependency.versions}" to="flatten"/>
</copy>
</target>
---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>org.drOffice.browser</groupId>
<artifactId>embedded-browser</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerVersion>1.6</compilerVersion>
<encoding>UTF-8</encoding>
<source>1.6</source>
<target>1.6</target>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugins>
</build>
<repositories>
<repository>
<id>atomation-repository</id>
<name>atomation maven repository</name>
<url>http://atomation-repository.googlecode.com/svn/trunk</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>ru.atomation.jbrowser</groupId>
<artifactId>jbrowser</artifactId>
<version>1.9</version>
<scope>compile</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>generic</id>
<activation>
<activeByDefault></activeByDefault>
</activation>
</profile>
<profile>
<id>linux</id>
<dependencies>
<dependency>
<groupId>ru.atomation.native</groupId>
<artifactId>xulrunner-linux</artifactId>
<version>1.9</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>solaris</id>
<dependencies>
<dependency>
<groupId>ru.atomation.native</groupId>
<artifactId>xulrunner-solaris</artifactId>
<version>1.9</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>macosx</id>
<dependencies>
<dependency>
<groupId>ru.atomation.native</groupId>
<artifactId>xulrunner-macosx</artifactId>
<version>1.9</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>windows</id>
<dependencies>
<dependency>
<groupId>ru.atomation.native</groupId>
<artifactId>xulrunner-windows</artifactId>
<version>1.9</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
If you only use Ant to copy the dependencies, I assume it would be by far simpler to use maven to copy these dependencies.
If you really want to use Ant, you can simply define the property in your pom (in the profile), and use it in the Ant script.
Something like
<profile>
<id>linux</id>
<properties>
<custom.property>linux</custom.property>
<properties>
.....

Maven reports it ran the test suite but did not run any of my JUnit tests

I am trying to test a java app from Maven using JUnit.
I have the following POM (relevant section only).
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>2.7.2</version>
</dependency>
</dependencies>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
It seems "something" is being run. Here is the output from "mvn -X test":
Running TestSuite
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.769 sec
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
Notice the "Running TestSuite". However it still fails to find my test methods. I suspect it might have to do with this:
[DEBUG] Adding to surefire test classpath: /home/julien/.m2/repository/org/apache/maven/surefire/surefire-testng/2.4.3/surefire-testng-2.4.3.jar
[DEBUG] Adding to surefire test classpath: /home/julien/.m2/repository/org/apache/maven/maven-artifact/2.0/maven-artifact-2.0.jar
[DEBUG] Adding to surefire test classpath: /home/julien/.m2/repository/org/codehaus/plexus/plexus-utils/1.0.4/plexus-utils-1.0.4.jar
[DEBUG] Adding to surefire test classpath: /home/julien/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
[DEBUG] Adding to surefire test classpath: /home/julien/.m2/repository/org/apache/maven/surefire/surefire-api/2.4.3/surefire-api-2.4.3.jar
It says it is using version 3.8.1 of Junit...
However it goes on to say:
Test Classpath :
[DEBUG] /home/julien/.m2/repository/junit/junit/4.8.2/junit-4.8.2.jar
I wonder what is the difference between the "surefire test classpath" and the "Test classpath"?
Here is how my test method is named and annotated:
#Test
public void test() {
...
It is located here:
src/test/java/com/cheetah/web/pages
Any idea what I am getting wrong?
Here is the effective 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>
<parent>
<artifactId>cheetah</artifactId>
<groupId>com.cheetah</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.cheetah</groupId>
<artifactId>cheetah-web</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>cheetah-web</name>
<build>
<sourceDirectory>/home/julien/Documents/donnees/projets/site-emploi-finance/java/cheetah/web/src/main/java</sourceDirectory>
<scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
<testSourceDirectory>/home/julien/Documents/donnees/projets/site-emploi-finance/java/cheetah/web/src/test/java</testSourceDirectory>
<outputDirectory>/home/julien/Documents/donnees/projets/site-emploi-finance/java/cheetah/web/target/classes</outputDirectory>
<testOutputDirectory>/home/julien/Documents/donnees/projets/site-emploi-finance/java/cheetah/web/target/test-classes</testOutputDirectory>
<resources>
<resource>
<mergeId>resource-2</mergeId>
<directory>/home/julien/Documents/donnees/projets/site-emploi-finance/java/cheetah/web/src/main/java</directory>
<includes>
<include>**/*.tml</include>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<mergeId>resource-3</mergeId>
<directory>/home/julien/Documents/donnees/projets/site-emploi-finance/java/cheetah/web/src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
<testResources>
<testResource>
<mergeId>resource-1</mergeId>
<directory>/home/julien/Documents/donnees/projets/site-emploi-finance/java/cheetah/web/src/test/resources</directory>
</testResource>
</testResources>
<directory>/home/julien/Documents/donnees/projets/site-emploi-finance/java/cheetah/web/target</directory>
<finalName>cheetah-web-1.0-SNAPSHOT</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-4</version>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.3.2</version>
</plugin>
<plugin>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<artifactId>maven-rar-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.0-beta-8</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>2.0</version>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.0.4</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.3</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-beta-1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-beta-1</version>
</plugin>
<plugin>
<artifactId>maven-help-plugin</artifactId>
<version>2.1.1</version>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>java.net</id>
<url>http://download.java.net/maven/1</url>
<layout>legacy</layout>
</repository>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>jboss</id>
<name>jboss</name>
<url>http://repository.jboss.org/maven2/</url>
</repository>
<repository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<updatePolicy>never</updatePolicy>
</snapshots>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<updatePolicy>never</updatePolicy>
</snapshots>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
</pluginRepository>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>com.cheetah</groupId>
<artifactId>cheetah-domain</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.cheetah</groupId>
<artifactId>cheetah-service</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-core</artifactId>
<version>5.2.6</version>
</dependency>
<dependency>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-beanvalidator</artifactId>
<version>5.2.6</version>
</dependency>
<dependency>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-spring</artifactId>
<version>5.2.6</version>
</dependency>
<dependency>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-test</artifactId>
<version>5.2.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.0.5.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>2.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<reporting>
<outputDirectory>/home/julien/Documents/donnees/projets/site-emploi-finance/java/cheetah/web/target/site</outputDirectory>
</reporting>
</project>
Running junit tests in maven requires minimal setup. Add junit to your dependencies:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
Create a class in src/test/java/com/cheetah/web/pages:
public class FooTest {
#Test
public void writingToStdOut_succeeds() throws Exception {
System.out.println("I work!");
}
}
Run mvn test. That's all. There's no need to configure anything in the surefire plugin. It's no different for a war project vs. a jar project. If you do these two things and it doesn't work, then something is misconfigured somewhere else, and we'll probably need to see the whole pom or, better yet, the effective pom to tell what's going on.
Note that Surefire will only run either testng tests or junit tests but not both in the same build.
Just to mention what everyone already knows, but what still catches me out every now and again. Remember that there is a naming convention to what tests will be "seen" and if you don't name the test class correctly, it is ignored.
running
mvn -X test
shows us (trimmed down):
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test' with basic configurator -->
[DEBUG] (s) additionalClasspathElements = []
...
[DEBUG] (s) excludes = [**/Abstract*.java]
[DEBUG] (s) includes = [**/*Tests.java, **/*Test.java]
So, by default, only classes ending "Test.java" or "Tests.java" will be picked up.
In my case problem was with maven version dependecy. I added it manually and I made a mistake.
Advise:
You should always add dependencies by "Insert Dependency" menu. It can be displayed by using shortcut "crtl"+"space" when your cursor is between <dependency> and </dependency> in your xml file. When you in "Select Dependency" menu enter "junit" in "Enter..." textbox and choose your version of junit. After clicking "ok" your dependency will be automatically added. This helps avoid problem with incorrect version typed manually.

Resources