I am getting below error while using the plugin (sonar-maven-plugin 3.7.0.1746):
ERROR:
Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project kcc-xbu-saprfc-services-sys-api: Unexpected internal error near index 1
I have added below in pom.xml file in respective sections:
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.7.0.1746</version>
</plugin>
<dependency>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.7.0.1746</version>
</dependency>
<repository>
<id>org.sonarsource.scanner.maven</id>
<name>sonar-maven-plugin</name>
<url>https://mvnrepository.com/artifact/org.sonarsource.scanner.maven/sonar-maven-plugin</url>
<layout>default</layout>
</repository>
<pluginRepository>
<id>org.sonarsource.scanner.maven</id>
<name>sonar-maven-plugin</name>
<layout>default</layout>
<url>https://mvnrepository.com/artifact/org.sonarsource.scanner.maven/sonar-maven-plugin</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
Versions currently being used:
SonarQube version: 7.9.1
MULE_EE with version 4.2.2
JDK: 1.8.0_251 (mixed mode)
Maven Version : 3.173.0
However maven is getting executed from "C:\Program Files\Maven\apache-maven-3.6.2\bin\mvn.cmd".
I am executing the build using azure pipeline.
Please let me know how to resolve this issue. Thank you.
If you are going to submit your code for SonarQube platform, normally the pom file doesn't need to have those dependencies, instead of it you can decouple that in changing the settings.xml of the maven (if you have a dedicated server, it should be inside .m2 folder for Windows).
Maven's settings.xml should have this profile:
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
<properties>
<sonar.login>*your-user-here*</sonar.login>
<sonar.password>*your-pwd-here*</sonar.password>
<sonar.host.url>*url-of-your-sonar-platform*</sonar.host.url>
</properties>
</activation>
<profile>
After that, you can setup you pipeline to run the following command for your project:
mvn sonar:sonar
Good luck!
Related
TLDR;
One depndency resolves and other does not. Can someone share how to debug it? or share some insight on what may be going on ?
Details:
I created a new maven project to create models and api in typescript from OpenApiV3.yaml file.
In my project's pom file I added a plugin.
<profile>
<id>typescript-angular</id>
<build>
<plugins>
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.25</version>
swagger-codegen-maven-plugin does not resolve. I get error in build that it could not be found.
<profiles>
<profile>
<id>typescript</id>
<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.1.0</version>
While openapi-generator-maven-plugin resolves. And does generate the objects.
org.openapitools openapi-generator-maven-plugin 5.1.0
io.swagger.codegen.v3 swagger-codegen-maven-plugin 3.0.25
We, in organization, do have a local nexus deployment but aparently this behavior is with same pluginRepositories in project's pom file. No change done to make it work for the other dependency.
<pluginRepositories>
<pluginRepository>
<id>maven-repository</id>
<name>Maven Repository</name>
<url>https://mvnrepository.com/artifact/</url>
</pluginRepository>
<pluginRepository>
<id>maven-central</id>
<name>Maven Central</name>
<url>https://repo1.maven.org/maven2/</url>
</pluginRepository>
</pluginRepositories>
Can someone share how to debug it? or share some insight on what may be going on ?
Is it possible to disable redeployment just from pom level via deployment plugin configuration?
Im trying to prevent redeployment of few artifacts in artifactory but dont want to set this globaly (i know it should be dole globaly, but im just a user of that artifactory and it is not up to me to decide).
Thats why i was wondering if it is posible to configure my artifacts poms to fail if deployment would in fact mean redeployment of non SNAPSHOT version.
Maven used: 3.6.1
There is no parameter for deploy:deploy to achieve this. There are two workarounds to prevent unintentional deploying at least:
1. deploy:deploy <skip>
<properties>
<skipDeploy>true</skipDeploy>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<skip>${skipDeploy}</skip>
</configuration>
</plugin>
</plugins>
</build>
Deploy with:
mvn deploy -DskipDeploy=false
2. Deploy to local TEMP by default, use profile to really deploy
<distributionManagement>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>local-dummy-repo</id>
<name>local dummy repository to prevent unintentional re-deploying</name>
<url>file://${env.TEMP}/maven-dummy-repo</url>
<layout>default</layout>
</repository>
</distributionManagement>
<profiles>
<profile>
<id>deploy</id>
<distributionManagement>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>repo</id>
<name>real repository</name>
<url>scheme://authority/path</url>
<layout>default</layout>
</repository>
</distributionManagement>
</profile>
</profiles>
Deploy with:
mvn deploy -Pdeploy
I need to build and release projects using Jenkins,
on a server with no access to maven central, and even, with no access to Nexus.
Given that I have access to maven-central on dev machines,
to fill the maven local_repository, I could do
mvn dependency:resolve-plugins dependency:go-offline
to then copy the local_repository on the linux server.
Then, to get ride of a Non-resolvable parent POM error,
as described here, I filled the specific profiles for both windows (dev) and linux (jenkins) with faked central profile to override the maven-central reference made by my parent pom:
<profiles>
<profile>
<id>windows</id>
<activation>
<os>
<family>Windows</family>
</os>
</activation>
<properties> <repository.base.url>file:///c:/maven_distribution_repo/</repository.base.url>
</properties>
</profile>
<profile>
<id>linux</id>
<activation>
<os>
<family>Linux</family>
</os>
</activation>
<properties>
<repository.base.url>file:///appli/Maven_3.1.1_build/maven_distribution_repo/</repository.base.url>
</properties>
<repositories>
<repository>
<id>central</id>
<name>Maven Plugin Repository</name>
<!--<url>http://repo1.maven.org/maven2</url>-->
<url>${repository.base.url}</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Plugin Repository</name>
<!--<url>http://repo1.maven.org/maven2</url>-->
<url>${repository.base.url}</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
That way, mvn -o compile still raise a Non-resolvable parent POM error !,
but using the --legacy-local-repository option suggested here ,
managed to fake the remote repository by using a local one,
and the Non-resolvable parent POM problem disappeared:
mvn --legacy-local-repository compile
Still, a strange error appeared (decribed here):
[ERROR] Failed to execute goal on project myProject: Could not resolve dependencies for project some.package:myProject:war:0.0.7-SNAPSHOT: Failed to collect dependencies at org.jxls:jxls-poi:jar:1.0.11 -> org.jxls:jxls:jar:[2.0.0,): org.jxls:jxls:jar:[2.0.0,) within specified range -> [Help 1]
But it was hiding an earlier warning:
[WARNING] Could not transfer metadata org.jxlsjxls/maven-metadata.xml from/to central (/path):/appli/Maven_3.1.1_build/maven_distribution_repo/org/jxls/jxls/maven-metadata-central.xml (access forbidden)
Using --legacy-local-repository, maven seems to use the distribution repository path as the local libs repository !
I swapped them in the pom:
<profile>
<id>linux</id>
<activation>
<os>
<family>Linux</family>
</os>
</activation>
<properties>
<!--<repository.base.url>file:///appli/Maven_3.1.1_build/maven_distribution_repo/</repository.base.url>-->
<repository.base.url>file:///appli/Maven-3.1.1_build/maven_local_repo/</repository.base.url>
</properties>
...
and had also to copy into the local repository:
all maven-metadata-maven2_central.xml into maven-metadata.xml
using the following bash command:
for file in $(find /appli/Maven-3.1.1_build/maven_local_repo -type f -name 'maven-metadata-maven2_central.xml'); do cp $file $(echo ${file%/*}/maven-metadata.xml); done
And ... BINGO !
BUILD SUCCESSFULL
Seems weird, at later stage, to release:perform into the local lib repository.
Would you have any better and not that painful solution ?
Maven deploy plugin would solve this problem.
mvn deploy -DaltDeploymentRepository=local-temp::default::file://directory/
More Exhaustive example:
# 1. Create temporary folder
tmp_repo=$(mktemp -d systemds-repo-tmp-XXXXX)
# 2. Create a simple settings.xml
cat <<EOF >../tmp-settings-nexus.xml
<settings>
<activeProfiles>
<activeProfile>local-temp</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>local-temp</id>
<repositories>
<repository>
<id>local-temp</id>
<url>${tmp_repo}</url>
</repository>
</repositories>
</profile>
</profiles>
</settings>
EOF
# 3. deploy to local
mvn --settings ../tmp-settings-nexus.xml -Pdistribution deploy \
-DaltDeploymentRepository=local-temp::default::file://${tmp_repo} \
-Daether.checksums.algorithms='SHA-512,SHA-1,MD5'
You should consider setting up a local repository (for example, Nexus) that will be accessible to your build machine.
This is a very common setup.
It enables you to build without internet connection to the build machine.
I've been using release version of this github IoT java client: https://github.com/ibm-messaging/iot-java
I'd like to build the source but when I import it into my Eclipse I get a missing dependency error for:
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.0.3-SNAPSHOT</version>
</dependency>
I have tried the snapshot modification in settings.xml:
<profiles>
<profile>
<id>allow-snapshots</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
But that won't solve the problem. Also, using this settings using Eclipse Maven settings.xml editor as linked from the dependency error message won't make the dependency be found. (BTW, I can't use Paho 1.0.2)
Also, I have seen that in bottom of pom.xml of the project it references RELEASE, not SNAPSHOT, and tried also changing it.
May this is because you are using
https://repo.eclipse.org/content/repositories/paho-releases/
not
https://repo.eclipse.org/content/repositories/paho-snapshots
so Please use this repository instead of yours
<repositories>
<!-- Dependency of the Paho mqqt snapshot is here -->
<repository>
<id>Eclipse Paho Snapshots Repo</id>
<url>https://repo.eclipse.org/content/repositories/paho-snapshots/</url>
</repository>
</repositories>
I want to deploy artifacts to Nexus from Jenkins to different repositories (like builds-all, builds-verified, releases). The thing is that I want to keep minimal configuration in the project POM file. My settings file now looks like:
<servers>
<server>
<id>orion-nexus</id>
<username>admin</username>
<password>password</password>
</server>
</servers>
<localRepository>~/.m2/repository</localRepository>
<profiles>
<!-- Deployment configuration for CI builds for mainline -->
<profile>
<id>build</id>
<repositories>
<repository>
<id>builds-all</id>
<url>http://orion-nexus:8081/</url>
<snapshots>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
Project POM:
<distributionManagement>
<repository>
<id>orion-nexus</id>
<layout>default</layout>
<url><!-- how to avoid explicit URL? --></url>
</repository>
</distributionManagement>
I wan to run deploy like mvn -B -P build clean install deploy. However, I don't understand how to avoid setting explicit URL in distribution management section. Can I set a variable in settings file and propagate it to my POM?
Is there any step-by-step guide for such workflow?
You can declare a property inside a profile on your settings.xml and use its name within <distributionManagement/> configuration.
settings.xml
<profiles>
<profile>
<id>distmgt</id>
<properties>
<distUrl>scp://...</distUrl>
<properties/>
</profile>
</profiles>
pom.xml
<distributionManagement>
<repository>
<id>orion-nexus</id>
<layout>default</layout>
<url>${distUrl}</url>
</repository>
</distributionManagement>
And finally
mvn -P distmgt clean deploy
You can avoid the -P build params using activation.