ekryd / sortpom Goto Github PK
View Code? Open in Web Editor NEWMaven plugin that helps the user sort pom.xml.
Home Page: https://github.com/Ekryd/sortpom/wiki/
License: BSD 3-Clause "New" or "Revised" License
Maven plugin that helps the user sort pom.xml.
Home Page: https://github.com/Ekryd/sortpom/wiki/
License: BSD 3-Clause "New" or "Revised" License
Steps:
1. Configure plugin:
<plugin>
<groupId>com.google.code.sortpom</groupId>
<artifactId>maven-sortpom-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sort</goal>
</goals>
</execution>
</executions>
<configuration>
<nrOfIndentSpace>-1</nrOfIndentSpace>
<keepBlankLines>true</keepBlankLines>
</configuration>
</plugin>
2. mvn verify
Result:
Blank lines are prefixed with TAB, which is correct considering XML document
and indentations.
In my case, however, I want the blank lines to be empty of trailing whitespace
(that's a convention used in every file throughout projects). Could you add a
property for setting trailing whitespace off?
Reasoning/background:
Empty line whitespace is often "forgotten" to maintain, causing extra diffs if
developer's have differing conventions regarding whitespace. That's why we've
set trailing whitespace off everywhere.
Original issue reported on code.google.com by [email protected]
on 5 Jun 2012 at 8:38
What steps will reproduce the problem?
1. Sort attached POM
2. Configure IDE XML style:
- Right margin 120 columns (IntelliJ: Code Style -> General)
- Enable Text and XML attribute wrapping (IntelliJ: Code Style -> XML -> Other)
What is the expected output? What do you see instead?
Line breaks should be preserved for property "ftp.remote.dir" and attributes of
"ftp" tag. Otherwise, IDE formatter will keep adding line breaks again. This
makes it hard to keep POMs in version control if all files are formatted
automatically by the IDE.
Original issue reported on code.google.com by [email protected]
on 19 Jun 2012 at 5:54
What steps will reproduce the problem?
1. Create a pom.xml which contains blank lines for example between profiles and
build.
2. Force a sort (create a state which violates the sortFile-Schema)
What is the expected output? What do you see instead?
- Blank lines should not be deleted.
- Instead the manual added blank lines will be deleted.
What version of the product are you using? On what operating system?
2.2 Windows 7
Please provide any additional information below.
<plugin>
<groupId>com.google.code.sortpom</groupId>
<artifactId>maven-sortpom-plugin</artifactId>
<version>2.2</version>
<configuration>
<sortDependencies>scope,groupId,artifactId</sortDependencies>
<sortOrderFile>C:\custom_1.xml</sortOrderFile>
<nrOfIndentSpace>4</nrOfIndentSpace>
<indentBlankLines>true</indentBlankLines>
</configuration>
</plugin>
--> It would be nice, if i can specify blank lines in the schema and the plugin
would forcing these lines.
Original issue reported on code.google.com by [email protected]
on 11 Sep 2013 at 8:36
The element with xmlns, xsi, etc., currently is reformatted to all be on one line.
I would like it split onto four lines so that each line is no more than 80 characters.
My team uses Atlassian Crucible for code reviews. It displays the old code side-by-side with the new code. A lot of our pom.xml files don't have any lines longer than 100 characters, except for the line which is formatted onto one line of over 200 characters. This causes a very big horizontal scroll bar between the old and new code which is just empty space, difficult to compare changes.
I'm not asking to enforce 80 character line limits, just allow the line to be formatted to something shorter than over 200 characters on one line.
This means that Java 8 is required to run the plugin from now on and that the version number will be changed to 3.x.x.
The reason for this is:
I'm using sortpom-maven-plugin to only check the pom.xml when a new PR is submitted. I didn't find a way to get the messages in the machine-readable form (XML/JSON). It would be great to have such feature because it could be used in automatization and integration with external plugins/bots.
What steps will reproduce the problem?
1. Run sortpom on a POM which does not follow the configured sort order.
2. Then view the diff of the original POM and the sorted POM.
What is the expected output? What do you see instead?
sortpom adds an additional newline at the end of the file. The following
example is from "git diff":
@@ -21,3 +21,4 @@
</dependency>
</dependencies>
</project>
+
I would expect that no additional newline will be added.
What version of the product are you using? On what operating system?
I am using sortpom 0.4.0 and 1.0.0-SNAPSHOT with JDK 1.6.0_29.
Original issue reported on code.google.com by [email protected]
on 10 Dec 2011 at 3:29
Intellij default xml formatter puts line breaks in long lines. The value add for this project is the sorting, not the formatting. I would like to see the following parameter added to the configuration.
<breakLongLines>
default false and/or <format>
default it to false.
I can't find a 2.4.0 tag in the git repo, even though that's the current released version.
This is really just a question.
I put the plugin in my pom and would like to provide a svn url to a sort order
xml file for the sorting. Is there a way to do this with this plugin?
I would like to this because we have multiple projects and multiple engineers.
I would like project poms to all be sorted the correct way and I want it to
always be sorted using the latest sort order xml.
I didn't really want to add the sort order xml to each project we have. I would
rather have it brought in for the sort and then disposed of once the project
has been built.
Original issue reported on code.google.com by [email protected]
on 15 Aug 2013 at 4:54
Would you provide documentation on the behavior of comments?
I found in issue #26 (https://code.google.com/p/sortpom/issues/detail?id=26)
the reply:
"It is hard to indicate that a certain comment should be be connected to the
preceding xml element. Right now, comments are bound to the following xml
element and as the element moves, the comment follow."
This is fairly clear, perhaps rephrasing and adding to the top-level page
explaining the plugin?
Original issue reported on code.google.com by [email protected]
on 8 Sep 2014 at 4:32
I would like to have a special check
goal that won't change my pom.xml
but will indicate is it already has sorted or hasn't.
Other plugins already have such feature:
If a user modifies the pom but forgets to sort it (ie. doesn't run a build locally like they should) I'd like our CI system to fail the build.
Is this something that can be configured?
Hello,
You could please release your plugin, I look forward to use the "force EOL" feature !
Thanks !
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] ------------------------------------------------------------------------
Sonatype has documented how to push artifacts to Maven Central:
http://www.sonatype.com/people/2011/10/publishing-your-artifacts-to-the-central-
repository/
Can you push the sortpom plugin to Maven Central? Since 3rd-parties are also
allowed to push artifacts to central, so I can offer to do that if you do not
object.
Original issue reported on code.google.com by [email protected]
on 9 Nov 2011 at 1:28
What steps will reproduce the problem?
1. Create a pom with dependencies and/or dependency management
2. try to sort
What is the expected output? What do you see instead?
The expected output would be sorted list of dependencies, sorted by
artifact id first and then group id.
The result is a not sorted list of dependecies.
What version of the product are you using? On what operating system?
0.2.3 on Windows 7 (64bit) with Maven 2.2.1 and Java 1.6.0_17
Original issue reported on code.google.com by [email protected]
on 10 Feb 2010 at 7:36
What steps will reproduce the problem?
<implementation-class>
com.intellij.cvsSupport2.connections.ssh.SSHPasswordProvider
</implementation-class>
The result after sorting:
<implementation-class>
</implementation-class>
Original issue reported on code.google.com by [email protected]
on 19 Jun 2012 at 12:32
Since code.google.com is shutting down, I think it's really important that sortpom move to GitHub for its canonical location. I see this repository is already an export of what was in code.google.com, but it is not up-to-date.
Please update this repository, and migrate to GitHub, and provide a notice on code.google.com of the new location.
I like the sortProperties option, but I also like to separate "sections" of
properties (like plugin versions vs dependency versions), but still have them
sorted within those groups.
It would be nice to sort properties in sections, where sections could be
defined by a blank line or a comment line <!-- --> or something like that.
Original issue reported on code.google.com by [email protected]
on 12 Jun 2013 at 2:41
What steps will reproduce the problem?
1. Include an element in pom.xml with attribute xml:space="preserve" and some
embedded newlines
2. Sort the pom (using
https://code.google.com/p/sortpom/wiki/recommended_configuration)
What is the expected output? What do you see instead?
The element content should be unchanged. Instead, \n becomes \r\n.
What version of the product are you using? On what operating system?
2.2, on Linux (RHEL 6.4)
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 23 Sep 2013 at 2:48
If you use the invoke plugin, it would be nice to be able to sort the test-poms as well
I just stumbled across your pom sorter, up to now i keep my poms manually
sorted according to the maven suggestion documented in
http://maven.apache.org/developers/conventions/code.html.
Unfortunately, this suggested order differs from the xsd order. Can the sortpom
plugin support the suggested styleguide order?
Original issue reported on code.google.com by [email protected]
on 13 Sep 2012 at 11:14
I really need to leave subversion. Branching for multiple issues becomes so
much easier and quicker then.
Original issue reported on code.google.com by [email protected]
on 16 Sep 2012 at 9:05
This looks awesome. Can you provide license information, please? I'd like to use it at work.
When sorting dependencies, it would be helpful if there was an option to group
by scope.
Original issue reported on code.google.com by [email protected]
on 12 Sep 2012 at 7:13
What steps will reproduce the problem?
1. Execute a parallel build on a multi module project that uses the sortpom
plugin, e.g.: mvn clean install -T 1C
What is the expected output? What do you see instead?
Maven prints this big warning I'd rather not see:
[WARNING] *****************************************************************
[WARNING] * Your build is requesting parallel execution, but project *
[WARNING] * contains the following plugin(s) that are not marked as *
[WARNING] * @threadSafe to support parallel building. *
[WARNING] * While this /may/ work fine, please look for plugin updates *
[WARNING] * and/or request plugins be made thread-safe. *
[WARNING] * If reporting an issue, report it against the plugin in *
[WARNING] * question, not against maven-core *
[WARNING] *****************************************************************
[WARNING] The following plugins are not marked @threadSafe in mymodule:
[WARNING] com.google.code.sortpom:maven-sortpom-plugin:1.2.0
[WARNING] *****************************************************************
What version of the product are you using? On what operating system?
maven-sortpom-plugin 1.2.0
JDK 1.7.0_02
Maven 3.0.4
Windows 7 64-bit
Please provide any additional information below.
The POMs seem to be correctly sorted though, so this may not be a lot of work.
:-)
Original issue reported on code.google.com by [email protected]
on 19 Feb 2012 at 6:32
Hi,
I have just recently start using your plugin. I like it a lot, but there are two things that keep me from using it automatically. First, it also parses the project tag. Second, it parses the description tag. I feel both makes the pom file harder to read.
I know that it is possible to add ignore-sections, but I feel this clutters up the pom file.
Thanks for looking in to this.
Alex
P.S. As an example:
Project tag
Given
<project xmlns="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">
When the parser is run
Then it should not turn the snippet into
<project xmlns="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">
Tags with long lines.
Given:
<description>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
vehicula magna in lorem vestibulum lacinia. Nullam quis lobortis purus.
Etiam ut finibus velit. Donec tempor egestas nisl volutpat pharetra.
</description>
When the parser is run
Then it should not turn the snippet into
<description>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
vehicula magna in lorem vestibulum lacinia. Nullam quis lobortis purus.
Etiam ut finibus velit. Donec tempor egestas nisl volutpat pharetra.</description>
What steps will reproduce the problem?
1. Run mvn site
2. See coverage
What is the expected output? What do you see instead?
Expected near 100%
Please use labels and text to provide additional information.
Write more tests
Original issue reported on code.google.com by [email protected]
on 12 Sep 2009 at 9:26
how can is set the line with in sortpom?
see also
https://maven.apache.org/developers/conventions/code.html
Gruss Stefan
What steps will reproduce the problem?
1. Specify <sortOrderFile> file in plugin configuration inside some parent POM
2. Put the specified file in the same directory as that POM
3. Run sortpom:sort on one of the children modules of this parent
What is the expected output? What do you see instead?
sortpom:sort should use the sort order specified in <sortOrderFile>. But the
goal fails with file not found.
What version of the product are you using? On what operating system?
Apache Maven 3.2.1, Java version: 1.7.0_60, on Mac OS X.
Here is a longer description: When I put a <sortOrderFile> named
"sortpom-order.xml" in my top-level parent home, the sortpom plugin can't find
it when I build a child project.
In the parent POM, ~/myproject/myproject-parent/pom.xml, I specify the
configuration for the plugin
...
<build>
<plugins>
...
<plugin>
<groupId>com.google.code.sortpom</groupId>
<artifactId>maven-sortpom-plugin</artifactId>
<version>2.3.0</version>
<configuration>
<sortOrderFile>sortpom-order.xml</sortOrderFile>
...
</configuration>
</plugin>
...
</plugins>
</build>
...
Then, when I build one of the children separately, say
~/myproject/myproject-parent/myproject-child1/pom.xml, the "sortpom-order.xml"
isn't found.
Could not find /home/glts/myproject/myproject-parent/myproject-child1/sortpom-order.xml ...
That file of course does not exist. It's in the parent directory. I think it is
common style to put global configuration files in the top-level parent project.
Compare the behaviour of the Maven checkstyle plugin: there I can specify a
<configLocation>my-checkstyle.xml</configLocation> in the parent POM, put that
file in the parent home dir, and then all the children automatically have
access to this when I run checkstyle:checkstyle on them.
Thanks!
Original issue reported on code.google.com by [email protected]
on 28 Jun 2014 at 5:34
It would be nice to see the values that are set for the plugin in some form of debugging log mode
Hi
I notes that xml file like this:
<foo>bla</foo> <!-- bar -->
after sorting is displayed like that:
<foo>bla</foo>
<!-- bar -->
is there an option to avoid that (keep comment at end of line) ?
Thx
Christophe
How do I get the sortpom plugin to just use the configuration I define in my pom when I execute mvn sortpom:sort
?
I've noticed that the plugin will use a different configuration. The most notable difference is the indentation is 3 when I execute mvn verify
and it's set to 2 when I execute mvn sortpom:sort
.
Can I get around having to edit the settings.xml file in my maven install?
Feature request:
Add a plugin parameter sort.sortProperties (default false).
If sort.sortProperties is true, sort the properties alphabetically.
Original issue reported on code.google.com by [email protected]
on 8 Feb 2012 at 3:27
What steps will reproduce the problem?
1. Modify pom
2. Execute sorting
3. Watch backup pom preventing the release plugin
What is the expected output? What do you see instead?
Would be very cool to have something similar to versions:commit/versions:revert
that cleans the generated backup or reverts the sorting.
Original issue reported on code.google.com by [email protected]
on 8 Mar 2014 at 6:55
In bigger POM files, we use to have several blank lines to separate sections from one another. However, even when passing option -Dsort.keepBlankLines=true
, there is only one of them preserved.
How about adding another option like nrOfBlankLinesToKeep
to let the user specify how many blank lines should be kept? For instance if this is set to 2, at most two consecutive blank lines of the source file are preserved and remaining ones are removed it there are more than that.
BTW, great plugin!
What steps will reproduce the problem?
1. Add <exclusions> to a <dependency>
2. mvn sortpom:sort
What is the expected output? What do you see instead?
I expect to see the output ordered like the dependency:
<exclusion><groupId/><artifactId/></exclusion>
But instead I see <exclusion><artifactId/><groupId/></exclusion>
What version of the product are you using? On what operating system?
I'm on linux, using maven3
maven-sortpom-plugin:2.2.1:sort (default-cli)
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 21 Oct 2013 at 3:52
What steps will reproduce the problem?
1.Create a dependency with a comment like this
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.0</version><!--$NO-MVN-MAN-VER$ -->
</dependency>
2. Run sortpom
What is the expected output? What do you see instead?
It reformats it to
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.0</version>
<!--$NO-MVN-MAN-VER$ -->
</dependency>
Which breaks the eclipse m2e comment to ignore the overridden dependency.
What version of the product are you using? On what operating system?
2.1.0
Please provide any additional information below.
Sortpom is awesome and totally helps me maintain a large hierarchy of different
poms.
Original issue reported on code.google.com by [email protected]
on 19 Nov 2013 at 7:45
What steps will reproduce the problem?
1. Create a POM with an empty tag. Example:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.4</version>
<reportSets>
<reportSet>
<reports/>
</reportSet>
</reportSets>
</plugin>
2. Run sortpom
What is the expected output? What do you see instead?
Sortpom expands the tag to a start and an end tag:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.4</version>
<reportSets>
<reportSet>
<reports></reports>
</reportSet>
</reportSets>
</plugin>
Now my IDE (Intellij IDEA) complains about this.
I would expect that empty tags are not expanded to start/end tags:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.4</version>
<reportSets>
<reportSet>
<reports/>
</reportSet>
</reportSets>
</plugin>
What version of the product are you using? On what operating system?
I am using sortpom 0.4.0 with JDK 1.6.0_27.
Original issue reported on code.google.com by [email protected]
on 9 Dec 2011 at 12:26
The configuration has an option to preserve blank lines, but have you
considered adding an option to add blank lines when they don't exist (in order
to match the blank lines that exist in the sort order file)?
Original issue reported on code.google.com by [email protected]
on 12 Sep 2012 at 6:44
Is there any option to sort the reporting plugins?
Original issue reported on code.google.com by [email protected]
on 13 Sep 2012 at 5:10
Check out the page
http://maven.apache.org/developers/conventions/code.html#POM_Code_Convention
Original issue reported on code.google.com by [email protected]
on 7 Aug 2010 at 5:44
What steps will reproduce the problem?
1. sorting a pom with parent. Parent-groupId before -artifactId.
2. configuration <sortDependencies>scope,groupId,artifactId</sortDependencies>
What is the expected output? What do you see instead?
I would expect that dependencies and parent get sorted in the same order.
Instead, after sortign, the artifactId is right before the groupId and the log
says: "The xml element <artifactId> should be placed before <groupId>".
What version of the product are you using? On what operating system?
plugin-version 2.1.0, Maven 3.0.5
Please provide any additional information below.
Another solution would be to provide another configuration:
<sortParent>scope,groupId,artifactId</sortParent>
but IMHO nobody likes to sort dependencies and parent in different ways.
First day with this wonderful plugin, thanks a lot!
Best regards,
Sebastian
Original issue reported on code.google.com by [email protected]
on 11 Jun 2013 at 12:13
What steps will reproduce the problem?
1. Run the plugin using the defaultOrderJune2008.xml configuration
2. The order of the resulting POM-files differ slightly from the order here
http://maven.apache.org/ref/3.0.3/maven-model/maven.html
What is the expected output? What do you see instead?
Expected:
<parent>
<artifactId/>
<groupId/>
<version/>
<relativePath/>
</parent>
<executions>
<execution>
<id/>
<phase/>
<goals/>
<inherited/>
<configuration/>
</execution>
</executions>
Real:
<parent>
<groupId/>
<artifactId/>
<version/>
<relativePath/>
</parent>
<executions>
<execution>
<id/>
<goals/>
<phase/>
<inherited/>
<configuration/>
</execution>
</executions>
What version of the product are you using? On what operating system?
0.4.0 on Windows 7
Please provide any additional information below.
Attached patch fixes this.
Original issue reported on code.google.com by [email protected]
on 23 Nov 2011 at 9:16
Attachments:
It'd be nice to generate plugin documentation, and publish in gh-pages. See https://github.com/revelc/zookeeper-maven-plugin for an example plugin which generates site docs and pushes to a gh-pages branch in GitHub.
Currently the indent of the sorted POM is two spaces, our project default is
four spaces so that we need to reformat the POMs after sorting. It would be
really nice if the indent of the sorted POM is configurable.
Original issue reported on code.google.com by [email protected]
on 7 Apr 2010 at 12:23
Is the plugin capable of reording and sorting dependencies e.g. if I have
<!-- 2.0 was asked for but 2.2 is available in repo -->
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http-shared4</artifactId>
<version>${version.wagon-http-shared4}</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${version.com.sun.faces}</version>
</dependency>
in my dependencies block I and I sort using:
mvn sortpom:sort -Dsort.pomFile=~/Work/foo/pom.xml
-DsortDependencies=groupId,artifactId -Dsort.nrOfIndentSpace=4
I would expect the com.sun.faces dependency to be moved to be first. However it
doesn't move.
Original issue reported on code.google.com by [email protected]
on 2 Oct 2012 at 1:34
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.