Sonar 4.1.1 maven plugin can't be resolved - sonarqube

I'm using SonarQube 4.1.1 and have the following configuration in my pom.xml file:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>4.1.1</version>
</plugin>
</plugins>
</pluginManagement>
When I try to run sonar from the command line using the maven plugin I get:
[ERROR] Plugin org.codehaus.mojo:sonar-maven-plugin:4.1.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:sonar-maven-plugin:jar:4.1.1: Failure to find org.codehaus.mojo:sonar-maven-plugin:pom:4.1.1 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
Anyone know how to fix this issue? Do I need to make some configuration changes?

In fact this configuration is not needed. Have you try to run an analysis without it? You should give a try if you haven't.
But if you really need to force the version of the sonar-maven-plugin, you should set it to 2.1 on Maven 3.
See http://docs.codehaus.org/display/SONAR/Analyzing+with+Maven for more details.
Regards

Try this:
mvn clean sonar:sonar -U
The -U flag means force update of dependencies.

Related

Athena latest JDBC driver jar AthenaJDBC42_2.0.14

https://docs.aws.amazon.com/athena/latest/ug/connect-with-jdbc.html
I've installed latest jdbc jar into my local mvn repo. While i'm trying to build my project I'm getting below error.
Failed to collect dependencies at Athena:AthenaJDBC42:jar:2.0.14.1000: Failed to read artifact descriptor for Athena:AthenaJDBC42:jar:2.0.14.1000: 1 problem was encountered while building the effective model for Athena:AthenaJDBC${env.JDBC_V}:${env.MAJOR_V}.${env.MINOR_V}.${env.REVISION_V}.${env.BUILD_V}
[ERROR] [ERROR] 'artifactId' with value 'AthenaJDBC${env.JDBC_V}' does not match a valid id pattern. #
Anyone have any idea, how to resolve this error.?
It is difficult to say with just the small Maven error snippet, but it looks like Maven doesn't recognize the property ${env.JDBC_V} or it contains some invalid value like a space.
I recommend to generate a Maven effective pom model (mvn help~effective-pom) and execute Maven in debug mode (mvn -X ...) to try to troubleshoot the cause.
I was facing the same error. It got resolved when I installed jar into repository using following command. (Ensure you deleted all existing instances of athena drivers jar files from .m2 before executing command)
mvn install:install-file -Dfile=/Users/chetanparekh/Downloads/AthenaJDBC42_2.0.14.jar -DgroupId=Athena -DartifactId=AthenaJDBC42 -Dversion=2.0.14.1000 -Dpackaging=jar
Snippet from my POM.
<build>
<plugins>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>${mule.maven.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<sharedLibraries>
<sharedLibrary>
<groupId>Athena</groupId>
<artifactId>AthenaJDBC42</artifactId>
</sharedLibrary>
</sharedLibraries>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>Athena</groupId>
<artifactId>AthenaJDBC42</artifactId>
<version>2.0.14.1000</version>
</dependency>
</dependencies>
Thank you for your answer.
I finally resolved it using
mvn install:install-file -Dfile=/Users/dk/Downloads/AthenaJDBC42_2.0.14.jar -DgroupId=Athena -DartifactId=AthenaJDBC42 -Dversion=2.0.14
Removed the build version(1000) and -Dpackaing=jar, it worked. I'm not sure what could be the problem with build version .1000 and -Dpacking=jar.
Thanks Again.!

mvn dependency:go-offline doesn't download the requirements for maven-surefire-plugin

I'm trying to build an open source project in docker and want to save time spent on builds, so I tried using mvn dependency:go-offline, which does download maven-surefire-plugin itself.
Running mvn -o clean package afterwards results in
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test (default-test) on project oxalis-api: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4:test failed: Plugin org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4 or one of its dependencies could not be resolved: Cannot access apache.snapshots (http://repository.apache.org/snapshots/) in offline mode and the artifact org.codehaus.plexus:plexus-utils:jar:1.1 has not been downloaded from it before. -> [Help 1]
(I've enabled the snapshots repository because maven-dependency-plugin has serious issues with multi module projects otherwise)
The POM includes
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</pluginManagement>
and as described above, that plugin itself does exist in my repository after go-offline.
It seems that your maven local repository uses the legacy structure, details here. So the goal dependency:go-offline prepares the repository in the legacy mode, then the actual goal for building package cannot find the dependency because it uses the default mode.
So for your specific scenario you can use the following command to download the dependencies and the plugins in batch mode:
mvn dependency:resolve-plugins dependency:go-offline -B
And you can use the following for the build, with the offline, batch and legacy local repository options:
mvn package -o -llr -B
Hint: if you need additional plugin or dependencies in your build that are not explicitly defined in the main pom, like the ones you add during the build (i.e. clover, allure, pact, etc) you can pre download using the following command:
mvn dependency:get -Dartifact=org.openclover:clover-maven-plugin:4.4.1 -B
Hint 2: If you have issues when offline and the dependencies are not taken maybe it is because you have different maven settings when you download the dependencies and when you build your project. You can consider to delete the maven-metadata*.xml and _*.repositories inside the local repository, you can use this:
find ~/.m2/repository -name 'maven-metadata*.xml' | xargs -n1 rm
find ~/.m2/repository -name '_*.repositories' | xargs -n1 rm
I too was facing the same issue, changed the version from 3.0.0-M4 to 2.12 and it worked for me. I am still trying to figure out why its not working with 3.0.0-M4.

Unable to deploy release package to nexus using maven release:perform

I am getting 400 errors when I try to execute maven release: perform.
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project my-project: Failed to deploy artifacts: Cou
ld not transfer artifact com.acca.project:project:pom:1.0.0-RELEASE from/to acca-nexus (https://nexus.io/repository/project/): Failed to transfer file https://nexus.io/repository/project/myproject/myproject/1.0.0-RELEASE/myproject-1.0.0-RELEASE.pom with status code 400 -> [Help 1]
Following things I have tried
1) I verified, credentials are correct
2) URL for nexus repo is correct
3) I am maintaining the proper 1.0.0-SNAPSHOT name
4) there is no package with the same version in nexus as well
5) Not a network issue as well, I can do maven deploy properly.
Release plugin -config looks like below
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<scmCommentPrefix>[maven-scm] :</scmCommentPrefix>
<goals>deploy</goals>
<releaseProfiles>release</releaseProfiles>
</configuration>
</plugin>
I want to deploy the package when I do maven release: perform, but I am unable to debug beyond this. can someone please tell me how to debug this. Pointing out the issue will also helpful
I fixed the above issue.
The solution was in the nexus repository configuration.
I updated the configuration to "allow redeploy" and it started working.
Thank you

sonar.host.url not working with sonar-maven-plugin:2.7

After upgrading my POMs to sonar-maven-plugin:2.7 the configuration does not work any more. My configuration in settings.xml is like this:
<profile>
<id>sonar</id>
<properties>
<sonar.jdbc.url>jdbc:postgresql://my.server:5432/sonar</sonar.jdbc.url>
<sonar.jdbc.driverClassName>org.postgresql.Driver</sonar.jdbc.driverClassName>
<sonar.jdbc.username>xxxxx</sonar.jdbc.username>
<sonar.jdbc.password>yyyyy</sonar.jdbc.password>
<sonar.host.url>http://my.server</sonar.host.url>
</properties>
</profile>
The build is started with -Psonar of course. With version 2.6 everything is fine, with 2.7 I get
[INFO] --- sonar-maven-plugin:2.7:sonar (default-cli) # myproject ---
[INFO] User cache: C:\Users\me\.sonar\cache
[ERROR] SonarQube server 'http://localhost:9000' can not be reached
...
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7:sonar (default-cli) on project myproject: Fail to download libraries from server: java.net.ConnectException: Connection refused: connect -> [Help 1]
Starting the build with -X gives me the correct mojo configuration in both cases, especially the url is still correct in the log
[DEBUG] (f) sonarHostURL = http://my.server
Even deleting the mentioned caching directory does not help.
What can I do except of managing the plugin to version 2.6?
We are investigating the issue. Ticket was created: https://jira.sonarsource.com/browse/MSONAR-129
In the meantime you could either lock the SQ plugin to version 2.6 or pass all properties using command line.
Workaround: Adding -Dsonar.host.url=http://my.server:9000 to mvn command works for me
Better than disabling the plugin, you may fix the plugin version to 2.6, which works fine, taking into account sonar.host.url.
For instance, with Maven in my case:
<pluginManagement>
</plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.6</version>
<!-- sonar.host.url not working with version 2.7 -->
</plugin>
</plugins>
</pluginManagement>
I use the full qualified goal in the CI server to run the sonar goals:
mvn org.codehaus.mojo:sonar-maven-plugin:2.6:sonar
Since we use the templates in TeamCity this is not so much of a disaster. Still we were a bit surprised by the event.
Both
mvn -Dsonar.host.url=http://localhost:9000 org.codehaus.mojo:sonar-maven-plugin:2.6:sonar
and
mvn -Dsonar.host.url=http://localhost:9000 org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar
worked for me :
Instead of reconfiguring all jobs I disabled sonar for all jobs until this gets fixed. I added
<sonar.skip>true</sonar.skip>
to the sonar profile in settings.xml.

How to add weblogic maven dependency?

When I add dependency I get following error :
[ERROR] Plugin com.oracle.weblogic:weblogic-maven-plugin:10.3.6 or one of its dependencies could not be resolved: Failure to find com.oracle.weblogic:weblogic-maven-plugin:jar:10.3.6 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
I think that you have to define an extra repository in your ~/.m2/settings.xml file, or add an extra proxy repository to your artifact repository (e.g. Nexus).
It seems that getting access to that repository is somewhat involved, so I'll just point you to what would seem to be the right documentation:
https://blogs.oracle.com/WebLogicServer/entry/weblogic_server_and_the_oracle
The error implies that the plugin was not available in the plugin repository.
Please modify your pom to include the plugin as:
<build>
<plugins>
<plugin>
<groupId>com.oracle.weblogic</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<version>10.3.4</version>
<configuration>
<adminurl>t3://localhost:7001</adminurl>
<user>weblogic</user>
<password>weblogic123</password>
<upload>true</upload>
<action>deploy</action>
<remote>false</remote>
<verbose>true</verbose>
<source>${project.build.directory}/${project.build.finalName}.${project.packaging}</source>
<name>${project.build.finalName}</name>
</configuration>
</plugin>
</plugins>
</build>
Please change adminurl, user, password accordingly.

Resources