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

Show line number #45

Closed
php-coder opened this issue Feb 15, 2017 · 11 comments
Closed

Show line number #45

php-coder opened this issue Feb 15, 2017 · 11 comments

Comments

@php-coder
Copy link

I'd like to see on which line I have an error. At present, plugin shows only a message:

$ mvn sortpom:verify -Dsort.verifyFail=stop
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building My Stamps 0.3-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- sortpom-maven-plugin:2.5.0:verify (default-cli) @ mystamps ---
[INFO] Verifying file /Users/coder/git/mystamps.git/pom.xml
[ERROR] The xml element <groupId>com.github.heneke.thymeleaf</groupId> should be placed before <groupId>javax.validation</groupId>
[ERROR] The file /Users/coder/git/mystamps.git/pom.xml is not sorted
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
@Ekryd
Copy link
Owner

Ekryd commented Feb 16, 2017

I use a library called Jdom to parse the XML, and I think that this library doesn't support the concept of line numbers. I look into this further, but the chances are slim.

@Ekryd
Copy link
Owner

Ekryd commented Feb 17, 2017

The plugin works like this for verification:

  1. The pom.xml is parsed by the JDOM library into an element structure. That library does not store the line numbers for the elements.
  2. The plugin sorts the element structure
  3. The plugin traverses both the original element structure and the sorted element structure. For each pair of elements the plugin checks if the elements and the content are the same.
  4. When the two elements differ, the plugin writes an error message.

The problem is that the element structure does not have access to the line number. I could try to locate the elements in the original file by using a line by line string comparison, but I cannot be certain that I get a unique match or even that I get a match at all (if element start or end is on separate lines).

Sometimes the line number indication would point to the wrong line and sometimes it would be missing.
Would it help you to get a line number that you could not trust?

@php-coder
Copy link
Author

I'm surprised that library didn't have information about line numbers. Is it something JDOM-specific or all the libraries have the same behavior?

@Ekryd
Copy link
Owner

Ekryd commented Feb 18, 2017

It is JDOM specific. It is an old library (think Java 1.4) and I don't have the time to change xml parsing library. Some of the plugin functionality is now directly dependent on that version of that library.
Not very good design and I can only say that I would have done differently today than in 2009 :-/

@Ekryd Ekryd closed this as completed Feb 18, 2017
@php-coder
Copy link
Author

Why not keep this issue open to be able to fix it someday in the next major release?

@Ekryd
Copy link
Owner

Ekryd commented Feb 19, 2017

Sorry mate, it won't happen. I don't have time to rewrite the plugin from scratch. It is no idea to keep issues open if I can't fix them within reasonable time.

@khmarbaise
Copy link

But others could see what can be done and might offer a pull request...

@Ekryd
Copy link
Owner

Ekryd commented Feb 19, 2017

To rewrite the plugin from scratch :-D
I'm not even sure that I would like that (it's my baby!!).

How about if I create a wiki page that collects issues (epics) that can only be done sometime in the future?

@khmarbaise
Copy link

khmarbaise commented Feb 19, 2017

Sorry to say, but if you don't like it than do not make it open source ;-( But of course a wiki pages which collects issues like this would be another good idea...Or just assign the issues to an appropriate milestone like 3.0 ?

@php-coder
Copy link
Author

Sorry to say, but if you don't like it than do not make it open source ;-(

@Ekryd did a good job by creating this plugin and it's ok that he doesn't want to accept some PRs because of some reason. Actually it's good that he said it as-is right now. It just means that if someone wants to implement it, he/she should fork this project instead of creating a PR here.

@khmarbaise
Copy link

Of course a fork is also a reasonable solution.

@Ekryd Ekryd added the wontfix label Feb 27, 2017
@Ekryd Ekryd added this to the Future enhancement milestone Feb 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants