You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Eric Lilja <mi...@gmail.com> on 2020/02/04 14:21:51 UTC

Prevent maven-release-plugin from reformatting attributes on project element

Hi, we noticed that maven-release-plugin changes formatting of the project
element, it writes the element as a single line, removing existing line
breaks on attributes. Is it possible to make it preserve original
formatting?

We're using maven-release-plugin version 3.0.0-M1

- Eric L

Re: Prevent maven-release-plugin from reformatting attributes on project element

Posted by Bernd Eckenfels <ec...@zusammenkunft.net>.
For the declaration element we took the easy route and use the single line element as it gets regenerated by the release.

 This is actually a good thing it contains absolutely nothing of value, so wasting only one line is ok (you just must get over the need of printing it on paper ,)


--
http://bernd.eckenfels.net
________________________________
Von: Eric Lilja <mi...@gmail.com>
Gesendet: Tuesday, February 4, 2020 7:35:01 PM
An: Maven Developers List <de...@maven.apache.org>
Betreff: Re: Prevent maven-release-plugin from reformatting attributes on project element

Sure! Today I did a release in a single module project. The unwanted diff
was that the release plugin changed

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">

to

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">

So it discarded our formatting (which had a linebreak after the
xmlns:xsi-attribute and aligned xsi:schemaLocation-attribute, column-wise,
with the xmlns-attribute, in case formatting is lost in the email) and put
all attributes on the same line as its containing element (element
"project", in this case).

I don't know if it happens only for this element or not, in our pom-files,
that is usually the only element that has so many attributes that our
formatter line splits it.

We're trying to make sure formatting is always correct in our code-base, to
get rid of unwanted noise in git diffs to make reviews smaller, that's why
this is a slight nuisance to us.

The release was done on Linux machine. All files have unix-style line
breaks, indentation is four spaces.

- Eric L

On Tue, Feb 4, 2020 at 6:47 PM Hervé BOUTEMY <he...@free.fr> wrote:

> can you provide an example of reformatting, please?
>
> in every case I saw until now, there is no reformatting, so I suppose
> you're
> in a case I did not expect
>
> Regards,
>
> Hervé
>
> Le mardi 4 février 2020, 16:24:54 CET Eric Lilja a écrit :
> > > I see.
> > > I am not aware of any such feature.
> > > If you have some tool that pretty prints XML according to your
> > > comporate rules you could invoke it in completionGoals [1]
> >
> > That could be a workaround for now. Thanks!
> >
> > - Eric L
> >
> > > Enrico
> > >
> > > [1]
> > >
> http://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.ht
> > > ml#completionGoals
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: Prevent maven-release-plugin from reformatting attributes on project element

Posted by Robert Scholte <rf...@apache.org>.
The transformation is triggered by one of the subclasses of AbstractRewritePomsPhase[1]
In 2.5.3[2] the plugin was relying on JDOM with quite some hacks to make it work. This is now extracted so it is possible to switch to a different parser (JDom is not an active project anymore).
Here's where you need to find the cause and solution.

thanks,
Robert

[1] https://github.com/apache/maven-release/blob/master/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java
[2] https://github.com/apache/maven-release/blob/maven-release-2.5.3/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java
On 4-2-2020 19:35:27, Eric Lilja <mi...@gmail.com> wrote:
Sure! Today I did a release in a single module project. The unwanted diff
was that the release plugin changed



xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">

to




So it discarded our formatting (which had a linebreak after the
xmlns:xsi-attribute and aligned xsi:schemaLocation-attribute, column-wise,
with the xmlns-attribute, in case formatting is lost in the email) and put
all attributes on the same line as its containing element (element
"project", in this case).

I don't know if it happens only for this element or not, in our pom-files,
that is usually the only element that has so many attributes that our
formatter line splits it.

We're trying to make sure formatting is always correct in our code-base, to
get rid of unwanted noise in git diffs to make reviews smaller, that's why
this is a slight nuisance to us.

The release was done on Linux machine. All files have unix-style line
breaks, indentation is four spaces.

- Eric L

On Tue, Feb 4, 2020 at 6:47 PM Hervé BOUTEMY wrote:

> can you provide an example of reformatting, please?
>
> in every case I saw until now, there is no reformatting, so I suppose
> you're
> in a case I did not expect
>
> Regards,
>
> Hervé
>
> Le mardi 4 février 2020, 16:24:54 CET Eric Lilja a écrit :
> > > I see.
> > > I am not aware of any such feature.
> > > If you have some tool that pretty prints XML according to your
> > > comporate rules you could invoke it in completionGoals [1]
> >
> > That could be a workaround for now. Thanks!
> >
> > - Eric L
> >
> > > Enrico
> > >
> > > [1]
> > >
> http://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.ht
> > > ml#completionGoals
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: Prevent maven-release-plugin from reformatting attributes on project element

Posted by Eric Lilja <mi...@gmail.com>.
Sure! Today I did a release in a single module project. The unwanted diff
was that the release plugin changed

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">

to

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">

So it discarded our formatting (which had a linebreak after the
xmlns:xsi-attribute and aligned xsi:schemaLocation-attribute, column-wise,
with the xmlns-attribute, in case formatting is lost in the email) and put
all attributes on the same line as its containing element (element
"project", in this case).

I don't know if it happens only for this element or not, in our pom-files,
that is usually the only element that has so many attributes that our
formatter line splits it.

We're trying to make sure formatting is always correct in our code-base, to
get rid of unwanted noise in git diffs to make reviews smaller, that's why
this is a slight nuisance to us.

The release was done on Linux machine. All files have unix-style line
breaks, indentation is four spaces.

- Eric L

On Tue, Feb 4, 2020 at 6:47 PM Hervé BOUTEMY <he...@free.fr> wrote:

> can you provide an example of reformatting, please?
>
> in every case I saw until now, there is no reformatting, so I suppose
> you're
> in a case I did not expect
>
> Regards,
>
> Hervé
>
> Le mardi 4 février 2020, 16:24:54 CET Eric Lilja a écrit :
> > > I see.
> > > I am not aware of any such feature.
> > > If you have some tool that pretty prints XML according to your
> > > comporate rules you could invoke it in completionGoals [1]
> >
> > That could be a workaround for now. Thanks!
> >
> > - Eric L
> >
> > > Enrico
> > >
> > > [1]
> > >
> http://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.ht
> > > ml#completionGoals
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: Prevent maven-release-plugin from reformatting attributes on project element

Posted by Hervé BOUTEMY <he...@free.fr>.
can you provide an example of reformatting, please?

in every case I saw until now, there is no reformatting, so I suppose you're 
in a case I did not expect

Regards,

Hervé

Le mardi 4 février 2020, 16:24:54 CET Eric Lilja a écrit :
> > I see.
> > I am not aware of any such feature.
> > If you have some tool that pretty prints XML according to your
> > comporate rules you could invoke it in completionGoals [1]
> 
> That could be a workaround for now. Thanks!
> 
> - Eric L
> 
> > Enrico
> > 
> > [1]
> > http://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.ht
> > ml#completionGoals





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Prevent maven-release-plugin from reformatting attributes on project element

Posted by Eric Lilja <mi...@gmail.com>.
>
> I see.
> I am not aware of any such feature.
> If you have some tool that pretty prints XML according to your
> comporate rules you could invoke it in completionGoals [1]
>

That could be a workaround for now. Thanks!

- Eric L


>
> Enrico
>
> [1]
> http://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html#completionGoals
>

Re: Prevent maven-release-plugin from reformatting attributes on project element

Posted by Enrico Olivelli <eo...@gmail.com>.
Il giorno mar 4 feb 2020 alle ore 16:17 Eric Lilja
<mi...@gmail.com> ha scritto:
>
> I didn't say the generated xml was invalid. It's a nuisance for us since
> the formatting conflicts with our corporate settings, so we are seeing
> unwelcome noise git diffs after releases.

I see.
I am not aware of any such feature.
If you have some tool that pretty prints XML according to your
comporate rules you could invoke it in completionGoals [1]

Enrico

[1] http://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html#completionGoals
>
> - Eric L
>
> On Tue, Feb 4, 2020 at 4:08 PM Enrico Olivelli <eo...@gmail.com> wrote:
>
> > Eric
> > What's your use case?
> > As far as it creates a valid XML with the same meaning this should not be a
> > problem
> >
> > Enrico
> >
> > Il Mar 4 Feb 2020, 15:22 Eric Lilja <mi...@gmail.com> ha scritto:
> >
> > > Hi, we noticed that maven-release-plugin changes formatting of the
> > project
> > > element, it writes the element as a single line, removing existing line
> > > breaks on attributes. Is it possible to make it preserve original
> > > formatting?
> > >
> > > We're using maven-release-plugin version 3.0.0-M1
> > >
> > > - Eric L
> > >
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Prevent maven-release-plugin from reformatting attributes on project element

Posted by Eric Lilja <mi...@gmail.com>.
I didn't say the generated xml was invalid. It's a nuisance for us since
the formatting conflicts with our corporate settings, so we are seeing
unwelcome noise git diffs after releases.

- Eric L

On Tue, Feb 4, 2020 at 4:08 PM Enrico Olivelli <eo...@gmail.com> wrote:

> Eric
> What's your use case?
> As far as it creates a valid XML with the same meaning this should not be a
> problem
>
> Enrico
>
> Il Mar 4 Feb 2020, 15:22 Eric Lilja <mi...@gmail.com> ha scritto:
>
> > Hi, we noticed that maven-release-plugin changes formatting of the
> project
> > element, it writes the element as a single line, removing existing line
> > breaks on attributes. Is it possible to make it preserve original
> > formatting?
> >
> > We're using maven-release-plugin version 3.0.0-M1
> >
> > - Eric L
> >
>

Re: Prevent maven-release-plugin from reformatting attributes on project element

Posted by Enrico Olivelli <eo...@gmail.com>.
Eric
What's your use case?
As far as it creates a valid XML with the same meaning this should not be a
problem

Enrico

Il Mar 4 Feb 2020, 15:22 Eric Lilja <mi...@gmail.com> ha scritto:

> Hi, we noticed that maven-release-plugin changes formatting of the project
> element, it writes the element as a single line, removing existing line
> breaks on attributes. Is it possible to make it preserve original
> formatting?
>
> We're using maven-release-plugin version 3.0.0-M1
>
> - Eric L
>

Re: Prevent maven-release-plugin from reformatting attributes on project element

Posted by Bernd Eckenfels <ec...@zusammenkunft.net>.
It is quite likely that it was fixed/changed and we never fixed the broken indentions in existing poms, that's why I am still reminded of it :) I will test later.


--
http://bernd.eckenfels.net
________________________________
Von: Eric Lilja <mi...@gmail.com>
Gesendet: Tuesday, February 4, 2020 8:41:03 PM
An: Maven Developers List <de...@maven.apache.org>
Betreff: Re: Prevent maven-release-plugin from reformatting attributes on project element

Ah, yes, I do remember the changed indentation of the tag element in the
past, put I don't recall seeing that lately. Have to check tomorrow when I
get to the office.

Bernd: Which version of the maven-release-plugin did you use?

- Eric L

On Tue, Feb 4, 2020 at 8:30 PM Bernd Eckenfels <ec...@zusammenkunft.net>
wrote:

> Hm, for me it keeps the line breaks, it does however change the intention
> for the tag element. I thought this was configurable, but can't find it at
> the moment.
>
> Anyway this is an open (and rejected) issue:
> https://issues.apache.org/jira/browse/MRELEASE-1008
>
> Gruss
> Bernd
> --
> http://bernd.eckenfels.net
> ________________________________
> Von: Eric Lilja <mi...@gmail.com>
> Gesendet: Tuesday, February 4, 2020 3:21:51 PM
> An: Maven Developers List <de...@maven.apache.org>
> Betreff: Prevent maven-release-plugin from reformatting attributes on
> project element
>
> Hi, we noticed that maven-release-plugin changes formatting of the project
> element, it writes the element as a single line, removing existing line
> breaks on attributes. Is it possible to make it preserve original
> formatting?
>
> We're using maven-release-plugin version 3.0.0-M1
>
> - Eric L
>

Re: Prevent maven-release-plugin from reformatting attributes on project element

Posted by Eric Lilja <mi...@gmail.com>.
Ah, yes, I do remember the changed indentation of the tag element in the
past, put I don't recall seeing that lately. Have to check tomorrow when I
get to the office.

Bernd: Which version of the maven-release-plugin did you use?

- Eric L

On Tue, Feb 4, 2020 at 8:30 PM Bernd Eckenfels <ec...@zusammenkunft.net>
wrote:

> Hm, for me it keeps the line breaks, it does however change the intention
> for the tag element. I thought this was configurable, but can't find it at
> the moment.
>
> Anyway this is an open (and rejected) issue:
> https://issues.apache.org/jira/browse/MRELEASE-1008
>
> Gruss
> Bernd
> --
> http://bernd.eckenfels.net
> ________________________________
> Von: Eric Lilja <mi...@gmail.com>
> Gesendet: Tuesday, February 4, 2020 3:21:51 PM
> An: Maven Developers List <de...@maven.apache.org>
> Betreff: Prevent maven-release-plugin from reformatting attributes on
> project element
>
> Hi, we noticed that maven-release-plugin changes formatting of the project
> element, it writes the element as a single line, removing existing line
> breaks on attributes. Is it possible to make it preserve original
> formatting?
>
> We're using maven-release-plugin version 3.0.0-M1
>
> - Eric L
>

Re: Prevent maven-release-plugin from reformatting attributes on project element

Posted by Bernd Eckenfels <ec...@zusammenkunft.net>.
Hm, for me it keeps the line breaks, it does however change the intention for the tag element. I thought this was configurable, but can't find it at the moment.

Anyway this is an open (and rejected) issue: https://issues.apache.org/jira/browse/MRELEASE-1008

Gruss
Bernd
--
http://bernd.eckenfels.net
________________________________
Von: Eric Lilja <mi...@gmail.com>
Gesendet: Tuesday, February 4, 2020 3:21:51 PM
An: Maven Developers List <de...@maven.apache.org>
Betreff: Prevent maven-release-plugin from reformatting attributes on project element

Hi, we noticed that maven-release-plugin changes formatting of the project
element, it writes the element as a single line, removing existing line
breaks on attributes. Is it possible to make it preserve original
formatting?

We're using maven-release-plugin version 3.0.0-M1

- Eric L