Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-6117

${session.parallel} not correctly set

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.3.9
    • Fix Version/s: 3.5.0-alpha-1, 3.5.0
    • Component/s: None
    • Labels:
      None

      Description

      Running mvn help:evaluate -T 3 and resolving the property session.parallel returns true when run with Maven 3.0.5.

      When running it with 3.3.9, this property resolves to false.

      mvn help:evaluate -T 3
      [INFO] Scanning for projects...
      [INFO]
      [INFO] Using the MultiThreadedBuilder implementation with a thread count of 3
      [INFO]
      [INFO] ------------------------------------------------------------------------
      [INFO] Building Maven Stub Project (No POM) 1
      [INFO] ------------------------------------------------------------------------
      [INFO]
      [INFO] --- maven-help-plugin:2.2:evaluate (default-cli) @ standalone-pom ---
      [INFO] No artifact parameter specified, using 'org.apache.maven:standalone-pom:pom:1' as project.
      [INFO] Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:
      ${session.parallel}
      [INFO]
      false
      

      E.g. Surefire relies on this property, to check whether Maven is running in parallel mode, as mentioned in the comments of SUREFIRE-1301.

        Issue Links

          Activity

          Hide
          gboue Guillaume Boué added a comment -

          The parallel flag is indeed never set to true when the build is done in parallel.

          However, there is a special consideration: the current MultiThreadedBuilder will only build in parallel when the degree of concurrency (determined with -T) is at least 2, and when there are at least 2 projects to build. So running mvn help:evaluate -T 3 on a single project (like the stub project) will still build the project with just 1 thread. In this case, which is the example in the description, I think session.parallel should still return false (and not true like Maven 3.0.5 does, in the given example): even though -T 3 was set, it is ignored and only one thread is going to be used, resulting is a sequential, and not parallel, build.

          To me, the fix here is to have session.parallel set to true when more than 1 thread are actually used to build. MultiThreadedBuilder does not clearly document the number of threads used, but if we agree on this, I'll also add it to reflect that.

          Show
          gboue Guillaume Boué added a comment - The parallel flag is indeed never set to true when the build is done in parallel. However, there is a special consideration: the current MultiThreadedBuilder will only build in parallel when the degree of concurrency (determined with -T ) is at least 2, and when there are at least 2 projects to build. So running mvn help:evaluate -T 3 on a single project (like the stub project) will still build the project with just 1 thread. In this case, which is the example in the description, I think session.parallel should still return false (and not true like Maven 3.0.5 does, in the given example): even though -T 3 was set, it is ignored and only one thread is going to be used, resulting is a sequential, and not parallel, build. To me, the fix here is to have session.parallel set to true when more than 1 thread are actually used to build. MultiThreadedBuilder does not clearly document the number of threads used, but if we agree on this, I'll also add it to reflect that.
          Hide
          rraumberger Richard Raumberger added a comment -

          I'm sorry for the misunderstanding. I wasn't aware of the fact, that this special behaviour exists for the MultiThreadedBuilder. The behaviour does make sense, though.

          A valid example using the correct amount of threads, which avoids the mentioned special behaviour can be found here. Which results in session.parallel to be false for all threads, when run with mvn clean test -T 3 | grep isParallel.
          If the same command is executed with Maven 3.0.5 the property is correctly set.

          Your fix sounds ok for me.

          Show
          rraumberger Richard Raumberger added a comment - I'm sorry for the misunderstanding. I wasn't aware of the fact, that this special behaviour exists for the MultiThreadedBuilder . The behaviour does make sense, though. A valid example using the correct amount of threads, which avoids the mentioned special behaviour can be found here . Which results in session.parallel to be false for all threads, when run with mvn clean test -T 3 | grep isParallel . If the same command is executed with Maven 3.0.5 the property is correctly set. Your fix sounds ok for me.
          Hide
          gboue Guillaume Boué added a comment -
          Show
          gboue Guillaume Boué added a comment - Fixed in dfb4a7b7f4225bc32385da139679e189a2aeb79a .
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build maven-3.x #1414 (See https://builds.apache.org/job/maven-3.x/1414/)
          MNG-6117 $

          {session.parallel}

          not correctly set (gboue: rev dfb4a7b7f4225bc32385da139679e189a2aeb79a)

          • (edit) maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build maven-3.x #1414 (See https://builds.apache.org/job/maven-3.x/1414/ ) MNG-6117 $ {session.parallel} not correctly set (gboue: rev dfb4a7b7f4225bc32385da139679e189a2aeb79a) (edit) maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
          Hide
          stephenc Stephen Connolly added a comment -

          Maven 3.4.0 has been dropped. See this thread for more details.

          This issue will need to be re-scheduled for a Maven release in the (hopefully near) future.

          Show
          stephenc Stephen Connolly added a comment - Maven 3.4.0 has been dropped. See this thread for more details. This issue will need to be re-scheduled for a Maven release in the (hopefully near) future.
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build maven-3.x #1498 (See https://builds.apache.org/job/maven-3.x/1498/)
          MNG-6117 $

          {session.parallel}

          not correctly set (gboue: http://git-wip-us.apache.org/repos/asf/?p=maven.git&a=commit&h=d413296cf396d4df385d1323843f9464af0c8a3e)

          • (edit) maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build maven-3.x #1498 (See https://builds.apache.org/job/maven-3.x/1498/ ) MNG-6117 $ {session.parallel} not correctly set (gboue: http://git-wip-us.apache.org/repos/asf/?p=maven.git&a=commit&h=d413296cf396d4df385d1323843f9464af0c8a3e ) (edit) maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/multithreaded/MultiThreadedBuilder.java

            People

            • Assignee:
              gboue Guillaume Boué
              Reporter:
              rraumberger Richard Raumberger
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development