Comments (8)
Hi
If you specify your properties in a custom sort order file, then the properties
will be sorted in that order.
Example:
Part of a custom sort order file (full file is attached):
<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">
<modelVersion />
...snip...
<properties>
<project.build.sourceEncoding/>
<compileSource/>
<another/>
</properties>
...snip...
<reports />
</project>
The (very short) pom-file you want to sort:
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<properties>
<another>Cucumber</another>
<compileSource>1.6</compileSource>
<other>Tomatoes</other>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
The result of the sort will be:
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compileSource>1.6</compileSource>
<another>Cucumber</another>
<other>Tomatoes</other>
</properties>
</project>
Notice that the three properties specified in the custom sort order file are
sorted first, in the order you specified it.
So, my question is: Could this solve your problem, or do you still need the
plugin parameter sort.sortProperties?
Regards
/Björn
Original comment by [email protected]
on 9 Feb 2012 at 10:25
- Changed state: Accepted
Attachments:
from sortpom.
[deleted comment]
from sortpom.
Hi Björn,
Listing all properties explicitly in a custom sort order file solves the
problem, but seems to be a bit cumbersome.
I have to sort the properties still manually using this approach (however, only
once and every time I add a new property in my poms).
I have already made a patch for the new parameter. It seems to work but I
didn't test it extensively. The change in WrapperFactoryImpl is a bit a hack,
but suffices my needs.
If you decide to implement the feature, feel free to use (and improve) it.
Regards,
Christian
Original comment by [email protected]
on 9 Feb 2012 at 2:22
Attachments:
from sortpom.
I will look into this. Obviously this can be solved :-)
Original comment by [email protected]
on 10 Feb 2012 at 6:11
- Changed state: Started
from sortpom.
Added the new parameter sortProperties to the source. Can you do an update and
run it locally with
mvn com.google.code.sortpom:maven-sortpom-plugin:1.2.0-SNAPSHOT:sort
-Dsort.sortProperties=true
before I upload it to Central?
I used parts of your patch, it was helpful. Thank you!
Regards
/Björn
Original comment by [email protected]
on 12 Feb 2012 at 6:11
from sortpom.
Hi Björn,
I have tested the 1.2.0-SNAPSHOT and it worked fine.
I haven't thought of properties inside of profiles, good you have changed that.
I have been looking into the maven-4.0.0.xsd and have seen that there are also
properties possible inside of contributor and developer elements. Maybe you
want to add them too.
Regards,
Christian
Original comment by [email protected]
on 16 Feb 2012 at 1:05
from sortpom.
I saw those properties too, but decided that they probably didn't have anything
to do with the actual build. They seemed more like documentation tags and
therefore the plugin will not sort them.
I'll send the plugin to Central now (it takes a day or two). Please verify the
plugin once again when it is deployed and set the issue to Verified.
Regards,
Björn
Original comment by [email protected]
on 16 Feb 2012 at 1:14
- Changed state: Fixed
from sortpom.
Original comment by [email protected]
on 1 May 2014 at 8:35
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
from sortpom.
Related Issues (20)
- 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
- Tone down sortpom output HOT 6
- Properties configuration Suggestion HOT 7
- Setting to disable pom sorting? HOT 4
- LATEST using in pom is deprecated and will be removed from maven 4 HOT 8
- Handle plugin warnings HOT 1
- Dependency Dashboard
- Setup Maven 4 build pipe HOT 1
- Preserve formatting inside project element HOT 9
- Add configuration to suppress XML declaration HOT 7
- Add configuration for newline at the end of file HOT 6
- XML tag with `xml:space="preserve"` containing only spaces should not be collapsed HOT 4
- Attributes resulting in long lines should be wrapped or chopped down HOT 10
- Revisit schema location indent choice HOT 11
- Java Class File Version 52+ ( 55=Java 11 and/or 61=Java 17)
- Newlines aren't kept at beginning or end of String content. HOT 4
- Not sorting with mvn comand 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.