How to consume Maven Components from Private Gitlab Repositories? - java

Problem
We are trying to consume a Maven components in a private Maven repository... The dependency right now is not being pulled for some reason... I have declared the dependency in gradle as follows:
dependencies {
implementation group: 'super_.platform.client', name: 'client-feign', version: '1.0.0-SNAPSHOT'
}
repositories {
maven {
url "https://gitlab.com/api/v4/projects/22268428/packages/maven"
}
}
When running gradle eclipse to pull the dependency, the command fails with the following:
[INFO] Resolving super_.platform.client:client-feign:jar:1.0.0-SNAPSHOT with transitive dependencies
[WARNING] Missing POM for super_.platform.client:client-feign:jar:1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:07 min
[INFO] Finished at: 2020-11-06T19:49:27Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:get (default-cli) on project standalone-pom: Couldn't download artifact: Missing:
[ERROR] ----------
[ERROR] 1) super_.platform.client:client-feign:jar:1.0.0-SNAPSHOT
[ERROR]
[ERROR] Try downloading the file manually from the project website.
[ERROR]
[ERROR] Alternatively, if you host your own repository you can deploy the file there:
[ERROR] mvn deploy:deploy-file -DgroupId=super_.platform.client -DartifactId=client-feign -Dversion=1.0.0-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
[ERROR]
[ERROR] Path to dependency:
[ERROR] 1) org.apache.maven.plugins:maven-downloader-plugin:jar:1.0
[ERROR] 2) super_.platform.client:client-feign:jar:1.0.0-SNAPSHOT
[ERROR]
[ERROR] ----------
[ERROR] 1 required artifact is missing.
[ERROR]
[ERROR] for artifact:
[ERROR] org.apache.maven.plugins:maven-downloader-plugin:jar:1.0
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR] central (https://repo.maven.apache.org/maven2, releases=true, snapshots=false)
[ERROR]
[ERROR] -> [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
Question
Since the Git repo at Gitlab is private, I would imagine the Maven repository is also private. How to download that in Gradle?

Solution
Add the token information in the Maven repo passing the value through Environment Variable: GITLAB_TOKEN. You need to use the credentials section with an HTTP Header object.
maven {
url "https://gitlab.com/api/v4/projects/22268428/packages/maven"
credentials(HttpHeaderCredentials) {
name "Private-Token"
value System.env.GITLAB_TOKEN
}
authentication {
header(HttpHeaderAuthentication)
}
}
After that, I was able to pull the library from the private Maven repository within the Gitlab repo.
GITLAB_TOKEN=1234556 gradle eclipse

Related

An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar

I have encountered problems while trying to run sonarqube on my application. When I execute the command it throws me an error which doesn't say much to me. Does anyone know where is the problem here?
The Error looks like this:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.257 s
[INFO] Finished at: 2022-12-07T15:10:39+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project TeamTracker: Execution default-cli of goal org.sonarsource.sca
nner.maven:sonar-maven-plugin:3.9.1.2184:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar: java.la
ng.ExceptionInInitializerError: null
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.codehaus.mojo:sonar-maven-plugin:3.9.1.2184
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/A113408609/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/3.9.1.2184/sonar-maven-plugin-3.9.1.2184.jar
[ERROR] urls[1] = file:/C:/Users/A113408609/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-sec-dispatcher-1.4.jar
[ERROR] urls[2] = file:/C:/Users/A113408609/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[3] = file:/C:/Users/A113408609/.m2/repository/org/codehaus/plexus/plexus-utils/3.2.1/plexus-utils-3.2.1.jar
[ERROR] urls[4] = file:/C:/Users/A113408609/.m2/repository/org/sonarsource/scanner/api/sonar-scanner-api/2.16.2.588/sonar-scanner-api-2.16.2.588.jar
[ERROR] urls[5] = file:/C:/Users/A113408609/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] : java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security
.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module #26f204a4
[ERROR] -> [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/PluginContainerException
'cmd' is not recognized as an internal or external command,
operable program or batch file.
This is a command I execute:
mvn sonar:sonar -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_AUTH_TOKEN -Dsonar.projectKey=$SONAR_PROJECT_KEY -Dsonar.projectName=$CI_PROJECT_PATH_SLUG
I have gone through documentations but I still really can't see what is the problem here :/
When I try to run mvn clean install the build is succesfull.
I am using Java 11, Maven 3.6.3 and Sonar Community Edition Version 8.9.10

maven install not work in eclipse and trying other plans

Error logs:
[INFO]
[INFO] BUILD FAILURE
[INFO]
[INFO]
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-
plugin:2.12.4:test (default-test) on project sample: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: Plugin org.apache.maven.plugins:maven-surefire-plugin:2.12.4 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-surefire-plugin:jar:2.12.4 -> org.apache.maven.surefire:surefire-booter:jar:2.12.4: Failed to read artifact descriptor for org.apache.maven.surefire:surefire-booter:jar:2.12.4: Could not transfer artifact org.apache.maven.surefire:surefire-booter:pom:2.12.4 from/to central (https://repo.maven.apache.org/maven2): Received fatal alert: protocol_version -> [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/PluginResolutionException
================================================================
I try plans.
preferences > maven > user settings reset
project clean > maven update > maven clean > maven install
C:\Users\docan.m2\repository folder delete and try step2

Maven release:prepare cannot commit parent module

I want to make a release with the maven release plugin in two steps:
1. mvn clean release:prepare
2. mvn release:perform
It worked fine the last two releases, but after changing my IDE from intellij to eclipse I am not able to perform a release this way with apache-maven 3.5.3 and eGit 4.9.2.
The general structure of my project is:
parent-dir
-> pom.xml
-> child1-dir
-> pom.xml
-> child2-dir
-> pom.xml
child1 and child2 contain code and packaging to jar, the parent has packaging goal pom.
Configuration of maven-release-plugin in parent pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-invoker</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</plugin>
The plugin updates all poms with correct version #, committs changes and pushes to the remote repository for both child modules. But for the parent module I get the following error at the end of the log:
[INFO] Reactor Summary:
[INFO]
[INFO] test Parent 0.12-SNAPSHOT ........................ FAILURE [02:46 min]
[INFO] test Child1 ...................................... SUCCESS [ 0.011 s]
[INFO] test Child2 0.12-SNAPSHOT ........................ SUCCESS [ 0.205 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:48 min
[INFO] Finished at: 2018-09-08T12:56:06+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.1:prepare (default-cli) on project test-parent: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] git#github.com: Permission denied (publickey).
[ERROR] fatal: Could not read from remote repository.
[ERROR]
[ERROR] Please make sure you have the correct access rights
[ERROR] and the repository exists.
[ERROR] -> [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/MojoFailureException
I do not understand why I get this error message after succesfull commiting and pushing the children modules?
You need to add your public key in Github.
For help please refer https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/

Cannot install Hadoop: InvalidAlgorithmParameter exception

I downloaded the latest version of apache hadoop from the github repo and followed the steps here:
http://cleverowl.uk/2015/06/30/compiling-2-7-0-on-64-bit-linux/
I didn't install protobuf and java because I already have them installed on my machine.
When installing with the command:
mvn package -Pdist,native -DskipTests -Dtar
The following error appears:
[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/apache/felix/maven-bundle-plugin/2.5.0/maven-bundle-plugin-2.5.0.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unresolveable build extension: Plugin org.apache.felix:maven-bundle-plugin:2.5.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.felix:maven-bundle-plugin:jar:2.5.0 #
#
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project org.apache.hadoop:hadoop-main:3.0.2 (/home/andrew/hadoop-rel-release-3.0.2/pom.xml) has 1 error
[ERROR] Unresolveable build extension: Plugin org.apache.felix:maven-bundle-plugin:2.5.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.felix:maven-bundle-plugin:jar:2.5.0: Could not transfer artifact org.apache.felix:maven-bundle-plugin:pom:2.5.0 from/to central (https://repo.maven.apache.org/maven2): java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty -> [Help 2]
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginManagerException
Any help?

Eclipse Java project build errors with Maven

I'm trying to setup a project from a svn repo on my eclipse IDE. When ever I try to build the project I'm thrown with the following error.
Errors occurred during the build. Errors running builder 'Maven
Project Builder' on project 'ats'. 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
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
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 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
In order to setup Maven for this project, I've ran the following command on cmd
mvn eclipse:eclipse
Upon running the following, Maven throws a build error with the following info.
[INFO] BUILD FAILURE [INFO]
------------------------------------------------------------------------ [INFO] Total time: 03:10 min [INFO] Finished at:
2015-07-30T09:51:07-04:00 [INFO] Final Memory: 7M/122M [INFO]
------------------------------------------------------------------------ [ERROR] No plugin found for prefix 'eclipse' in the current project
and in the p lugin groups [org.apache.maven.plugins,
org.codehaus.mojo] available from the re positories [local
(C:\Users\user.m2\repository), central (https://repo.mave
n.apache.org/maven2)] -> [Help 1] [ERROR] [ERROR] To see the full
stack trace of the errors, re-run Maven with the -e swit ch. [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 rea d the following articles: [ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundF
orPrefixException
Has anyone ran in to this issue in the past that they can help me out with? I'm on Windows 7 64bit.
Thank you for reading.

Categories