Configuring Maven, jenkins with Sonar - maven

I have installed Jenkins and Sonar, both work fine. I am able to build a maven android project using Jenkins. No i want to run Sonar on the android project. I have installed the Sonar plugin in Jenkins. Configured the sonar module in the configure system module and added a post build task for sonar to run
[ERROR] Plugin org.codehaus.mojo:sonar-maven-plugin:sonar or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:sonar-maven-plugin:jar:sonar: Could not find artifact org.codehaus.mojo:sonar-maven-plugin:pom:sonar in nbs-repo (http://10.10.2.89:8081/nexus/content/groups/public/) -> [Help 1]
org.apache.maven.plugin.PluginResolutionException: Plugin org.codehaus.mojo:sonar-maven-plugin:sonar or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:sonar-maven-plugin:jar:sonar
at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:129)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor(DefaultMavenPluginManager.java:142)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor(DefaultMavenPluginManager.java:261)
at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor(DefaultBuildPluginManager.java:185)
at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.getMojoDescriptor(MojoDescriptorCreator.java:235)
at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:106)
at
My nexus installation works fine ? What am i doing wrong. My maven pom.xml does not contain any sonar plugin. What am i doing wrong?
Kind Regards

From the error message its clear that mvn is trying to download the sonar-maven-plugin from your local Nexus repository which does not seem to have it.
Try mvn -U in the build in case you already have the plugin.This overrides the negative cache. Another thing is <updatepolicy> in your settings.xml
If you don't have the plugin and neither does your Nexus connect to the internet, you have to manually download and upload in Nexus of course. Please remember to match the version of the plugin with the SONAR installation. Also there would be a few (7-10) transitive dependencies with the plugin which you will need. I suggest using mvn -X or mvn -e to see a verbose output during your testing.

Related

Spring project creating a bug in pom.xml need help to fix it

CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 has not been downloaded from it before.
Any chance you're running maven in offline mode? Please check that you don't use -o option.
If you have to work in offline mode you should first download all the required dependency (one time):
mvn dependency:go-offline

Integrate the local maven plugin with remote repository

I have created a simple maven plugin and installed it in my local repo(.m2). Now I want to use that plugin with a git repo(maven project). How can I do that?
Currently, I am trying to build my git repo using Jenkins and it throws below error-
[ERROR] Plugin sample.plugin:hello-maven-plugin:0.0.1-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact sample.plugin:hello-maven-plugin:jar:0.0.1-SNAPSHOT
I believe simply changing the pom file of my git repo won't work. What should I do so that it resolves the plugin dependency by looking into the .m2 dir first
Your Jenkins probably deploys to a Nexus or Artifactory server. That server is also the right place to manage your plugin.

Not able to create a Maven Project. I am using eclipse photon

Error thrown is
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6
I have checked maven installation using cmd and it shows there. I think some issue with pom.xml or settings.xml is there but not sure. I am new to Maven.

Could not find artifact and could not resolve dependencies

I'm working in a maven project which contains many dependencies, i have a dependency from a centralized remote NEXUS repository ,so i should have a specific configuration in my setting.xml..
so When i launch clean install from the maven tab in intellij it displays errors:
ERROR] Failed to execute goal on project calender: Could not resolve
dependencies for project com.orange:calender:war:1.0-SNAPSHOT: Could
not find artifact com.francetelecom.clara.component:security:jar:3.0.0
in central (https://repo.maven.apache.org/maven2) -> [Help 1]
but when i switch to the Terminal tab in intellij the build succeed without errors and when i try to deploy the war within Tomcat it won't.
Tomcat log:
java.lang.NoSuchMethodError:
org.apache.commons.collections.ArrayStack: method (I)V not found
at org.apache.commons.digester.Digester.(Digester.java:150) at
com.francetelecom.clara.security.config.SecurityConfig.parse(SecurityConfig.java:95)
at
com.francetelecom.clara.security.SecurityManager.initialize(SecurityManager.java:114)
at
com.francetelecom.clara.security.SecurityManager.(SecurityManager.java:99)
at
com.francetelecom.clara.security.SecurityManager.getContextInstance(SecurityManager.java:371)
When running maven from maven tab in IntelliJ, you use the settings you find from Alt/Ctrl S -> Build, Execution, Deployment > Build Tools > Maven
When running from terminal in IntelliJ it will use first mvn you find on PATH and use configuration from what you get there. "mvn -version" from terminal will show you your Maven Home when running mvn from terminal

Jenkins Offline cannot able to resolve Maven Dependencies

I am trying to Build a Maven Project from Jenkins.
My server is Offline, so no Internet access or no proxy settings.
Maven Project Build absolutely perfect from Jenkins if Internet is present.
But same project fails to Build from Jenkins in absence of Internet. My repo is containing this plugin.
My Maven Home:/home/oracle/app/Trust/maven
My Jenkin Home:/home/oracle/.jenkins/
.m2 file Location:/home/oracle/.m2
Error: [ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.4.1: The repository system is offline but the artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1 is not available in the local repository. -> [Help 1]

Resources