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

UTF-8 BOM in pom.xml breaks banDuplicatePomDependencyVersions rule

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.0-M2
    • 3.0.0-M3
    • Standard Rules
    • None
    • Patch

    Description

      Having UTF-8 BOM at the beginning of pom.xml causes the banDuplicatePomDependencyVersions rule to fail to parse the file with the following exception being shown by -X output:

      [DEBUG] Adding failure due to exception
      org.apache.maven.enforcer.rule.api.EnforcerRuleException: Unable to retrieve the MavenProject:
          at org.apache.maven.plugins.enforcer.BanDuplicatePomDependencyVersions.execute (BanDuplicatePomDependencyVersions.java:87)
          at org.apache.maven.plugins.enforcer.EnforceMojo.execute (EnforceMojo.java:194)
          at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
          at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
          at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
          at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
          at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
          at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
          at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
          at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
          at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (Unknown Source)
          at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (Unknown Source)
          at java.lang.reflect.Method.invoke (Unknown Source)
          at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
          at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
          at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
          at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
      Caused by: org.codehaus.plexus.util.xml.pull.XmlPullParserException: only whitespace content allowed before start tag and not \uef (position: START_DOCUMENT seen \uef... @1:1)
          at org.codehaus.plexus.util.xml.pull.MXParser.parseProlog (MXParser.java:1862)
          at org.codehaus.plexus.util.xml.pull.MXParser.nextImpl (MXParser.java:1698)
          at org.codehaus.plexus.util.xml.pull.MXParser.next (MXParser.java:1317)
          at org.apache.maven.model.io.xpp3.MavenXpp3Reader.read (MavenXpp3Reader.java:3856)
          at org.apache.maven.model.io.xpp3.MavenXpp3Reader.read (MavenXpp3Reader.java:595)
          at org.apache.maven.model.io.xpp3.MavenXpp3Reader.read (MavenXpp3Reader.java:609)
          at org.apache.maven.plugins.enforcer.BanDuplicatePomDependencyVersions.execute (BanDuplicatePomDependencyVersions.java:75)
          at org.apache.maven.plugins.enforcer.EnforceMojo.execute (EnforceMojo.java:194)
          at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
          at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
          at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
          at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
          at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
          at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
          at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
          at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
          at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
          at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (Unknown Source)
          at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (Unknown Source)
          at java.lang.reflect.Method.invoke (Unknown Source)
          at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
          at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
          at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
          at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
      [WARNING] Rule 0: org.apache.maven.plugins.enforcer.BanDuplicatePomDependencyVersions failed with message:
      Unable to retrieve the MavenProject:
      
      

      See attached pom.xml for minimal example.

      Attached patch changes the parsing to be compatible with UTF-8 BOM and fixes the issue for me.

      Attachments

        Issue Links

          Activity

            People

              eolivelli Enrico Olivelli
              wilx Václav Haisman
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m