[jira] [Commented] (MNG-7589) MavenXpp3Writer write empty property with self-closing tag?
[ https://issues.apache.org/jira/browse/MNG-7589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17731647#comment-17731647 ] Guillaume Nodet commented on MNG-7589: -- Do you have a simple reproducer project to investigate a bit ? > MavenXpp3Writer write empty property with self-closing tag? > --- > > Key: MNG-7589 > URL: https://issues.apache.org/jira/browse/MNG-7589 > Project: Maven > Issue Type: Wish > Components: Core >Affects Versions: 3.8.6 > Environment: Maven 3.8.6 >Reporter: Jeff Thomas >Priority: Trivial > > I am using a maven-plugin which manipulates the POM and writes a new POM > model. (similar to 'maven-git-versioning-extension' or > 'flatten-maven-plugin'). > When writing a POM using the MavenXpp3Writer a property without a value is > written out as follows: > > {code:java} > > > > > > {code} > > Would it be possible to write this out with a self-closing tag? Or provide an > option to the writer to do so? > > {code:java} > > > > > {code} > Its just eye-candy but the IDE (IntelliJ) displays warnings for empty tags > and I don't want to disable the check globally. :) > > Why empty properties? > For some plugins we use empty properties as placeholders which child projects > or sub-modules can override. For example: maven-surefire-plugin `argLine`. > This prevents other IDE errors for missing properties when editing the POM. > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7589) MavenXpp3Writer write empty property with self-closing tag?
[ https://issues.apache.org/jira/browse/MNG-7589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17628896#comment-17628896 ] Jeff Thomas commented on MNG-7589: -- In fact on the master branch it "looks" like a property with no value will not even be written...which is sort of more of a problem for me. :( writer.vm {code:java} private void writeTag( String tagName, String defaultValue, String value, XmlSerializer serializer ) throws IOException { if ( value != null && !Objects.equals( defaultValue, value ) ) { serializer.startTag( NAMESPACE, tagName ).text( value ).endTag( NAMESPACE, tagName ); } } {code} This would make empty tags that were added as placeholders disappear when simply reading and re-writing the model. > MavenXpp3Writer write empty property with self-closing tag? > --- > > Key: MNG-7589 > URL: https://issues.apache.org/jira/browse/MNG-7589 > Project: Maven > Issue Type: Wish > Components: Core >Affects Versions: 3.8.6 > Environment: Maven 3.8.6 >Reporter: Jeff Thomas >Priority: Trivial > > I am using a maven-plugin which manipulates the POM and writes a new POM > model. (similar to 'maven-git-versioning-extension' or > 'flatten-maven-plugin'). > When writing a POM using the MavenXpp3Writer a property without a value is > written out as follows: > > {code:java} > > > > > > {code} > > Would it be possible to write this out with a self-closing tag? Or provide an > option to the writer to do so? > > {code:java} > > > > > {code} > Its just eye-candy but the IDE (IntelliJ) displays warnings for empty tags > and I don't want to disable the check globally. :) > > Why empty properties? > For some plugins we use empty properties as placeholders which child projects > or sub-modules can override. For example: maven-surefire-plugin `argLine`. > This prevents other IDE errors for missing properties when editing the POM. > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7589) MavenXpp3Writer write empty property with self-closing tag?
[ https://issues.apache.org/jira/browse/MNG-7589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17628892#comment-17628892 ] Jeff Thomas commented on MNG-7589: -- Yeah I sort of saw that ...but was confused about MavenXpp3Writer both being generated in Modello *and* checked in on the 'master' branch. :) In 3.8.6 it is only generated. On 'master' it seems the maven-model has taken more control over the source-code generation or rather the writer model ("mdo/writer.vm"). I mean the "fix" would be relatively easy here just conditionally test for null/empty and leave off the 'entry.getValue()' and XmlSerializer just auto-closes the element. {code:java} private void writeProperties( String tagName, Map props, XmlSerializer serializer ) throws IOException { if ( props != null && !props.isEmpty() ) { serializer.startTag( NAMESPACE, tagName ); for ( Map.Entry entry : props.entrySet() ) { writeTag( entry.getKey(), null, entry.getValue(), serializer ); } serializer.endTag( NAMESPACE, tagName ); } }{code} However, I know the self-closing tags are sort of a discussion point so I wasn't really sure if it was a good idea or not... Like I said this is just "eye-candy" of sorts, the Maven Xpp3 Reader doesn't seem to care either way if "{{{}{}}}" or "". If this is just too trivial please go ahead and close the issue :) I won't be offended haha > MavenXpp3Writer write empty property with self-closing tag? > --- > > Key: MNG-7589 > URL: https://issues.apache.org/jira/browse/MNG-7589 > Project: Maven > Issue Type: Wish > Components: Core >Affects Versions: 3.8.6 > Environment: Maven 3.8.6 >Reporter: Jeff Thomas >Priority: Trivial > > I am using a maven-plugin which manipulates the POM and writes a new POM > model. (similar to 'maven-git-versioning-extension' or > 'flatten-maven-plugin'). > When writing a POM using the MavenXpp3Writer a property without a value is > written out as follows: > > {code:java} > > > > > > {code} > > Would it be possible to write this out with a self-closing tag? Or provide an > option to the writer to do so? > > {code:java} > > > > > {code} > Its just eye-candy but the IDE (IntelliJ) displays warnings for empty tags > and I don't want to disable the check globally. :) > > Why empty properties? > For some plugins we use empty properties as placeholders which child projects > or sub-modules can override. For example: maven-surefire-plugin `argLine`. > This prevents other IDE errors for missing properties when editing the POM. > -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MNG-7589) MavenXpp3Writer write empty property with self-closing tag?
[ https://issues.apache.org/jira/browse/MNG-7589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17628744#comment-17628744 ] Michael Osipov commented on MNG-7589: - The writer is auto generated. You need to look into Codehaus Modello. This component decides about this. > MavenXpp3Writer write empty property with self-closing tag? > --- > > Key: MNG-7589 > URL: https://issues.apache.org/jira/browse/MNG-7589 > Project: Maven > Issue Type: Wish > Components: Core >Affects Versions: 3.8.6 > Environment: Maven 3.8.6 >Reporter: Jeff Thomas >Priority: Trivial > > I am using a maven-plugin which manipulates the POM and writes a new POM > model. (similar to 'maven-git-versioning-extension' or > 'flatten-maven-plugin'). > When writing a POM using the MavenXpp3Writer a property without a value is > written out as follows: > > {code:java} > > > > > > {code} > > Would it be possible to write this out with a self-closing tag? Or provide an > option to the writer to do so? > > {code:java} > > > > > {code} > Its just eye-candy but the IDE (IntelliJ) displays warnings for empty tags > and I don't want to disable the check globally. :) > > Why empty properties? > For some plugins we use empty properties as placeholders which child projects > or sub-modules can override. For example: maven-surefire-plugin `argLine`. > This prevents other IDE errors for missing properties when editing the POM. > -- This message was sent by Atlassian Jira (v8.20.10#820010)