Does this Maven plugin really have an invalid descriptor? - java

COMMAND:
mvn org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-4:generate -DarchetypeGroupId=org.beardedgeeks -DarchetypeArtifactId
=gae-eclipse-maven-archetype -DarchetypeVersion=1.1.2 -DarchetypeRepository=http://beardedgeeks.googlecode.com/svn/repository/release
s
OUTPUT:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Internal error in the plugin manager getting plugin 'org.apache.maven.plugins:maven-archetype-plugin': Plugin 'org.apache.maven
.plugins:maven-archetype-plugin:2.0-alpha-4' has an invalid descriptor:
1) Plugin's descriptor contains the wrong group ID: net.kindleit
2) Plugin's descriptor contains the wrong artifact ID: maven-gae-plugin
3) Plugin's descriptor contains the wrong version: 0.5.9
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed Jun 09 20:48:35 CEST 2010
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------
I have a hard time believing this Maven plugin has an invalid descriptor since other people seem to be using it with no problem. Am I doing something wrong?

Can't reproduce your problem, the following command works fine for me (copied & pasted from GAE + Eclipse + Maven Archetype):
mvn org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-4:generate \
-DarchetypeGroupId=org.beardedgeeks \
-DarchetypeArtifactId=gae-eclipse-maven-archetype \
-DarchetypeVersion=1.1.2 \
-DarchetypeRepository=http://beardedgeeks.googlecode.com/svn/repository/releases
Tested with Maven 2.2.1:
$ mvn -version
Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
Java version: 1.6.0_20
Java home: /usr/lib/jvm/java-6-sun-1.6.0.20/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.32-22-generic" arch: "i386" Family: "unix"

I often experience problems with crappy metadata in my local repository. This kind of error usually vanishes after I do
rm -Rf my/home/dir/.m2/repository/net/kendleit/maven-gae-plugin
but actually the reason why it works with Pascal is that Pascal uses this url http://beardedgeeks.googlecode.com/svn/repository/releases whereas you use this url http://beardedgeeks.googlecode.com/svn/repository/release (an s is missing, hence there's a 404)
do the rm as mentioned above and then run again with the correct url
EDIT: sorry there is actually a trailing s I didn't see. I take everything back, but still: try to delete the metadata in your local repo

Reason:
the GAV (groupid, artifactid, version) in Nexus (consequently in local repository and in the pom.xml) is not the same as the one in the jar file in \META-INF\maven\plugin.xml
This usually happens when you upload manually the plugin artifact in your own Nexus (or any other maven enterprise repository)
Solution:
download the jar, see what are the GAV values in plugin.xml
upload the jar on Nexus, passing as GAV the information from the plugin.xml
Update the pom.xml accordingly
Make sure to remove from Nexus the old inconsistent artifact.

Related

Maven Sonarqube plugin: Unable to execute SonarQube: Fail to get bootstrap index from server

I'm having an headache setting up the sonarqube maven plugin for a project.
So I have a sonarqube instance let's say on https://sonarqube.mycompany.software. I test many projects on this instance, it's working well since months.
I also have other projects that use the maven plugin (but use another docker image to run)
I start a new project, and of course I want to add to my automatic pipeline that checks the code with sonarqube.
Everything runs perfectly when I execute the maven plugin on my machine, with the OpenJdk-8:
$ mvn org.jacoco:jacoco-maven-plugin:0.8.5:prepare-agent clean test package
$ mvn sonar:sonar -Dsonar.projectKey=projectname -Dsonar.host.url=https://sonarqube.mycompany.software -Dsonar.login=youwishyouknew
[... Lots of output ...]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.891 s
[INFO] Finished at: 2020-05-07T18:03:00+02:00
[INFO] ------------------------------------------------------------------------
Then I try to execute the exact same command with docker on the server (where the pipeline will run), using the maven:3.6.3-jdk-8 image, I get this error:
$ docker run -v `pwd`/m2cache:/root/.m2 -v `pwd`/sonarcache:/root/.sonar/cache -v`pwd`:`pwd` -w`pwd` maven:3.6.3-jdk-8 mvn sonar:sonar -Dsonar.projectKey=projectname -Dsonar.host.url=https://sonarqube.mycompany.software -Dsonar.login=youwishyouknew
[INFO]
[INFO] ---------------------------< software.mycompany:projectname >----------------------------
[INFO] Building projectname 2.3.0
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.7.0.1746:sonar (default-cli) # projectname ---
[INFO] User cache: /root/.sonar/cache
[ERROR] SonarQube server [https://sonarqube.mycompany.software] can not be reached
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.286 s
[INFO] Finished at: 2020-05-07T16:06:22Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project projectname: Unable to execute SonarQube: Fail to get bootstrap index from server: Broken pipe (Write failed) -> [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
When I Execute this, absolutely nothing is happening in the Sonarqube logs (nothing moves at all in any log, while when I run it on my machine I find everything I expect to find.)
Furthermore, if I try to curl the sonarqube server from the docker image, it works! Tried with ping too.
$ docker run -v `pwd`/m2cache:/root/.m2 -v `pwd`/sonarcache:/root/.sonar/cache -v`pwd`:`pwd` -w`pwd` maven:3.6.3-jdk-8 curl https://sonarqube.mycompany.software
<!doctype html><html lang="en"><head><meta http-equiv="content-type" content="text/html; charset=UTF-8" charset="UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"><link rel="apple-touch-icon" href="/apple-touch-icon.png"><link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png"><link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png">
[... And a lot more output ... ]
It responds with the sonarqube index page as I expect.
As far as I can see, there is no proxy setting in the docker maven image.
This is quite frustrating.
Has anybody any clue on what is going on here and how to fix this?
[EDIT] So I've tried many things, and one worked: using another docker image. In particular, I've tried all the available maven jdk-8 images available here: https://hub.docker.com/_/maven, and one actually worked, while all other failed: maven:3.6.3-ibmjava-8.
It looks like a java-8 related problem, since all JDK 11 images instead do work as expected. Unfortunately the project is in Java 8 and everything breaks when upgrading the JVM :-)
I leave this here as a work-around, but still, I would like to know why it fails with other docker images and how to fix this in the future.
I had this issue too with maven and gradle sonarqube analysis, i have only this issue with jdk8-u252+.
Maven 3.6.3 official image have jdk8-u262.
For me, with maven 3.5.2 it's ok (jdk-u232).
For the root cause, it could be the javax.net.ssl new features shipped in u252 : https://www.oracle.com/java/technologies/javase/8u251-relnotes.html

Java+Maven builds on Jenkins but not on local machine

I have a strange problem. My build is working on Jenkins but not locally. It used to work locally but stopped for some reason.
I have no uncommitted changes. The code on Jenkins is in sync with my master branch(using Git).
I have deleted all uncommitted files from my local machines project.
Mvn -version on local machine:
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T09:58:13+02:00)
Maven home: /Users/andersvincentlund/Downloads/apache-maven-3.5.2
Java version: 9.0.4, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home
Default locale: en_SE, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.6", arch: "x86_64", family: "mac"
Tool configuration on Jenkins machine:
jdk-9.0.1
apache-maven-3.5.2
Compiler plugin in Maven in the code:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Build result on Jenkins:
[INFO] Reactor Summary:
[INFO]
[INFO] RootProject ..................................... SUCCESS [ 1.781 s]
[INFO] ProjectA ........................................ SUCCESS [ 15.344 s]
[INFO] ProjectB ............................................ SUCCESS [ 35.063 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
Build result from local machine:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] RootProject ..................................... SUCCESS [ 0.350 s]
[INFO] ProjectA ........................................ SUCCESS [ 1.285 s]
[INFO] ProjectB ............................................ FAILURE [ 1.402 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
Failures in ProjectB are referencing packages in Project A. All look like this:
[ERROR] /somePath1/src/main/java/somePath2/SomeFile.java:[10,38] error: package some.package.in.projectA does not exist
I know my Maven and Java aren't exactly the same version on the different machines. The local one is a Mac running Sierra. The remote one is Windows Server 2012 R2. Since I am using the maven compile plugin to set the version to Java 7 it shouldn't be a problem right? I don't get this. Normally the issue is that it is working locally but not on Jenkins. This is the other way around. Help would be greatly appreciated. Starting to feel really stupid over here.
EDIT:
Tried on another Mac. Same result as with my Mac, failure. Created a VM with Windows and tried again, same result as with the server. Success. Seems to be a problem isolated to Mac. It has worked on Mac before so I am considering if an update has broken something.
I a compile action works on Windows but not on OSX/Linux the most common failure is a file with wrong uppercase or lowercase character in the file name (or directory name).
As Windows works case insensitive it is able to find and access the file.
OSX and Linux are working case sensitive and therefore are not able to acces the file.
Check the directory names of the package some.package.in.projectA
and the filename of the Java files that they exactly match the package respectively class name(s).

Jenkins: Duplicate building of jars in a single build

I am using Jenkins 1.596 along with Maven 3.1.1. I have multiple branches in my repository and I am using following goals for build:
'-T 5 clean install'
When I start the build, it shows following log:
Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/<my_job>/workspace
> git rev-parse --is-inside-work-tree # timeout=10
....
[workspace] $ /usr/local/apache-maven/apache-maven-3.1.1/bin/mvn -s /var/lib/jenkins/.m2/settings.xml -T 5 clean install
[INFO] Scanning for projects...
It then shows the projects and Reactor build order. It executes the tests successfully and builds all the jars. Following Success message gets displayed after completion of build:
BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3:39.752s (Wall Clock)
[INFO] Finished at: Wed Apr 15 00:02:57 BST 2015
[INFO] Final Memory: 104M/406M
Now, the issue is, just after this success message, it repeats the whole build again. It starts scanning all the poms, downloads jars, executes tests and again, I can see the success message. Following is the starting trace of unwanted build:
Parsing POMs
[workspace] $ java -Xmx1024M -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-agent-1.6.jar:/usr/local/apache-maven/apache-maven-3.1.1/boot/plexus-classworlds-2.5.1.jar:/usr/local/apache-maven/apache-maven-3.1.1/conf/logging jenkins.maven3.agent.Maven31Main /usr/local/apache-maven/apache-maven-3.1.1 /var/cache/jenkins/war/WEB-INF/lib/remoting-2.49.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-interceptor-1.6.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.6.jar 54000
<===[JENKINS REMOTING CAPACITY]===>channel started
Due to this, the whole build takes twice as much time. I have disabled archiving but that doesn't seem to have affected this. Can anyone please let me know what am I doing wrong here?
Thanks in advance.
I finally managed to figure out the cause of this. Apparently, the 'Pre Steps' was enabled in jenkins which was doing mvn clean install and then the actual build was configures to start which in turn, was doing the same thing :)
I have removed the pre step and it is now building in half amount of time compared to earlier builds.
Hope this helps someone :)

Emacs Java Malabar Mode

I was using JDEE for my java projects in Emacs. JDEE does not work well for maven. Recently I came across Malabar Mode which has better support for Maven based Java projects in Emacs.
I managed to install malbar-mode using melpa in M-x list-packages. But when I'm getting error message on mvn package for my simple app https://github.com/vijayendra/JavaSrc/tree/master/my-app
Projects.get('/home/egnyte/src/my-app/pom.xml', []).run(['package'], [], [:])
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.081s
[INFO] Finished at: Sat Dec 06 23:55:22 PST 2014
[INFO] Final Memory: 20M/48M
[INFO] ------------------------------------------------------------------------
[ERROR] Execution error
org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for or\
g.apache.maven.plugins:maven-resources-plugin:jar:2.5
at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:129)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor(DefaultMavenPluginManager.java:142)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor(DefaultMavenPluginManager.java:261)
at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor(DefaultBuildPluginManager.java:185)
My emacs version is as follows:
emacs -version
GNU Emacs 24.3.1
Copyright (C) 2013 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
My .emacs file is as follows:
(require 'package) ;; You might already have this line
(add-to-list 'package-archives
'("melpa-stable" . "http://stable.melpa.org/packages/") t)
;; unstable packages
;; (add-to-list 'package-archives
;; '("melpa" . "http://melpa.org/packages/") t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize) ;; You might already have this line
(require 'cedet)
(require 'semantic)
(load "semantic/loaddefs.el")
(semantic-mode 1)
(setq malabar-groovy-lib-dir "~/.m2/repository/com/software-ninja/malabar/1.5.10")
(require 'malabar-mode)
(add-to-list 'auto-mode-alist '("\\.java\\'" . malabar-mode))
My maven version is as follows:
mvn -version
Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T13:58:10-07:00)
Maven home: /home/egnyte/lib/apache-maven-3.2.3
Java version: 1.7.0_65, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.8.0-29-generic", arch: "amd64", family: "unix"
How can I get malabar mode to work?
There are two answers.
First, malabar-mode is stuck at maven 3.0.4 so try that version. Also do not set the lib dir. It should be set automatically.
Second, in order to get around the maven version I am rewriting malabar-mode from scratch. Follow the instructions at https://github.com/m0smith/malabar-mode/blob/develop/doc/2.0/INSTALL.md. This version should work for all versions of maven after 3.0.4. It is a work in progress and not all the features are there yet.
If you have problems or suggestions create an issue in the GitHub repo as now is a good time to get your wishes known
EDIT: 2.0 of malabar has been released to MELPA. To install now:
```
(load-file "~/projects/cedet/cedet-devel-load.el")
(add-hook 'after-init-hook (lambda ()
(message "activate-malabar-mode")
(activate-malabar-mode)))
(add-hook 'malabar-java-mode-hook 'flycheck-mode)
(add-hook 'malabar-groovy-mode-hook 'flycheck-mode)
```

Maven 3.0.5 + Windows 8 + jdk 7 issue

I trying to figure out what is happening with my maven. I have switch to windows 8 last days and found problem with building apps with maven (please see failure message at the bottom):
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.400s
[INFO] Finished at: Sat Apr 13 18:36:56 CEST 2013
[INFO] Final Memory: 18M/178M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project Example: Could not resolve dep
endencies for project
(Here are lots of libs)
Could not transfer artifact com.sun.xml.bind:jaxb-impl:pom:2.2.4-1 from/to central (
http://repo.maven.apache.org/maven2): Connection to http://repo.maven.apache.org
refused: connect: Address is invalid on local machine, or port is not valid on
remote machine -> [Help 1]
When switched to java 6, eveything is working fine. I have even disabled windows firewall, without any success though. Maybe someone has faced with that problem?
Here is my environment:
Windows 8 x64
JDK 7u17 (check on both, x86 and x64)
Maven 3.0.5
Well the answer look is so simple that I'm embarrassed to give but... . As I have written above I have disabled firewall / antyvirus but without any effect. However I don't add java as a exception to my antyvirus, which is as it turns out, scanning my apps and don't allow some to access event if it's disabled... . That's wierd but adding an exception in AV helped. Sorry for bother....

Categories

Resources