Groovy grape not resolving artifacts in Maven central - maven

Fresh install of Groovy and for some reason it isn't pulling artifacts from Maven central:
$ grape resolve org.apache.httpcomponents httpclient 4.2.1
Error in resolve:
Error grabbing Grapes -- [download failed: org.apache.httpcomponents#httpclient;4.2.1!httpclient.jar, download failed: org.apache.httpcomponents#httpcore;4.2.1!httpcore.jar, download failed: commons-logging#commons-logging;1.1.1!commons-logging.jar]
Complete -d debug log:
https://gist.github.com/mrobinet/a86073e35771cab55665
Environment:
$ groovy --version
Groovy Version: 2.4.4 JVM: 1.7.0_79 Vendor: Oracle Corporation OS: Mac OS X
The artifacts clearly exist:
https://repo1.maven.org/maven2/org/apache/httpcomponents/httpclient/4.1.2/
Things I've tried:
Adding Maven Central to ~/.groovy/grapeConfig.xml
grape -r https://repo1.maven.org/maven2 resolve org.apache.httpcomponents httpclient 4.2.1
Viewing the debug output, it doesn't even appear to be requesting it from central.

I recently ran into this again and was able to figure out the issue. I ended up filing a bug with Groovy: https://issues.apache.org/jira/browse/GROOVY-8655
The problem occurs when you have only a POM file for the artifact in your Maven local repository (no jar file).

Related

Error when creating Maven project from archetype: 501 HTTPS Required

I run mvn archetype:generate and get this error:
Error reading archetype catalog http://repo.maven.apache.org/maven2
org.apache.maven.wagon.TransferFailedException: Transfer failed for http://repo.maven.apache.org/maven2 501 HTTPS Required
I'm using Maven 3.6.3.
I cannot put a different repository URL into the POM file, because when I'm creating a project from an archetype, no POM file exists yet.
I have no settings.xml file in ~/.m2.
Is there something wrong with my Maven installation?
The output of mvn --version is:
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
Java version: 11.0.2, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"
/usr/local/Cellar/maven/3.6.3_1/libexec/conf/settings.xml does not contain the URL that the error message is complaining about.
Short answer: override the default http catalog url with an https one, by appending:
-DarchetypeCatalog=https://repo.maven.apache.org/maven2/archetype-catalog.xml
to the mvn archetype:generate command
Background:
When using the mvn -X -e archetype:generate command, Maven 3.6.3 seems to use version 2.4 of the maven-archetype-plugin:
[DEBUG] Resolved plugin version for org.apache.maven.plugins:maven-archetype-plugin to 2.4 from repository central (https://repo.maven.apache.org/maven2, default, releases)
The plugin uses the remote catalog: http://repo.maven.apache.org/maven2/archetype-catalog.xml:
[DEBUG] Searching for remote catalog: http://repo.maven.apache.org/maven2/archetype-catalog.xml
[DEBUG] Searching for remote catalog: http://repo.maven.apache.org/maven2
[WARNING] Error reading archetype catalog http://repo.maven.apache.org/maven2
org.apache.maven.wagon.TransferFailedException: Transfer failed for http://repo.maven.apache.org/maven2 501 HTTPS Required
As of 15/1/2020, maven central requires an HTTPS url: Central 501 HTTPS Required
According to this JIRA, the issue should be fixed in version 3.0.0 of the plugin.

Gradle compileGroovy java.lang.ExceptionInInitializerError

Here is the github repo: https://github.com/entrpn/gradle_plugin. You will need to manually create a folder "repo" at the root of the project since git doesn't add empty directories. That is where the generated files are supposed to go when running:
./gradlew uploadArchives
I am trying to write a simple gradle plugin following this tutorial https://afterecho.uk/blog/create-a-standalone-gradle-plugin-for-android-a-step-by-step-guide.html and when I get to the part where I am trying to create the local maven repo, I am not able to.
Problem: I am using the gradle wrapper command line:
./gradlew uploadArchives
and I receive the above error. Anyone know what I am doing wrong. Here is the log output:
Executing org.gradle.api.internal.tasks.compile.ApiGroovyCompiler in worker daemon.
16:20:23.624 [INFO] [org.gradle.workers.internal.WorkerDaemonServer] Exception executing org.gradle.api.internal.tasks.compile.ApiGroovyCompiler in worker daemon: java.lang.ExceptionInInitializerError.
16:20:23.636 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationWorkerRegistry] Worker root.2.3 completed (1 in use)
16:20:23.636 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Removed task artifact state for {} from context.
16:20:23.636 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':compileGroovy'
Thank you.
Ok I figured it out. Jason's answer gave me a clue. I opened terminal and ran ./gradlew --version and got this output:
Gradle 3.5-rc-2
Build time: 2017-03-27 15:56:23 UTC
Revision: ec63970cd167993d3dcda346a1d00a286a23b1c9
Groovy: 2.4.10
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_131 (Oracle Corporation 25.131-b11)
OS: Mac OS X 10.12.6 x86_64
So I noticed the Groovy version is 2.4.10 so I changed the gradle file to use this version, recompiled and the files were generated.
When I tried to run it I received the following error in addition to yours,
When I tried to run it I received the following error, "Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.4.7 and you are trying to load version 2.3.11"
I modified build.gradle and changed line 14 from
compile 'org.codehaus.groovy:groovy-all:2.3.11'
to
compile 'org.codehaus.groovy:groovy-all:2.4.7'

SonarQube Jenkins Plugin won't authenticate to Artifactory

SonarQube 5.1 running on Ubuntu 12.04.4 LTS
Jenkins ver. 1.616 running on Ubuntu 12.04.4 LTS
SonarQube Plugin 2.2.1
Artifactory Pro Power Pack 3.8.0 (rev. 30190) running on Ubuntu 12.04.5 LTS
sbt 0.13.8
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.8.0_45, vendor: Oracle Corporation
Java home: /usr/lib/jvm/jdk1.8.0_45/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.5.0-23-generic", arch: "amd64", family: "unix"
Attempting to use the SonarQube Jenkins Plugin in a Jenkins Build, the plugin seems to try to rebuild the entire build and re-resolve all the dependencies out of Artifactory. Problem is, unlike the rest of the build, when the SonarQube plugin requests artifacts from Artifactory, it does so as a non-authenticated-user, and Artifactory refuses the request.
I've tried everything from copying the <servers/>, <profiles/>, and <activeProfiles/> from the jenkins user's settings.xml file into /etc/maven.settings.xml and explicitly telling the plugin to use the former as user settings and the latter as system settings - in short, anything and everything I could find documented to medieval brute force the plugin to use the jenkins user's credentials , but still it just keeps connecting as a non-authenticated user and having its requests refused.
Example from Jenkins Log (sensitive information obfuscated):
INFO: No credentials available for BASIC 'Artifactory Realm'#libs.<organization>;:443
[WARNING] Could not transfer metadata <GAV>/maven-metadata.xml from/to ArtifactorySnapshotsRepo (<Artifactory URL>/artifactory/libs-snapshot/): Not authorized.
[WARNING] The POM for org.codehaus.jackson:jackson-core-asl:jar:1.8 is missing, no dependency information available
[WARNING] The POM for org.codehaus.jackson:jackson-mapper-asl:jar:1.8 is missing, no dependency information available
[WARNING] Failure to transfer <GAV>/maven-metadata.xml from <Artifactory URL>/artifactory/libs-snapshot/ was cached in the local repository, resolution will not be reattempted until the update interval of ArtifactorySnapshotsRepo has elapsed or updates are forced. Original error: Could not transfer metadata <GAV>/maven-metadata.xml from/to ArtifactorySnapshotsRepo (<Artifactory URL>/artifactory/libs-snapshot/): Not authorized.
And in Artifactory's request.log we get (again with sensitive information obfuscated):
20150916190344|5181|REQUEST|<Jenkins IP>;|non_authenticated_user|GET|/libs-snapshot//<GAV>/maven-metadata.xml|HTTP/1.0|401|0
The maven command launched by the SonarQube Plugin was as follows (lines broken for clarity, sensitive information obfuscated):
mvn
-f /var/lib/jenkins/workspace/NE-BUILD-1/pom.xml
-s /var/lib/jenkins/.m2/settings.xml
-gs /etc/maven/settings.xml
-e
-B org.codehaus.mojo:sonar-maven-plugin:2.6:sonar
-Dsonar.jdbc.url=jdbc:postgresql://<server>:<port>/sonar
******** ********
-Dsonar.host.url=http://<server>:<port>/
-Dsonar.branch=sbt-publish-deb ******** ********
How can I make this process authenticate to Artifactory properly?

sonar-maven-plugin 5.1.1 not found

I've just installed the latest version of SonarQube (5.1.1) and when I try to run the sonar:sonar target, I get an error:
Embedded error: Unable to build project for plugin 'org.codehaus.sonar:sonar-maven-plugin': POM 'org.codehaus.sonar:sonar-maven-plugin' not found in repository: Unable to download the artifact from any repository
org.codehaus.sonar:sonar-maven-plugin:pom:5.1.1
I've checked here:
http://mvnrepository.com/artifact/org.codehaus.sonar/sonar-maven-plugin
And it seems that version 5.1.1 of the sonar-maven-plugin has not been pushed to the public repo(s).
Is that so or am I looking in the wrong location?
The sonar-maven-plugin is an independent project that does not follow SonarQube versioning.
Correct command-line is mvn org.codehaus.mojo:sonar-maven-plugin:2.6:sonar
The groupId mvn.codehaus.sonar is for internal use.

maven generating pom file

I use maven 3.0.3 and have tried to generate pom for third-party jar like this:
mvn install:install-file -Dfile=cobra.jar -DgroupId=com.cobra
-DartifactId=cobra -Dversion=0.98.4 -Dpackaging=jar -DgeneratePom=true
According to link below it should generate proper pom.xml and install artifact in the repo.
http://maven.apache.org/plugins/maven-install-plugin/examples/generic-pom-generation.html
Meanwhile, it returns such a error:
[ERROR] The goal you specified requires a project to execute but there
is no POM in this directory (D:\cobra-0.98.4\lib). Please verify you
invoked Maven from the correct directory. -> [Help 1]
Why is it asking for pom.xml while it should generate pom.xml?
This is an old question, but was a serious PITA for me for a few minutes, so I thought I'd share:
I just ran into this problem, and I believe that the issue is probably platform-dependent. The real tip-off was that the solution from Cyril's answer wasn't working as expected: despite my specification of -DgroupId=com.xyz and -DartifactId=whatever on the command-line and the corresponding entry in the POM file, the jar was installed in the local repo under com/whatever.
This led me to experiment with quoting command-line arguments, and the eventual correct result from formatting the command-line like this (after deleting the POM file):
mvn install:install-file "-Dfile=cobra.jar" "-DgroupId=com.cobra" "-DartifactId=cobra" "-Dversion=0.98.4" "-Dpackaging=jar" "-DgeneratePom=true"
Some of the quoting is doubtless redundant, but better safe than sorry, right? I happen to be running Vista on this computer, and would not be surprised if this problem were specific to this OS version...by the way, this was with Maven v3.0.4.
Are you sure that you are executing the install-file goal? I checked your command and it works for me, but when I place a blank install :install-file (maybe you have this typo) the install goal would be used which needs a pom.xml.
Try to use the -X parameter to get more debug information:
-X,--debug Produce execution debug output
My system
Maven
c:\>mvn -version
Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
Maven home: C:\progs\apache-maven-3.0.3
Java version: 1.6.0_21, vendor: Sun Microsystems Inc.
Java home: c:\Program Files (x86)\Java\jdk1.6.0_21\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
Install Plugin
c:\>mvn -Dplugin=install help:describe
Name: Maven Install Plugin
Description: Copies the project artifacts to the user's local repository.
Group Id: org.apache.maven.plugins
Artifact Id: maven-install-plugin
Version: 2.3.1
Goal Prefix: install
This plugin has 3 goals:
install:help
Description: Display help information on maven-install-plugin.
Call
mvn install:help -Ddetail=true -Dgoal=<goal-name>
to display parameter details.
install:install
Description: Installs the project's main artifact in the local repository.
install:install-file
Description: Installs a file in the local repository.
For more information, run 'mvn help:describe [...] -Ddetail'
I found a bypass. You need to create a simple pom.xml like this :
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cobra</groupId>
<artifactId>cobra</artifactId>
<version>0.98.4</version>
</project>
It's not perfect but it's worked for me. If you find a better way to do that, I'm interested.
My config :
$mvn -version
Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100)
Maven home: /usr/local/maven
Java version: 1.6.0_20, vendor: Sun Microsystems Inc.
Java home: /usr/local/jdk1.6.0_20/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-25-generic-pae", arch: "i386", family: "unix"
$mvn -Dplugin=install help:describe
...
Name: Maven Install Plugin
Description: Copies the project artifacts to the user's local repository.
Group Id: org.apache.maven.plugins
Artifact Id: maven-install-plugin
Version: 2.3.1
Goal Prefix: install
...
Try to run it on cmd.exe or execute cmd command before the mvn command.
Using maven version 3.6.3, this worked for me to generate pom file in my chosen directory:
C:<MyChosenDir> mvn archetype:generate "-DgroupId=com.mycompany.app" "-DartifactId=my-app" "-DarchetypeArtifactId=maven-archetype-quickstart" "-DarchetypeVersion=1.4" "-DinteractiveMode=false"
just go under your project directory where you can find your pom.xml file then execute the same command ! it works for me ;)
If you are having trouble with the command line version of Maven, you might want to try the M2E plugin for eclipse. It is far more user friendly for people without very much experience with Maven.
It worked for me when I changed Powershell to Cygwin. Powershell is somehow parsing the command line argument incorrectly.
I had that error when I was using maven in Windows, what worked for me was opening the cmd and not the PowerShell.
Apparently certain errors appear when you don't do it with the cmd.
I hope it works.
If you are getting this error during jenkins pipeline setup , Then the error is we are placing git repository without .git in jenkins git url blank .Generally we put website url of git repo but we need to place clone url of git repo.Insert .git (cloned url) to website url , Simply insert git clone url.

Resources