Uploaded image for project: 'Maven Enforcer Plugin'
  1. Maven Enforcer Plugin
  2. MENFORCER-477

failWhenParentIsSnapshot does not respect onlyWhenRelease

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 3.2.1, 3.3.0
    • None
    • None
    • None

    Description

      I have a snapshot project that has a snapshot parent.

      At release time, I want to use the enforcer plugin to make sure the release version of my project only depends on release versions, including the parent, so I use failWhenParentIsSnapshot=true.

      For snapshot versions of my project, I want to allow snapshot dependencies including snapshot parent, so I use onlyWhenRelease=true to disable the enforcer for snapshot versions.

      Expected: my snapshot project build succeeds with a snapshot parent.

      Actual: my snapshot project build fails with a snapshot parent, despite onlyWhenRelease=true.

      I suspect that failWhenParentIsSnapshot does not take onlyWhenRelease into account.

      The intuitive fix for me would be that the combination of both options behaves as expected.

      I imagine that maybe it was a design choice to keep both options completely independent of each other, so an acceptable alternative for me would be to introduce yet another option, e.g. onlyWhenParentIsRelease that behaves similar to onlyWhenRelease but applies to the parent only.

      [WARNING] 
      [WARNING] Some problems were encountered while building the effective settings
      [WARNING] Unrecognised tag: 'properties' (position: START_TAG seen ...</servers>\n\t<properties>... @13:14)  @ /home/peter/.m2/settings.xml, line 13, column 14
      [WARNING] 
      [INFO] Scanning for projects...
      [WARNING] 
      [WARNING] Some problems were encountered while building the effective model for su.pernova:assertions-parent:pom:1.1.0-SNAPSHOT
      [WARNING] 'build.pluginManagement.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-failsafe-plugin @ su.pernova:bom:1.1.0-SNAPSHOT, /home/peter/.m2/repository/su/pernova/bom/1.1.0-SNAPSHOT/bom-1.1.0-SNAPSHOT.pom, line 263, column 17
      [WARNING] 
      [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
      [WARNING] 
      [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
      [WARNING] 
      [INFO] Inspecting build with total of 5 modules...
      [INFO] Installing Nexus Staging features:
      [INFO]   ... total of 5 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
      [INFO] ------------------------------------------------------------------------
      [INFO] Reactor Build Order:
      [INFO] 
      [INFO] Supernova Assertions - Parent                                      [pom]
      [INFO] Supernova Assertions - Main                                        [jar]
      [INFO] Supernova Assertions - JUnit 4                                     [jar]
      [INFO] Supernova Assertions - JUnit 5                                     [jar]
      [INFO] Supernova Assertions - JUnit 4 + JUnit 5                           [jar]
      [INFO] 
      [INFO] --------------------< su.pernova:assertions-parent >--------------------
      [INFO] Building Supernova Assertions - Parent 1.1.0-SNAPSHOT              [1/5]
      [INFO] --------------------------------[ pom ]---------------------------------
      [INFO] 
      [INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) @ assertions-parent ---
      [INFO] 
      [INFO] --- flatten-maven-plugin:1.3.0:clean (flatten-clean) @ assertions-parent ---
      [INFO] 
      [INFO] --- maven-enforcer-plugin:3.2.1:enforce (enforce-no-snapshots-in-releases) @ assertions-parent ---
      [INFO] ------------------------------------------------------------------------
      [INFO] Reactor Summary for Supernova Assertions - Parent 1.1.0-SNAPSHOT:
      [INFO] 
      [INFO] Supernova Assertions - Parent ...................... FAILURE [  0.464 s]
      [INFO] Supernova Assertions - Main ........................ SKIPPED
      [INFO] Supernova Assertions - JUnit 4 ..................... SKIPPED
      [INFO] Supernova Assertions - JUnit 5 ..................... SKIPPED
      [INFO] Supernova Assertions - JUnit 4 + JUnit 5 ........... SKIPPED
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD FAILURE
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time:  1.023 s
      [INFO] Finished at: 2023-04-06T21:12:23+02:00
      [INFO] ------------------------------------------------------------------------
      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.2.1:enforce (enforce-no-snapshots-in-releases) on project assertions-parent: 
      [ERROR] Rule 0: org.apache.maven.enforcer.rules.dependency.RequireReleaseDeps failed with message:
      [ERROR] Parent Cannot be a snapshot: su.pernova:bom:pom:1.1.0-SNAPSHOT
      [ERROR] -> [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
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            peterdm Peter De Maeyer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: