Maven
  1. Maven
  2. MNG-2715

Maven does not comply to XML rules regarding prefixes.

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Critical Critical
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: POM
    • Labels:
      None
    • Environment:
      Ubuntu 6.10
      Maven 2.0.4
    • Complexity:
      Intermediate
    • Number of attachments :
      0

      Description

      I am new to Maven and have been trying to learn how to create a simple project.
      Let me walk through my scenario of creating a pom.xml file:
      1. I bind the

      {http://maven.apache.org/POM/4.0.0}

      namespace (defined at "http://maven.apache.org/maven-v4_0_0.xsd") to Java classes using an XML Binding solution.
      2. I use the bound classes to create a simple <project/> as one would expect to see in a pom.xml file.
      3. I marshal the bound Java objects into xml and write it into pom.xml. Here is the xml I use:
      <ns1:project
      xmlns:ns1="http://maven.apache.org/POM/4.0.0">
      <ns1:modelVersion>4.0.0</ns1:modelVersion>
      <ns1:groupId>com.myapp</ns1:groupId>
      <ns1:artifactId>sample-project</ns1:artifactId>
      <ns1:name>Sample Maven Project</ns1:name>
      <ns1:version>1.0</ns1:version>
      <ns1:developers>
      <ns1:developer>
      <ns1:id>ssafris</ns1:id>
      <ns1:name>Seva Safris</ns1:name>
      </ns1:developer>
      </ns1:developers>
      <ns1:build>
      <ns1:sourceDirectory>$

      {basedir}

      /src/java</ns1:sourceDirectory>
      </ns1:build>
      </ns1:project>
      4. I run mvn, and am promptly given a "Not a v4.0.0 POM." exception.

      Tracing through Maven's source, I went to the exact location of the exception in DefaultMavenProjectBuilder.java. On line 1297 it has:

      if ( modelSource.indexOf( "<modelVersion>4.0.0" ) < 0 )
      {
      throw new InvalidProjectModelException( projectId, pomLocation, "Not a v4.0.0 POM." );
      }

      Since modelSource is checked explicitly for <modelVersion[...], my <project/> xml as shown above will fail this test because it has: <ns1:modelVersion[...].

      This is most definitely a bug in Maven and should be fixed as soon as possible. The workaround is to use a xmlns="http://maven.apache.org/POM/4.0.0" and define all elements without a prefix. However, my use of xmlns:ns1="http://maven.apache.org/POM/4.0.0" should not break Maven as it is not merely legal by xml conventions, but is also a better practice for xml documents.

      I hope you see the importance of getting this bug fixed: My use of a XML Binding solution to bind Maven's xml to Java allows me a strongly-typed level of indirection that will deterministically create proper xml that will validate successfully. If this bug is not fixed, then this level of indirection is not possible (or very very very difficult because the XML Binding solution would have to be hacked to use the xmlns="[...]" convention). I have only found this one instance of where the bug is obvious, but perhaps there are more locations in Maven where the same kind of error can occur.

      Thank you for your time, and I hope you consider this issue as seriously as I do.

      Sincerely,

      Seva Safris

        Issue Links

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Seva Safris
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: