[jira] [Comment Edited] (ARCHETYPE-584) Resulting root pom.xml from archetype generation has additional newlines with JDK11

2021-08-02 Thread Ruwen Reddig (Jira)


[ 
https://issues.apache.org/jira/browse/ARCHETYPE-584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17391819#comment-17391819
 ] 

Ruwen Reddig edited comment on ARCHETYPE-584 at 8/2/21, 10:43 PM:
--

I committed a new solution attempt. For reasons that are unclear for me, I 
cannot see the maven CI pipeline anymore at 
[https://ci-builds.apache.org/job/Maven/job/maven-box/]

I assume that the change will break some other random part/test, but without 
seeing the result it is hard to tell.

As reference - this is the stackoverflow trail so far:
 * 
[https://stackoverflow.com/questions/12669686/how-to-remove-extra-empty-lines-from-xml-file]
 * 
[https://stackoverflow.com/questions/14255064/removechild-how-to-remove-indent-too?noredirect=1=1]
 * 
[https://stackoverflow.com/questions/978810/how-to-strip-whitespace-only-text-nodes-from-a-dom-before-serialization]


was (Author: newur):
I committed a new solution attempt. For reasons that are unclear for me, I 
cannot see the maven CI pipeline anymore at 
[https://ci-builds.apache.org/job/Maven/job/maven-box/]

I assume that the change will break some other random part/test, but without 
seeing the result it is hard to tell.

> Resulting root pom.xml from archetype generation has additional newlines with 
> JDK11
> ---
>
> Key: ARCHETYPE-584
> URL: https://issues.apache.org/jira/browse/ARCHETYPE-584
> Project: Maven Archetype
>  Issue Type: Bug
>  Components: Archetypes
>Affects Versions: 3.1.1, 3.1.2
>Reporter: Andre Prata
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> This issue does not apply to version 3.1.0, it was introduced in version 
> 3.1.1.
>  
> In our project, we have the default configuration of the root pom.xml that 
> contains lines such as this:
> {code:java}
> 
> 11
> Greenwich.RELEASE
> 
> {code}
> These lines are still in good shape when added to the jar artifact. However, 
> upon generating the project from the archetype, we get the following (note 
> also the whitespace on the blank lines hinting at some indentation attempts, 
> not just the unexpected line breaks)
> {code:java}
> 
>   
>   
>   11
>   
>   
>   Greenwich.RELEASE
>   
> 
>   
> {code}
> This issue does *not* occur in in child module pom.xml files.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (ARCHETYPE-584) Resulting root pom.xml from archetype generation has additional newlines with JDK11

2021-08-02 Thread Ruwen Reddig (Jira)


[ 
https://issues.apache.org/jira/browse/ARCHETYPE-584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17391819#comment-17391819
 ] 

Ruwen Reddig commented on ARCHETYPE-584:


I committed a new solution attempt. For reasons that are unclear for me, I 
cannot see the maven CI pipeline anymore at 
[https://ci-builds.apache.org/job/Maven/job/maven-box/]

I assume that the change will break some other random part/test, but without 
seeing the result it is hard to tell.

> Resulting root pom.xml from archetype generation has additional newlines with 
> JDK11
> ---
>
> Key: ARCHETYPE-584
> URL: https://issues.apache.org/jira/browse/ARCHETYPE-584
> Project: Maven Archetype
>  Issue Type: Bug
>  Components: Archetypes
>Affects Versions: 3.1.1, 3.1.2
>Reporter: Andre Prata
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> This issue does not apply to version 3.1.0, it was introduced in version 
> 3.1.1.
>  
> In our project, we have the default configuration of the root pom.xml that 
> contains lines such as this:
> {code:java}
> 
> 11
> Greenwich.RELEASE
> 
> {code}
> These lines are still in good shape when added to the jar artifact. However, 
> upon generating the project from the archetype, we get the following (note 
> also the whitespace on the blank lines hinting at some indentation attempts, 
> not just the unexpected line breaks)
> {code:java}
> 
>   
>   
>   11
>   
>   
>   Greenwich.RELEASE
>   
> 
>   
> {code}
> This issue does *not* occur in in child module pom.xml files.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Comment Edited] (ARCHETYPE-584) Resulting root pom.xml from archetype generation has additional newlines with JDK11

2021-07-04 Thread Ruwen Reddig (Jira)


[ 
https://issues.apache.org/jira/browse/ARCHETYPE-584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17374207#comment-17374207
 ] 

Ruwen Reddig edited comment on ARCHETYPE-584 at 7/4/21, 6:54 AM:
-

[~elharo] I googled the problem a bit and [this stackoverflow 
answer|https://stackoverflow.com/a/58481951] provides an explanation that makes 
sense and also fits the expected timeline (change introduced in JDK 9).

 

The change in {{ToStream.java}} that is mentioned on SO, can be found here: 
[https://github.com/openjdk/jdk/commit/1619ba484211c6f1b93fb13e22b507faa5e9d41b]


was (Author: newur):
[~elharo] I googled the problem a bit and [this stackoverflow 
answer|https://stackoverflow.com/a/58481951] provides an explanation that makes 
sense and also fits the expected timeline (change introduced in JDK 9).

 

The change in `ToStream.java` that is mentioned on SO, can be found here: 
[https://github.com/openjdk/jdk/commit/1619ba484211c6f1b93fb13e22b507faa5e9d41b]

> Resulting root pom.xml from archetype generation has additional newlines with 
> JDK11
> ---
>
> Key: ARCHETYPE-584
> URL: https://issues.apache.org/jira/browse/ARCHETYPE-584
> Project: Maven Archetype
>  Issue Type: Bug
>  Components: Archetypes
>Affects Versions: 3.1.1, 3.1.2
>Reporter: Andre Prata
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> This issue does not apply to version 3.1.0, it was introduced in version 
> 3.1.1.
>  
> In our project, we have the default configuration of the root pom.xml that 
> contains lines such as this:
> {code:java}
> 
> 11
> Greenwich.RELEASE
> 
> {code}
> These lines are still in good shape when added to the jar artifact. However, 
> upon generating the project from the archetype, we get the following (note 
> also the whitespace on the blank lines hinting at some indentation attempts, 
> not just the unexpected line breaks)
> {code:java}
> 
>   
>   
>   11
>   
>   
>   Greenwich.RELEASE
>   
> 
>   
> {code}
> This issue does *not* occur in in child module pom.xml files.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Comment Edited] (ARCHETYPE-584) Resulting root pom.xml from archetype generation has additional newlines with JDK11

2021-07-04 Thread Ruwen Reddig (Jira)


[ 
https://issues.apache.org/jira/browse/ARCHETYPE-584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17374207#comment-17374207
 ] 

Ruwen Reddig edited comment on ARCHETYPE-584 at 7/4/21, 6:52 AM:
-

[~elharo] I googled the problem a bit and [this stackoverflow 
answer|https://stackoverflow.com/a/58481951] provides an explanation that makes 
sense and also fits the expected timeline (change introduced in JDK 9).

 

The change in `ToStream.java` that is mentioned on SO, can be found here: 
[https://github.com/openjdk/jdk/commit/1619ba484211c6f1b93fb13e22b507faa5e9d41b]


was (Author: newur):
[~elharo] googled the problem a bit and [this stackoverflow 
answer|https://stackoverflow.com/a/58481951] provides an explanation that makes 
sense and also fits the expected timeline (change introduced in JDK 9).

 

The change in `ToStream.java` that is mentioned on SO, can be found here: 
https://github.com/openjdk/jdk/commit/1619ba484211c6f1b93fb13e22b507faa5e9d41b

> Resulting root pom.xml from archetype generation has additional newlines with 
> JDK11
> ---
>
> Key: ARCHETYPE-584
> URL: https://issues.apache.org/jira/browse/ARCHETYPE-584
> Project: Maven Archetype
>  Issue Type: Bug
>  Components: Archetypes
>Affects Versions: 3.1.1, 3.1.2
>Reporter: Andre Prata
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> This issue does not apply to version 3.1.0, it was introduced in version 
> 3.1.1.
>  
> In our project, we have the default configuration of the root pom.xml that 
> contains lines such as this:
> {code:java}
> 
> 11
> Greenwich.RELEASE
> 
> {code}
> These lines are still in good shape when added to the jar artifact. However, 
> upon generating the project from the archetype, we get the following (note 
> also the whitespace on the blank lines hinting at some indentation attempts, 
> not just the unexpected line breaks)
> {code:java}
> 
>   
>   
>   11
>   
>   
>   Greenwich.RELEASE
>   
> 
>   
> {code}
> This issue does *not* occur in in child module pom.xml files.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (ARCHETYPE-584) Resulting root pom.xml from archetype generation has additional newlines with JDK11

2021-07-04 Thread Ruwen Reddig (Jira)


[ 
https://issues.apache.org/jira/browse/ARCHETYPE-584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17374207#comment-17374207
 ] 

Ruwen Reddig commented on ARCHETYPE-584:


[~elharo] googled the problem a bit and [this stackoverflow 
answer|https://stackoverflow.com/a/58481951] provides an explanation that makes 
sense and also fits the expected timeline (change introduced in JDK 9).

 

The change in `ToStream.java` that is mentioned on SO, can be found here: 
https://github.com/openjdk/jdk/commit/1619ba484211c6f1b93fb13e22b507faa5e9d41b

> Resulting root pom.xml from archetype generation has additional newlines with 
> JDK11
> ---
>
> Key: ARCHETYPE-584
> URL: https://issues.apache.org/jira/browse/ARCHETYPE-584
> Project: Maven Archetype
>  Issue Type: Bug
>  Components: Archetypes
>Affects Versions: 3.1.1, 3.1.2
>Reporter: Andre Prata
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> This issue does not apply to version 3.1.0, it was introduced in version 
> 3.1.1.
>  
> In our project, we have the default configuration of the root pom.xml that 
> contains lines such as this:
> {code:java}
> 
> 11
> Greenwich.RELEASE
> 
> {code}
> These lines are still in good shape when added to the jar artifact. However, 
> upon generating the project from the archetype, we get the following (note 
> also the whitespace on the blank lines hinting at some indentation attempts, 
> not just the unexpected line breaks)
> {code:java}
> 
>   
>   
>   11
>   
>   
>   Greenwich.RELEASE
>   
> 
>   
> {code}
> This issue does *not* occur in in child module pom.xml files.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Comment Edited] (ARCHETYPE-584) Resulting root pom.xml from archetype generation has additional newlines with JDK11

2021-07-03 Thread Ruwen Reddig (Jira)


[ 
https://issues.apache.org/jira/browse/ARCHETYPE-584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17374124#comment-17374124
 ] 

Ruwen Reddig edited comment on ARCHETYPE-584 at 7/3/21, 7:45 PM:
-

[~elharo] this depends on your definition of 'only occur with JDK 11'. I tested 
it with Java 11 and 16, and both show the described problem. In contrast to JDK 
8, which does not show any problems.

 

But don't take my word for it. I posted a self contained 
[example|https://issues.apache.org/jira/browse/ARCHETYPE-584?focusedCommentId=17008264=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17008264]
 here in the comments. So you can do further checks easily.


was (Author: newur):
[~elharo] this depends on your definition of 'only occur with JDK 11'. I tested 
it with Java 11 and 16, and both show the described problem. In contrast to JDK 
8, which does not show any problems.

 

But don't take my word for it. I posted example here in the comments. So you 
can do further checks easily.

> Resulting root pom.xml from archetype generation has additional newlines with 
> JDK11
> ---
>
> Key: ARCHETYPE-584
> URL: https://issues.apache.org/jira/browse/ARCHETYPE-584
> Project: Maven Archetype
>  Issue Type: Bug
>  Components: Archetypes
>Affects Versions: 3.1.1, 3.1.2
>Reporter: Andre Prata
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> This issue does not apply to version 3.1.0, it was introduced in version 
> 3.1.1.
>  
> In our project, we have the default configuration of the root pom.xml that 
> contains lines such as this:
> {code:java}
> 
> 11
> Greenwich.RELEASE
> 
> {code}
> These lines are still in good shape when added to the jar artifact. However, 
> upon generating the project from the archetype, we get the following (note 
> also the whitespace on the blank lines hinting at some indentation attempts, 
> not just the unexpected line breaks)
> {code:java}
> 
>   
>   
>   11
>   
>   
>   Greenwich.RELEASE
>   
> 
>   
> {code}
> This issue does *not* occur in in child module pom.xml files.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (ARCHETYPE-584) Resulting root pom.xml from archetype generation has additional newlines with JDK11

2021-07-03 Thread Ruwen Reddig (Jira)


[ 
https://issues.apache.org/jira/browse/ARCHETYPE-584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17374124#comment-17374124
 ] 

Ruwen Reddig commented on ARCHETYPE-584:


[~elharo] this depends on your definition of 'only occur with JDK 11'. I tested 
it with Java 11 and 16, and both show the described problem. In contrast to JDK 
8, which does not show any problems.

 

But don't take my word for it. I posted example here in the comments. So you 
can do further checks easily.

> Resulting root pom.xml from archetype generation has additional newlines with 
> JDK11
> ---
>
> Key: ARCHETYPE-584
> URL: https://issues.apache.org/jira/browse/ARCHETYPE-584
> Project: Maven Archetype
>  Issue Type: Bug
>  Components: Archetypes
>Affects Versions: 3.1.1, 3.1.2
>Reporter: Andre Prata
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> This issue does not apply to version 3.1.0, it was introduced in version 
> 3.1.1.
>  
> In our project, we have the default configuration of the root pom.xml that 
> contains lines such as this:
> {code:java}
> 
> 11
> Greenwich.RELEASE
> 
> {code}
> These lines are still in good shape when added to the jar artifact. However, 
> upon generating the project from the archetype, we get the following (note 
> also the whitespace on the blank lines hinting at some indentation attempts, 
> not just the unexpected line breaks)
> {code:java}
> 
>   
>   
>   11
>   
>   
>   Greenwich.RELEASE
>   
> 
>   
> {code}
> This issue does *not* occur in in child module pom.xml files.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (ARCHETYPE-584) Resulting root pom.xml from archetype generation has additional newlines with JDK11

2020-05-11 Thread Ruwen Reddig (Jira)


[ 
https://issues.apache.org/jira/browse/ARCHETYPE-584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17104951#comment-17104951
 ] 

Ruwen Reddig commented on ARCHETYPE-584:


Hello, since this issue just passed its 6 month, I give it a little bump.
Hope we can get this fixed soon. 

> Resulting root pom.xml from archetype generation has additional newlines with 
> JDK11
> ---
>
> Key: ARCHETYPE-584
> URL: https://issues.apache.org/jira/browse/ARCHETYPE-584
> Project: Maven Archetype
>  Issue Type: Bug
>  Components: Archetypes
>Affects Versions: 3.1.1, 3.1.2
>Reporter: Andre Prata
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> This issue does not apply to version 3.1.0, it was introduced in version 
> 3.1.1.
>  
> In our project, we have the default configuration of the root pom.xml that 
> contains lines such as this:
> {code:java}
> 
> 11
> Greenwich.RELEASE
> 
> {code}
> These lines are still in good shape when added to the jar artifact. However, 
> upon generating the project from the archetype, we get the following (note 
> also the whitespace on the blank lines hinting at some indentation attempts, 
> not just the unexpected line breaks)
> {code:java}
> 
>   
>   
>   11
>   
>   
>   Greenwich.RELEASE
>   
> 
>   
> {code}
> This issue does *not* occur in in child module pom.xml files.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Comment Edited] (ARCHETYPE-584) Resulting root pom.xml from archetype generation has bad indentation

2020-01-04 Thread Ruwen Reddig (Jira)


[ 
https://issues.apache.org/jira/browse/ARCHETYPE-584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17008264#comment-17008264
 ] 

Ruwen Reddig edited comment on ARCHETYPE-584 at 1/5/20 7:35 AM:


Stumpled over the same problem yesterday. Please have a look at my PR. I added 
some explanation in the github comment.

Here is a minimal, reproducible example of the problem + fix
{code:java}
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.net.URI;

public class ReadWriteXmlTest {

public static void main(String[] args) throws Exception {
String dummyPom =
"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\;>\n" +
"  4.0.0\n" +
"  pom\n" +
"";

InputSource inputSource = new InputSource();
inputSource.setCharacterStream( new StringReader(dummyPom) );

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

// uncomment the following 3 lines to see the fix
//dbf.setIgnoringElementContentWhitespace(true);
//dbf.setNamespaceAware(true);
//dbf.setSchema( getSchema() );

Document document = dbf.newDocumentBuilder().parse( inputSource );

Transformer tr = TransformerFactory.newInstance().newTransformer();
tr.setOutputProperty( OutputKeys.INDENT, "yes" );

// comment this line and output still looks okay?!!
tr.setOutputProperty( "{http://xml.apache.org/xslt}indent-amount;, "2" 
);

StringWriter fileWriter = new StringWriter();
tr.transform( new DOMSource( document ), new StreamResult( fileWriter ) 
);

System.out.println(fileWriter.toString());
}

private static Schema getSchema() throws SAXException, 
MalformedURLException {
URI uri = URI.create("https://maven.apache.org/xsd/maven-4.0.0.xsd;);
return SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
.newSchema(uri.toURL());
}

}
{code}


was (Author: newur):
Stumpled over the same problem yesterday. Please have a look at my PR. I added 
some explanation in the github comment.

Here is a minimal, reproducible example of the problem + fix
{code:java}
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.net.URI;

public class ReadWriteXmlTest {

public static void main(String[] args) throws Exception {
String dummyPom =
"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\;>\n" +
"  4.0.0\n" +
"  pom\n" +
"";

InputSource inputSource = new InputSource();
inputSource.setCharacterStream( new StringReader(dummyPom) );

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

// uncomment the following line to see the fix
//dbf.setIgnoringElementContentWhitespace(true);
dbf.setNamespaceAware(true);
dbf.setSchema( getSchema() );

Document document = dbf.newDocumentBuilder().parse( inputSource );

Transformer tr = TransformerFactory.newInstance().newTransformer();
tr.setOutputProperty( OutputKeys.INDENT, "yes" );

// comment this line and output still looks okay?!!
tr.setOutputProperty( "{http://xml.apache.org/xslt}indent-amount;, "2" 
);

StringWriter fileWriter = new StringWriter();
tr.transform( new DOMSource( document ), new StreamResult( fileWriter ) 
);

System.out.println(fileWriter.toString());

[jira] [Comment Edited] (ARCHETYPE-584) Resulting root pom.xml from archetype generation has bad indentation

2020-01-04 Thread Ruwen Reddig (Jira)


[ 
https://issues.apache.org/jira/browse/ARCHETYPE-584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17008264#comment-17008264
 ] 

Ruwen Reddig edited comment on ARCHETYPE-584 at 1/5/20 7:35 AM:


Stumpled over the same problem yesterday. Please have a look at my PR. I added 
some explanation in the github comment.

Here is a minimal, reproducible example of the problem + fix
{code:java}
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.net.URI;

public class ReadWriteXmlTest {

public static void main(String[] args) throws Exception {
String dummyPom =
"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\;>\n" +
"  4.0.0\n" +
"  pom\n" +
"";

InputSource inputSource = new InputSource();
inputSource.setCharacterStream( new StringReader(dummyPom) );

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

// uncomment the following line to see the fix
//dbf.setIgnoringElementContentWhitespace(true);
dbf.setNamespaceAware(true);
dbf.setSchema( getSchema() );

Document document = dbf.newDocumentBuilder().parse( inputSource );

Transformer tr = TransformerFactory.newInstance().newTransformer();
tr.setOutputProperty( OutputKeys.INDENT, "yes" );

// comment this line and output still looks okay?!!
tr.setOutputProperty( "{http://xml.apache.org/xslt}indent-amount;, "2" 
);

StringWriter fileWriter = new StringWriter();
tr.transform( new DOMSource( document ), new StreamResult( fileWriter ) 
);

System.out.println(fileWriter.toString());
}

private static Schema getSchema() throws SAXException, 
MalformedURLException {
URI uri = URI.create("https://maven.apache.org/xsd/maven-4.0.0.xsd;);
return SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
.newSchema(uri.toURL());
}

}
{code}


was (Author: newur):
Stumpled over the same problem yesterday. Please have a look at my PR. I added 
some explanation in the github comment.

Here is a minimal, reproducible example of the problem + fix
{code:java}
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.net.URI;

public class ReadWriteXmlTest {

public static void main(String[] args) throws Exception {
String dummyPom =
"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\;>\n" +
"  4.0.0\n" +
"  pom\n" +
"";

InputSource inputSource = new InputSource();
inputSource.setCharacterStream( new StringReader(dummyPom) );

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

// comment any of the following 3 lines to see the problem
//dbf.setIgnoringElementContentWhitespace(true);
dbf.setNamespaceAware(true);
dbf.setSchema( getSchema() );

Document document = dbf.newDocumentBuilder().parse( inputSource );

Transformer tr = TransformerFactory.newInstance().newTransformer();
tr.setOutputProperty( OutputKeys.INDENT, "yes" );

// comment this line and output still looks okay?!!
tr.setOutputProperty( "{http://xml.apache.org/xslt}indent-amount;, "2" 
);

StringWriter fileWriter = new StringWriter();
tr.transform( new DOMSource( document ), new StreamResult( fileWriter ) 
);


[jira] [Comment Edited] (ARCHETYPE-584) Resulting root pom.xml from archetype generation has bad indentation

2020-01-04 Thread Ruwen Reddig (Jira)


[ 
https://issues.apache.org/jira/browse/ARCHETYPE-584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17008264#comment-17008264
 ] 

Ruwen Reddig edited comment on ARCHETYPE-584 at 1/5/20 7:34 AM:


Stumpled over the same problem yesterday. Please have a look at my PR. I added 
some explanation in the github comment.

Here is a minimal, reproducible example of the problem + fix
{code:java}
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.net.URI;

public class ReadWriteXmlTest {

public static void main(String[] args) throws Exception {
String dummyPom =
"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\;>\n" +
"  4.0.0\n" +
"  pom\n" +
"";

InputSource inputSource = new InputSource();
inputSource.setCharacterStream( new StringReader(dummyPom) );

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

// comment any of the following 3 lines to see the problem
//dbf.setIgnoringElementContentWhitespace(true);
dbf.setNamespaceAware(true);
dbf.setSchema( getSchema() );

Document document = dbf.newDocumentBuilder().parse( inputSource );

Transformer tr = TransformerFactory.newInstance().newTransformer();
tr.setOutputProperty( OutputKeys.INDENT, "yes" );

// comment this line and output still looks okay?!!
tr.setOutputProperty( "{http://xml.apache.org/xslt}indent-amount;, "2" 
);

StringWriter fileWriter = new StringWriter();
tr.transform( new DOMSource( document ), new StreamResult( fileWriter ) 
);

System.out.println(fileWriter.toString());
}

private static Schema getSchema() throws SAXException, 
MalformedURLException {
URI uri = URI.create("https://maven.apache.org/xsd/maven-4.0.0.xsd;);
return SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
.newSchema(uri.toURL());
}

}
{code}


was (Author: newur):
Stumpled over the same problem yesterday. Please have a look at my PR. I added 
some explanation in the github comment.

Here is a minimal, reproducible example of the problem + fix
{code:java}
public static void main(String[] args) throws Exception {
String dummyPom =
"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\;>\n" +
"  4.0.0\n" +
"  pom\n" +
"";

InputSource inputSource = new InputSource();
inputSource.setCharacterStream( new StringReader(dummyPom) );

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

// uncomment the following lines to see the fix(?)
//dbf.setIgnoringElementContentWhitespace(true);
dbf.setNamespaceAware(true);
dbf.setSchema( getSchema() );

Document document = dbf.newDocumentBuilder().parse( inputSource );

Transformer tr = TransformerFactory.newInstance().newTransformer();
tr.setOutputProperty( OutputKeys.INDENT, "yes" );

// comment this line and output still looks okay?!!
tr.setOutputProperty( "{http://xml.apache.org/xslt}indent-amount;, "2" );

StringWriter fileWriter = new StringWriter();
tr.transform( new DOMSource( document ), new StreamResult( fileWriter ) );

System.out.println(fileWriter.toString());
}

private static Schema getSchema() throws SAXException, MalformedURLException {
URI uri = URI.create("https://maven.apache.org/xsd/maven-4.0.0.xsd;);
return SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
.newSchema(uri.toURL());
}

{code}

> Resulting root pom.xml from archetype generation has bad indentation
> 
>
> Key: ARCHETYPE-584
> URL: https://issues.apache.org/jira/browse/ARCHETYPE-584
> Project: Maven Archetype
>  Issue Type: Bug
>  Components: Archetypes
>Affects Versions: 3.1.1, 3.1.2
>Reporter: Andre Prata
>

[jira] [Commented] (ARCHETYPE-584) Resulting root pom.xml from archetype generation has bad indentation

2020-01-04 Thread Ruwen Reddig (Jira)


[ 
https://issues.apache.org/jira/browse/ARCHETYPE-584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17008264#comment-17008264
 ] 

Ruwen Reddig commented on ARCHETYPE-584:


Stumpled over the same problem yesterday. Please have a look at my PR. I added 
some explanation in the github comment.

Here is a minimal, reproducible example of the problem + fix
{code:java}
public static void main(String[] args) throws Exception {
String dummyPom =
"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\;>\n" +
"  4.0.0\n" +
"  pom\n" +
"";

InputSource inputSource = new InputSource();
inputSource.setCharacterStream( new StringReader(dummyPom) );

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

// uncomment the following lines to see the fix(?)
//dbf.setIgnoringElementContentWhitespace(true);
dbf.setNamespaceAware(true);
dbf.setSchema( getSchema() );

Document document = dbf.newDocumentBuilder().parse( inputSource );

Transformer tr = TransformerFactory.newInstance().newTransformer();
tr.setOutputProperty( OutputKeys.INDENT, "yes" );

// comment this line and output still looks okay?!!
tr.setOutputProperty( "{http://xml.apache.org/xslt}indent-amount;, "2" );

StringWriter fileWriter = new StringWriter();
tr.transform( new DOMSource( document ), new StreamResult( fileWriter ) );

System.out.println(fileWriter.toString());
}

private static Schema getSchema() throws SAXException, MalformedURLException {
URI uri = URI.create("https://maven.apache.org/xsd/maven-4.0.0.xsd;);
return SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
.newSchema(uri.toURL());
}

{code}

> Resulting root pom.xml from archetype generation has bad indentation
> 
>
> Key: ARCHETYPE-584
> URL: https://issues.apache.org/jira/browse/ARCHETYPE-584
> Project: Maven Archetype
>  Issue Type: Bug
>  Components: Archetypes
>Affects Versions: 3.1.1, 3.1.2
>Reporter: Andre Prata
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> This issue does not apply to version 3.1.0, it was introduced in version 
> 3.1.0.
>  
> In our project, we have the default configuration of the root pom.xml that 
> contains lines such as this:
> {code:java}
> 
> 11
> Greenwich.RELEASE
> 
> {code}
> These lines are still in good shape when added to the jar artifact. However, 
> upon generating the project from the archetype, we get the following (note 
> also the whitespace on the blank lines hinting at some indentation attempts, 
> not just the unexpected line breaks)
> {code:java}
> 
>   
>   
>   11
>   
>   
>   Greenwich.RELEASE
>   
> 
>   
> {code}
> This issue does *not* occur in in child module pom.xml files.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)