[ 
https://issues.apache.org/jira/browse/MRELEASE-1129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17730808#comment-17730808
 ] 

Henning Schmiedehausen commented on MRELEASE-1129:
--------------------------------------------------

Herve: My understanding is that the "default" maven namespace identifier is  
"{{http://maven.apache.org/POM/4.0.0}}"; for the root (unnamed) namespace in the 
pom XML file. That namespace is mapped onto the schema with the 
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd"; declaration. This maps the 
"{{http://maven.apache.org/POM/4.0.0}}"; namespace identifier to the 
"{{https://maven.apache.org/xsd/maven-4.0.0.xsd}}"; schema location.  In XML 
terms, this is just convention. There is nothing magical to the string 
"http://maven.apache.org/POM/4.0.0";, literally its only requirement is that it 
is a URI, at least according to the XML spec. Is there a hard requirement 
somewhere documented that the root namespace identifier must be the 
"http://maven.apache.org/POM/4.0.0"; URI ? 

This works fine btw:

{{<project xmlns="https://foo.bar.baz"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="https://foo.bar.baz 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>}}

The release plugin however does this: 
https://github.com/apache/maven-release/blame/f744036d62a550d321b157ed547bf21f586ec065/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom2/JDomModelETL.java#L186-L198

So it does not inspect the pom for existing namespace declarations and 
mappings. As a result, the code overwrites the root namespace, but then finds 
an exisiting xsi:schemaLocation attribute, assumes that "this definition will 
contain the root namespace definition. But it does not. It only contains the 
"https://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";. What the code *should do* is, in 
case the tag exists to load it, and *add* the new definition, so that the 
resulting project tag looks like this:

{{<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
}}

now it would write the new pom correctly (the XML writer would no longer 
qualify the nested tags with the namespace identifier because it was able to 
resolve the namespace to a schema. 

so an "else" branch here: 
https://github.com/apache/maven-release/blame/f744036d62a550d321b157ed547bf21f586ec065/maven-release-manager/src/main/java/org/apache/maven/shared/release/transform/jdom2/JDomModelETL.java#L198
 is needed that loads the attribute, parses the namespace identifier/schema 
pairs, checks whether the newly created `"http://maven.apache.org/POM/"; + 
modelVersion` namespace identifier is in there and if not *add* it to the 
existing definition.

And *that* is the bug in the code. Overwriting the root namespace identifier is 
rude and should not happen in the first place, *but* if the code insists on 
doing so, then it should at least write the schema locations correctly. And it 
does not do that today.

[~michael-o] I am not sure how you came to the conclusion that "the supplied 
input is broken". Can you explain that reasoning? 






 

> https POM xmlns URIs break the release plugin
> ---------------------------------------------
>
>                 Key: MRELEASE-1129
>                 URL: https://issues.apache.org/jira/browse/MRELEASE-1129
>             Project: Maven Release Plugin
>          Issue Type: Bug
>          Components: prepare
>    Affects Versions: 3.0.1
>            Reporter: Henning Schmiedehausen
>            Priority: Major
>             Fix For: waiting-for-feedback, wontfix-candidate
>
>         Attachments: pom-after-transform.xml, pom.xml
>
>
> replacing the "http" URIs with "https" in the POM headers breaks the release 
> process. 
> When the pom gets prepared, the plugin rewrites the header back to "http" and 
> adds an xmlns section to every opening tag in the POM creating an invalid POM.
> Sadly we are stuck with http:// URIs in the POMs for now.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to