• Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Blocker Blocker
    • maven-plugin
    • None
    • Jenkins 1.580.3
      Windows Server 2008 R2
      Maven 3.3.3 automatically installed from Apache
      Maven Integration plugin 2.11

      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

          [JENKINS-30058] Support Maven Core Extensions

          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

          Arnaud Héritier added a comment - 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

          chris_mh3 added a comment -

          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)

          chris_mh3 added a comment - 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)

          chris_mh3 does the pipeline-maven-plugin support extensions?

          Jakub Bochenski added a comment - chris_mh3 does the pipeline-maven-plugin support extensions?

          chris_mh3 added a comment - - edited

          Not sure. We use bat("mvn ...") or sh("mvn ...") without the pipeline-maven plugin.

          chris_mh3 added a comment - - edited 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

           

          Arnaud Héritier added a comment - 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)?

          Jakub Bochenski added a comment - 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

          https://github.com/apache/maven/blob/master/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java

          Arnaud Héritier added a comment - 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 https://github.com/apache/maven/blob/master/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java

          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] 
          ...
          

          Cyrille Le Clerc added a comment - 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 thanks!

          Jakub Bochenski added a comment - cleclerc thanks!

          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.

          Shahriar Robbani added a comment - 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.

            Unassigned Unassigned
            chris_mh3 chris_mh3
            Votes:
            16 Vote for this issue
            Watchers:
            24 Start watching this issue

              Created:
              Updated: