-
Bug
-
Resolution: Unresolved
-
Blocker
-
None
-
Jenkins 1.580.3
Windows Server 2008 R2
Maven 3.3.3 automatically installed from Apache
Maven Integration plugin 2.11
-
Powered by SuggestiMate
It seems that the maven (in a maven project) is not picking up .mvn/extensions.xml beside the executed pom.xml.
Executed from the windows command line the project builds fine.
Some testing with command line maven showed that the .mvn folder needs to be in the directory where the mvn command is executed.
mvn -f somesubdirecotry_with_.mvn does not work
I believe mvn is not actually executed in the workspace on jenkins.
http://takari.io/2015/03/19/core-extensions.html
http://wiki.eclipse.org/Tycho/Release_Notes/0.24
- is related to
-
JENKINS-44057 Option to Disable Parsing pom in jenkins during maven build.
-
- Open
-
- relates to
-
JENKINS-28629 Fix Apache Maven 3.3 support
-
- Resolved
-
- links to
[JENKINS-30058] Support Maven Core Extensions
This is quite frustrating ... just started to use pomless tycho builds and now they don't work out on Jenkins It seems, that it is even not possible to manually load the core extension such as to use the feature at all ....
Is there any time plan when this will be fixed?
Thanks a lot guys!!
I played around on this from a users perspective. Here are my results:
1. I installed Jenkins on my local Windows machine and started it via WAR file. I configured my local Maven installation (MAVEN_HOME) and run a pom-less Tycho build (using Maven Core Extensions). The build worked fine. I could see that the mvn.cmd was called.
2. I tried the same on our company build server, which is a Linux server. There we used at first the option that Maven is installed from Apache by Jenkins. That failed because the Maven Core Extensions are not loaded. Then we tried to use a local Maven installation by setting MAVEN_HOME. But that also failed. We noticed that Maven is started via org.codehaus.plexus.classworlds.launcher.Launcher.
3. We tried to execute the Maven build using a Shell Script and called "mvn clean verify -f <path-to-pom.xml>" ... that worked out. So my assumption is that there is something wrong with the org.codehaus.plexus.classworlds.launcher.Launcher. Although I don't know what it is exactly.
I have to correct myself. In our build system there is also a Artifactory plugin installed. I accidentially used the Maven build from that plugin. That one fails with the usage of org.codehaus.plexus.classworlds.launcher.Launcher.
After I changed that to use the Maven integration plugin ("Invoke top-level Maven targets") the build works fine.
Note that I am using a freestyle project and not a Maven project. From my experience the Maven project type is not very stable.
I could make it work by creating a pom.xml for every project in the multi-module build.
...not so nice because I wanted to avoid having pom and manifest.mf/plugin.xml, but at least the build works again
There is a tycho-pomgenerator-plugin that can be used to create the missing pom.xml with just one command.
And there is another that helps to keep version numbers in sync
After that the build worked in Jenkins and with mvn -f ./subdir/pom.xml
That doesn't make sense. The issue reported is that maven extensions doesn't work. And therefore pom-less Tycho doesn't work. Adding pom files again can't be the solution.
I have found out that the issue is related to the Maven build plugin. Using the freestyle project template it works fine.
This is also definitely blocking me from making full use of maven based tests etc ... using freestyle as an in betweens but really looking for a thorough solution.
From my point of view this feature is getting more and more important with every day that passes. New developers are likely to prefer the pomless style against the manual management of poms ...
This is a core maven feature – another one that is missing. Is the Maven integration completely useless? https://javaadventure.blogspot.com/2013/11/jenkins-maven-job-type-considered-evil.html
The only way to make extensions work is to use the "Invoke Top-Level Maven targets" step from Freestyle project and a custom Maven installation.
It will the pick-up extensions from lib/ext.
It doesn't work in a Maven Project main step even with a custom Maven installation.
It doesn't work for extensions declared in .mvn folder.
For me it works with Freestyle projects and a .mvn folder in the root of the job's workspace. That seems to be the maven execution directory for "Invoke Top-Level Maven targets" even if the pom is in a sub folder.
But yes this issue makes maven jobs useless for me.
@chris_mh3 I was testing it in a Maven Project, which had a .mvn folder at workspace root, by adding a "Invoke Top-Level Maven targets" step. So it also works in a Maven Project, but not in the main step.
Updated results:
- Invoke Top-Level Maven targets works with .mvn folder at workspace root in both Freestyle and Maven Projects
- Main Maven Project build doesn't work with neither .mvn folder at workspace root nor a custom Maven installation
I'm going to test further:
- Invoke Top-Level Maven targets with a custom Maven installation and w/o .mvn folder
- Maven 3.4.0-SNAPSHOT build as it includes fix for https://issues.apache.org/jira/browse/MNG-5889
apache-maven-3.4.0-20161124.073639-240 seems to behave exactly the same as 3.3.9
The problem is documented here and in JENKINS-28629 and the explanation a bit complex due to the confusion between the 2 issues.
A maven extension can be loaded historically from the the POM (https://maven.apache.org/guides/mini/guide-using-extensions.html) or from ${MAVEN_DIST}/lib/ext
But since 3.3.x it can be loaded from ${maven.multiModuleProjectDirectory}/.mvn/extensions.xml
( http://takari.io/2015/03/19/core-extensions.html ) which allows to use the extension to read a POM in a non native format and avoids to modify the maven distribution
Additionally a bug in Maven ( https://issues.apache.org/jira/browse/MNG-5889 fixed in 3.5.x see JENKINS-28629) didn't allow to use the .mvn folder properly
Because the parsing of POMs isn't done by Maven itself, extensions are loaded if they aren't defined in the POM. It could probably possible to implement the load of extensions from ${maven.multiModuleProjectDirectory}/.mvn/extensions.xml but not sure from ${MAVEN_DIST}/lib/ext
In any case I'm not sure it will be transparent enough to allow for exemple the usage of things like Polyglot : https://github.com/takari/polyglot-maven
For my use case (i.e. building eclipse plugins) I would only have needed loading extensions from the project directory (module directory and parents) not from /lib/ext. We do not modify the maven distribution.
(We switched to pipeline in the meantime)
Not sure. We use bat("mvn ...") or sh("mvn ...") without the pipeline-maven plugin.
jbochenski, chris_mh3 yes the pipeline integration is more basic. by default if you don't use the pipeline-maven plugin you'll just use maven like in a freestyle.
With pipeline-maven plugin you have few more features like the triggering across SNAPSHOTs. The advantage is that the implementation is completely different than the one of the maven plugin. It doesn't rely on -pre-parsing / analysing your POMs to understand what your build is consuming/producing but it is using a maven extension as a spy which is injecting in your real maven build thus there are many less side-effects.
You should consider to have a look at it, it is really powerful enough nowadays to replace a large part of usages of maven jobs and you can get the power of pipeline jobs (multi-branches discovery, persistent builds ...)
https://wiki.jenkins.io/display/JENKINS/Pipeline+Maven+Plugin
aheritier I know MavenSpy is an extension. Still I'd appreciate a clear answer to this:
Does pipeline-maven-plugin have official support Maven Core extensions (ones added by the user, not MavenSpy)?
Not tested myself jbochenski
Not sure if cleclerc did it
But with my limited knowledge of this plugin I don't see why it couldn't work. Using -Dmaven.ext.class.path shouldn't interfere with others extensions loaded from the POM, .m2/extensions.xml, Maven's lib/ext
Reading the maven code (cc hboutemy, stephenconnolly) the Spy extension is loaded independently
jbochenski Maven core extensions seem to work with withMaven.
Evidence:
node { withMaven(maven: "maven-3.5.2"){ git "https://github.com/takari/core-extensions-example.git" sh "mvn package" } }
In the build logs, you will see "Using the SmartBuilder implementation with a thread count of 8"
... + mvn package ----- withMaven Wrapper script ----- Picked up JAVA_TOOL_OPTIONS: -Dmaven.ext.class.path="/home/ubuntu/jenkins-aws-home/workspace/tests/JENKINS-30058-maven-core-extensions@tmp/withMavenb24b7dd9/pipeline-maven-spy.jar" -Dorg.jenkinsci.plugins.pipeline.maven.reportsFolder="/home/ubuntu/jenkins-aws-home/workspace/tests/JENKINS-30058-maven-core-extensions@tmp/withMavenb24b7dd9" Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T07:58:13Z) Maven home: /home/ubuntu/jenkins-aws-home/tools/hudson.tasks.Maven_MavenInstallation/maven-3.5.2 Java version: 1.8.0_141, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.13.0-135-generic", arch: "amd64", family: "unix" [jenkins-maven-event-spy] INFO generate /home/ubuntu/jenkins-aws-home/workspace/tests/JENKINS-30058-maven-core-extensions@tmp/withMavenb24b7dd9/maven-spy-20171122-093258-25279878962038760639.log.tmp ... [INFO] Scanning for projects... [INFO] [INFO] Using the SmartBuilder implementation with a thread count of 8 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building core-extensions-example 0.1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] ...
cleclerc Hi, it is working for pom-less builds?
Please see the last comment of Drik: http://blog.vogella.com/2015/12/15/pom-less-tycho-builds-for-structured-environments/
I think the pomless build for Jenkins maven project plugin is broken for ages. I don't know if this will be really solved or not.
This is a fairly big issue that jenkins doesn't support a feature of maven. Any updates on this?
It also doesn't work on an RHEL server or Ubuntu server with apache-maven-3.3.3 manually installed.