apache / apache/maven

[MNG-8253] ModelReader based Models are not readable anymore later in the build

Open
#10,762 3 comments 0 reactions 0 assignees View on GitHub
enhancement priority:major
Dominant language
Java
Stars
5.3k
Forks
3.1k
Avg merge
20h 42m
Merged PRs (30d)
297

Description

**[Christoph Läubrich](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=laeubi)** opened **[MNG-8253](https://issues.apache.org/jira/browse/MNG-8253?redirect=false)** and commented

Assume you have a ModelReader that reads a custom file (e.g. json, yaml, ...) this currently seem to result in the ModelReader Source#getPath being used as the "file model" for the POM.

This confuses some parts of maven (especially plugins) as they assume that this file is always an POM XML.

In maven-polyglot, this was circumvented by writing out the model as XML in a file named .polyglot.\.xml and this was set as the model file.

This also has had some drawbacks (that an extra file is generated (and possibly deleted after the build)) , but retained the semantics of Model#getFile to return an (xml readable) model.

As maven4 now uses Path, one way would be to hold the model in an in-memory path representation so that "reading" that path as a model again will simply return a copy, but as a first iteration using an approach similar to what polyglot does might be sufficient.

---
No further details from [MNG-8253](https://issues.apache.org/jira/browse/MNG-8253?redirect=false)

Contributor guide

Open the contributing guide

Research direction

Start by tracing how ModelReader Source#getPath becomes the POM's file model and how later Model#getFile consumers read it. Compare this behavior with the maven-polyglot workaround described in the issue. Done means models read from non-XML sources remain readable later in the build without being mistaken for POM XML.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.