use Maven to add info from MKS to Sonar - sonarqube

According to to the SCM Activity plugin info from the Sonar Webiste (http://docs.codehaus.org/display/SONAR/SCM+Activity+Plugin), a connection to MKS should be possible. On the Maven site, MKS provider code also exists.
However, when I run mvn sonar:sonar in my command line, I get the error:
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project example-it-jacoco-maven: Can not execute Sonar: Unsupported SCM: [svn:integrity]. Check compatibility at http://docs.codehaus.org/display/SONAR/SCM+Activity+Plugin. Please check the parameter "sonar.scm.url" or the section of Maven pom. -> [Help 1]
Do I need to somehow import the provider (coded into the pom.xml ?) or is there something wrong with my code in the pom:
scm:svn:integrity|myuser#mkssvr1:7001|#/SonarScm/TestCode
Anybody have an idea how to get this to work?
Cheers,
Kristian

I believe that correct URL will look like : scm:integrity|myuser#mkssvr1:7001|#/SonarScm/TestCode

Related

Could not find artifact org.apache.pulsar:pulsar-broker:pom:2.12.0-SNAPSHOT in apache.snapshots (https://repository.apache.org/snapshots)

While following the instructions to setup IntelliJ for pulsar development I got the below error
Could not find artifact org.apache.pulsar:pulsar-broker:pom:2.12.0-SNAPSHOT in apache.snapshots (https://repository.apache.org/snapshots)
Digging deeper into the snapshots, I don't see pulsar-broker at 2.12.0 either: https://repository.apache.org/content/groups/snapshots/org/apache/pulsar/pulsar-broker/
Is there some configuration step missing?
Attempted Fix [RESOLVED]
accepted answers steps and fix an issue with SDKMAN to have mvn call Java 17
I tried the command mvn -Pcore-modules,-main clean install -DskipTests -Dspotbugs.skip=true and got the new error below.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project buildtools: Compilation failure
[ERROR] /Users/brandon.hoffman/Projects/pulsar/buildtools/src/main/java/org/apache/pulsar/tests/RetryAnalyzer.java:[30,18] cannot access org.testng.ITestResult
[ERROR] bad class file: /Users/brandon.hoffman/.m2/repository/org/testng/testng/7.7.0/testng-7.7.0.jar(org/testng/ITestResult.class)
[ERROR] class file has wrong version 55.0, should be 52.0
[ERROR] Please remove or make sure it appears in the correct subdirectory of the classpath.
Running this on the command line will fix that problem:
mvn -Pcore-modules,-main clean install -DskipTests -Dspotbugs.skip=true
You must use Java 17 for compiling the master branch version of Pulsar (requirements).
It's possible that there has been some change in the maven build after the instructions were originally written.
It does not look like the project is currently using the repository.apache.org for nightly snapshots. You should ask your question on the dev#pulsar.apache.org mailing list.
Also we have not yet cut the 2.12 branch. The VOTE for the first release of 2.11.0 just passed the PMC.
(FYI I am an Apache Pulsar PMC Member)

I want to upload a JAR to a GitLab package registry

I have a prebuilt JAR file that I want to upload into a GitLab package registry so it can be using when a build is performed.
This is my first time playing with Maven and uploading so newbie alert here!
In my project in GitLab I do see that there is a section titled "package registry". I assume that I need to upload it there.
I found the following command which I thought might do the trick:
mvn deploy:deploy-file -DgroupId=com.acme.group -DartifactId=project-name \
-Dversion=1.2.3 -Dpackaging=jar -Dfile="test.jar" \
-Durl=https://gitlab-np-services.com/Ernie/ernie-sandbox-1/-/packages
-DrepositoryId=project-name
I have no idea what to put in for "DrepositoryId", "DartifactId". The other field I assumed in what i put.
How do I know what to put in those fields?
I run it and get the following :
Uploading to remote-repository: https://gitlab-np.services.com/Ernie/ernie-sandbox-1/-/packages/com/acme/group/project-name/1.2.3/project-name-1.2.3.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.793 s
[INFO] Finished at: 2021-06-01T15:51:09-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts: Could not transfer artifact com.acme.group:project-name:jar:1.2.3 from/to remote-repository (https://gitlab-np-services.com/Ernie/ernie-sandbox-1/-/packages): transfer failed for https://gitlab-np.services.com/Ernie/ernie-sandbox-1/-/packages/com/acme/group/project-name/1.2.3/project-name-1.2.3.jar, status: 422 Unprocessable Entity -> [Help 1]
[ERROR]
[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]
[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/MojoExecutionException
vanduyne-16mb:ernie-sandbox-1 vanduyer$ -DrepositoryId=project-name
bash: -DrepositoryId=project-name: command not found
Perhaps I need to allow permissions to upload to that location in GitLab - which I have no clue how to do.
Is that even where I should upload it to?
I have tried looking at the Maven sites and other sites for help on how to do this but I can not find something explaining this for a newbie.
Thanks for any help!
There are a few problems that I will list below.
First of all, you are missing a \ at the end of the third line. So, the -DrepositoryId=project-name parameter is not passing to the mvn deploy command.
Next, you need to decide which level do you want to deploy the artifact? You can read more about the levels on Gitlab's official documentation (GitLab endpoint for Maven packages). These addresses lead to /packages/maven, but you are missing the /maven token in the URL. (https://gitlab-np-services.com/Ernie/ernie-sandbox-1/-/packages)
You don't need to pass a repositoryId if you didn't configure any server inside your settings.xml file. If you configured it, then you can use the defined Id. So, Maven can use the configuration from the settings.xml file. You can read more about the repositoryId on Maven's official documentation: repositoryId
The groupId and artifactId parameters are the required parameters that define how you can import the artifact from the repository. I suggest you use the same groupId and the artifactId configured inside the pom.xml file of the artifact. If you deploy a package with groupId=com.group and artifactId=artifact-id then you can import the artifact to your project like this:
<dependencies>
<dependency>
<groupId>com.group</groupId>
<artifactId>artifact-id</artifactId>
<version>...</version>
</dependency>
...
</dependencies>
I suggest read more about deploying to Gitlab's Maven repository since you have to configure the authentication section as well: Maven packages in the Package Repository

Maven Release plugin error: Version was not mapped

I'm using maven release plugin and I'm getting the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) on project ****: Version for '****' was not mapped -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) on project ****: Version for '****' was not mapped
I run the job from Jenkins and source code is in perforce.
What am I missing?
Thanks.
You need to configure your project to use perforce as an SCM - use the maven-scm-plugin and add the dependency to the P4Maven plugin.
See the P4Maven manual.
See also this question.

Logging error when executing Maven SonarQube plugin

I've been facing an issue with Maven SonarQube plugin (v2.6) when Maven version is recent (strictly larger than 3.1).
Here is what I run:
mvn clean verify -Psonar
mvn org.codehaus.mojo:sonar-maven-plugin:2.6:sonar -Psonar
The first invocation makes sure sources are compiled and JaCoCo agent is prepared.
The interesting part comes, when the second command is run:
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project merlin-schema: Error setting Log implementation. Cause: java.lang.reflect.InvocationTargetException: org/slf4j/Marker -> [Help 1]
Any fix to be published?
Replacing default Maven logging implementation is currently not supported. Ticket created: http://jira.sonarsource.com/browse/MSONAR-122

First time SONAR setup with Maven, getting a error on RulePriority, analysis fails

I am trying to setup SONAR on a server. I have Maven 3.0.3 and using Sonar 3.1.1 with a Java project.
Part way through the mvn sonar:sonar, I am getting the following error:
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project XXXXXXX-common: Can not execute Sonar: No enum const class org.sonar.api.rules.RulePriority.3 -> [Help 1]
I have setup Sonar before and never saw this, it has always been unzip and go. But on this particular server I keep getting this error.
I tried creating a blank rule set, but the error still pops up.
Any thoughts?
I think you are facing the same problem described here
http://sonar.15.n6.nabble.com/Xpath-rules-gt-Failed-startup-of-context-td3183230.html
You might find it useful

Resources