Comments (25)
Ok, I'll try it this weekend. Thanks!
from sortpom.
Released version 2.7.0 with the new functionality. Will update the wiki documentation soon.
from sortpom.
This sounds like a good idea. Could you give me an example of how you would like the output to look like?
from sortpom.
I'm suggesting something like this (inspired by the CheckStyle/PMD reports):
<?xml version="1.0" encoding="UTF-8"?>
<sortpom version="2.5.0">
<violation line="19">
The xml element <groupId>com.github.heneke.thymeleaf</groupId> should be placed before <groupId>javax.validation</groupId>
</violation>
</sortpom>
If it's possible the column
and rule
attributes could be added too.
from sortpom.
There are (at least) two ways to do this.
Do you mean that you run the plugin as normal but specify that the output should be sent to a external file or do you want the run the plugin under the reporting section of the pom.xml?
See example of the two different ways at https://maven.apache.org/plugins/maven-pmd-plugin/usage.html
from sortpom.
Do you mean that you run the plugin as normal but specify that the output should be sent to a external file or do you want the run the plugin under the reporting section of the pom.xml?
The first option. I'd like to have output on the console as well as in the file (that later could be parsed).
from sortpom.
Great! I will make some changes and we will see if you like it. Disclaimer: this is done on my spare time, so I can't promise a specific delivery date.
from sortpom.
Normally if the plugin is configured in the pom-file or run with
mvn sortpom:verify -Dsort.verifyFail="Warn"
The output to the console would be
[INFO] --- sortpom-maven-plugin:2.4.0:verify (default-cli) @ sortpom-parent ---
[INFO] Verifying file /path/pom.xml
[WARNING] The xml element should be placed before
[WARNING] The file /path/pom.xml is not sorted
New way would be be a configuration like
mvn sortpom:verify -Dsort.verifyFail="Warn" -Dsort.outputType="console, file"
-Dsort.outputFile="sortpom-reports/sortpom-result.xml"
The output to the console would be the same and the the output to the file would be
Verifying file /path/pom.xml The xml element <version> should be placed before <packaging> The file /path/pom.xml is not sortedWould this be enough or should the the output be more customised?
from sortpom.
Verifying file /path/pom.xml
The xml element should be placed before
The file /path/pom.xml is not sorted
Would this be enough or should the the output be more customised?
I believe that the first and the last lines aren't so useful because they don't contain actual violations. Could we omit them? Also, this output will be in XML/JSON form or am I missing something here?
from sortpom.
Wtf! My xml example just vanished! This is how it should have looked
The output to the console would be the same and the the output to the file would be
<?xml version="1.0" encoding="UTF-8"?>
<sortpom version="2.6.0">
<information>Verifying file /path/pom.xml</information>
<warning>The xml element <version> should be placed before <packaging></warning>
<warning>The file /path/pom.xml is not sorted</warning>
</sortpom>
from sortpom.
If the following command was run:
mvn sortpom:verify -Dsort.verifyFail="Warn" -Dsort.outputType="console, file"
-Dsort.outputFile="sortpom-reports/sortpom-result.xml"
The console output would be
[INFO] --- sortpom-maven-plugin:2.4.0:verify (default-cli) @ sortpom-parent ---
[INFO] Verifying file /path/pom.xml
[WARNING] The xml element should be placed before
[WARNING] The file /path/pom.xml is not sorted
and the file output (./target/sortpom-reports/sortpom-result.xml) would be
<?xml version="1.0" encoding="UTF-8"?>
<sortpom version="2.6.0">
<file name="c:\path\pom.xml">
<violation goal="verify">The xml element <version> should be placed before <packaging></violation>
</file>
</sortpom>
I would like to keep the file indicator, but is the goal attribute really necessary?
Unfortunately I can only report one violation for the pom.xml.
What would the xml look like when everything is ok, just the sortpom and file tag?
I think that the console output should only be available to the verify goal, thoughts?
The violation entry will be written no matter what the verifyFail option says, right?
from sortpom.
I would like to keep the file indicator, but is the goal attribute really necessary?
Yes, I agree that goal
attribute isn't necessary (at least to me :))
What would the xml look like when everything is ok, just the sortpom and file tag?
I expect that the report file isn't created at all.
The violation entry will be written no matter what the verifyFail option says, right?
Sounds reasonable.
from sortpom.
Good! Then I will start to look at the code and see how this can be realized. I will keep you posted when I have done some progress.
from sortpom.
Added a new branch with the new functionality.
The new parameter would be used like this:
mvn sortpom:verify -Dsort.violationFilename="target/sortpom_reports/violation.xml"
and the output would be like this:
<?xml version="1.0" encoding="UTF-8"?>
<sortpom>
<file filename="/Users/bjorn/Workspace/SortPom/maven-plugin/target/it/violation-file/pom.xml">
<violation>The xml element <modelVersion> should be placed before <name></violation>
</file>
</sortpom>
from sortpom.
I will continue with some more tests.
from sortpom.
Finally I have gotten some time to code properly!
Question:
Should the violation file be overwritten automatically if it already exists? Or should the plugin stop directly? Or stop just when it is about to write to the file?
My thoughts is that the plugin should stop directly, so that an existing violation file cannot give a false impression that the build failed. Or should an old file be deleted if the verification was ok?
from sortpom.
I would expect that file will be overwritten. When there is no violations then report won't have them.
from sortpom.
Overwrite works for me. Just to clarify: If the verify passed and an old violation file exists, will it be deleted or will it be left alone?
from sortpom.
It should be overwritten by empty report:
<?xml version="1.0" encoding="UTF-8"?>
<sortpom>
<file filename="/Users/bjorn/Workspace/SortPom/maven-plugin/target/it/violation-file/pom.xml">
</file>
</sortpom>
from sortpom.
Lets see:
I can think of two scenarios where the violation file will be left by the build.
- Optimized Jenkins build where the target directory is cleaned seldom to improve build speed.
In this case the violation file should be cleared or emptied. - Deployment with some sort release plugin where the same phases run again and again.
In this case the violation file should be kept to indicate that the pom-file caused a violation at some point in the build.
I think that I will solve the problem as I handle the backup file. Write the violation file only if an violation occurred. Overwrite old file if violation occurs, otherwise just leave the disk drive as it is. This will be the easiest to implement/test. Any problems with leftover violation files will have to be solved by the user of the plugin. Would that work for you?
from sortpom.
Hi
I have made an implementation that is on the master branch. Could you please try it out by downloading the code, build it with mvn clean install
, and run it with mvn com.github.ekryd.sortpom:sortpom-maven-plugin:2.6.1-SNAPSHOT:verify -Dsort.violationFilename="target/sortpom_reports/violation.xml"
?
Feel free to try out your use case and any corner cases.
from sortpom.
It worked for me, thanks!
from sortpom.
Added some documentation to the parameter wiki. Have you tried the official version yet?
from sortpom.
No, I've added it to my todo list :)
from sortpom.
I know that feeling ;-)
from sortpom.
Related Issues (20)
- Sort plugins by executionId HOT 7
- detect duplicate properties HOT 1
- Release 3 HOT 1
- sortDependencies should have an option to leave the order of "import" scope dependencies alone HOT 2
- Update DOM parser HOT 2
- How install as an IntelliJ plugin? HOT 1
- Sortpom deleted the first blank line HOT 6
- License Header is removed from 3.1.0 release HOT 15
- Whitespace removed from within XML tags in 3.1.0 release HOT 6
- Whitespace after XML comments removed since 3.1.0 release HOT 9
- Suggestion: Add a parameter to control the sort of dependencies in dependencymanagement HOT 7
- Autoformat settings.xml files HOT 2
- Minimal version of Java for this plugin ? HOT 9
- Is it normal that pom.xml in target repository is checked ? HOT 7
- Preserve comments formatting HOT 5
- Merge automatic pull requests automatically HOT 6
- Xml formatting HOT 12
- sorting doesn't work in >=v3.0.0 HOT 11
- no sort xmls with doctype HOT 4
- Add entry for the 3.2.1 release on the wiki page `Versions` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sortpom.