Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ARCHETYPE-584] fix indentation in root pom.xml #35

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

newur
Copy link

@newur newur commented Jan 5, 2020

Problem: linebreaks + indentions (whitespaces) are read as actual document nodes. This causes problems in combination with

tr.setOutputProperty( OutputKeys.INDENT, "yes" );
tr.setOutputProperty( "{http://xml.apache.org/xslt}indent-amount", "2" );

Removed the .normalizeWhitespace() in tests, because this shadowed the actual bug. Also split one test into multiple tests. Test content remains the same.

Had to add the maven-4.0.0.xsd, not sure if this is desired.

asfgit pushed a commit that referenced this pull request Feb 16, 2020
asfgit pushed a commit that referenced this pull request Feb 16, 2020
asfgit pushed a commit that referenced this pull request Feb 16, 2020
asfgit pushed a commit that referenced this pull request Feb 16, 2020
@softdays
Copy link

Any chance to get this PR merged?

asfgit pushed a commit that referenced this pull request Mar 8, 2020

out = new StringWriter();
StringWriter out = new StringWriter();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this could be a field that doesn't need to be initialized in each method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to setup method.

@@ -61,6 +61,17 @@
public class ArchetypeTest
extends PlexusTestCase
{
private static final String XML_VERSION_1_0 =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

splitting out these constants makes the tests harder for me to read. I prefer having all the expected content directly in each method, even at the expense of some duplication.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny how different people read code. I could barley make any sense out of the initial version. Is revert in the new commit.

@newur
Copy link
Author

newur commented May 11, 2020

Any progress on this PR?


private OldArchetype archetype;

private StringWriter out;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initialize this here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping

Copy link
Author

@newur newur Jun 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is initialized in the setup method. If I init it here it would be done twice. If I remove it from the setup the tests would share state.

Or do I miss something here?

Btw if any maintainer really wants it to be changed, please fell free to do so. Whatever works best, I am fine with it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're missing something. Tests do not share instance variables. Every test is run with a new object.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


StringWriter out = new StringWriter();
out = new StringWriter();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to initialize this in the test


StringWriter out = new StringWriter();
out = new StringWriter();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to initialize this in the test


StringWriter out = new StringWriter();
out = new StringWriter();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to initialize this in the test


StringWriter out = new StringWriter();
out = new StringWriter();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to initialize this in the test


StringWriter out = new StringWriter();
out = new StringWriter();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to initialize this in the test


StringWriter out = new StringWriter();
out = new StringWriter();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to initialize this in the test

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutly right. Fixed all occurances.

@@ -453,5 +489,6 @@ protected void setUp()
{
super.setUp();
archetype = (OldArchetype) lookup( OldArchetype.ROLE );
out = new StringWriter();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setUp method usually goes near the top

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the method where it was before my patch. I think that keeps reviewing changes easier.
While I personally also prefer it at the top, there is another class which has it after the test, so I assume this is somehow an intended style.

@newur
Copy link
Author

newur commented May 12, 2020

Updated the branch

@hboutemy
Copy link
Member

hboutemy commented Jun 5, 2020

@elharo is this ok now to merge, or do you think something additional is required?

Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one nit remaining but atm I don't see anything blocking


private OldArchetype archetype;

private StringWriter out;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping

@hboutemy
Copy link
Member

hboutemy commented Jun 8, 2020

Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IT failures look real. I'm guessing that the golden data needs to be updated to match the output after this PR:

[ERROR] The following builds failed:
[ERROR] * ARCHETYPE-241_filter-directory/pom.xml
[ERROR] * ARCHETYPE-536_groovy-grape/pom.xml
[ERROR] * roundtrip-multi/pom.xml
[ERROR] * build-and-run-its/pom.xml

@elharo elharo changed the title ARCHETYPE-584 fix indention in root pom.xml [ARCHETYPE-584] fix indentation in root pom.xml Jul 14, 2020
@jorgheymans
Copy link

IT failures look real. I'm guessing that the golden data needs to be updated to match the output after this PR:

How does one update the golden data then ? This PR has gone stale but seems really only this last hurdle is missing.

@newur
Copy link
Author

newur commented Jul 3, 2021

Wow, this branch/bug is still around. I totally forgot about it.

After playing around with the integration tests a bit, one problem was to load the .xsd from the packaged .jar (which works differently from reading from a single file). Solving the loading from the jar seems to fix the ITs.

Let's see what comes up next or if this long journey reaches its happy end. :)

@newur newur requested a review from elharo July 3, 2021 07:32
@@ -79,6 +83,13 @@ public static boolean addNewModule( String artifactId, Reader fileReader, Writer
dbf.setXIncludeAware( false );
dbf.setExpandEntityReferences( false );

InputStream inputStream = PomUtils.class.getClassLoader().getResourceAsStream( "maven-4.0.0.xsd" );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of loading this schema?

Copy link
Author

@newur newur Jul 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my minimal, reproducible example here https://issues.apache.org/jira/browse/ARCHETYPE-584?focusedCommentId=17008264&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17008264

I investigated this 1.5 years ago and cannot remember the details why it only worked this way. However, I am pretty sure that I did not dive into the implementation details of DocumentBuilderFactory, which is fed with the schema, so not sure if I would have been able to explain it very deep back then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is that you don't need the schema to fix this bug. In fact, you probably only need setIgnoringElementContentWhitespace though setNamespaceAware( true ) is always a good idea.

Copy link
Author

@newur newur Jul 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the example I provided. When you run it, you will see that without the schema the output is not as expected.

@@ -0,0 +1,2246 @@
<?xml version="1.0"?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strange that this has to be copied into this project. I'd expect it to be loaded from maven core, if at all.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to point me to location of the xsd in maven core or any other way to load it and I happily update the PR.

@newur newur requested a review from elharo August 2, 2021 23:15
@newur
Copy link
Author

newur commented Aug 2, 2021

I committed a new attempt to get this merged. Since I do not understand which solution is acceptable, I made an unclean commit (code in comments, no proper exception handling).
Would be nice to have some feedback, if this solution has any chance to get accepted before I clean it up.

@kwin
Copy link
Member

kwin commented Jan 30, 2024

I think this is superseded by #128

@newur
Copy link
Author

newur commented Feb 4, 2024

I think so too and would love to try it out @kwin. Unfortunately maven-archetype-plugin version 3.3.0 is not released, yet.

Any estimated time when the release will happen? Or any way to test this, besides building the plugin locally?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants