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

Sort properties alphabetically #9

Closed
GoogleCodeExporter opened this issue Mar 14, 2015 · 8 comments
Closed

Sort properties alphabetically #9

GoogleCodeExporter opened this issue Mar 14, 2015 · 8 comments

Comments

@GoogleCodeExporter
Copy link

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 christia...@gmail.com on 8 Feb 2012 at 3:27

@GoogleCodeExporter
Copy link
Author

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 bjorn.ek...@gmail.com on 9 Feb 2012 at 10:25

  • Changed state: Accepted

Attachments:

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

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 christia...@gmail.com on 9 Feb 2012 at 2:22

Attachments:

@GoogleCodeExporter
Copy link
Author

I will look into this. Obviously this can be solved :-)

Original comment by bjorn.ek...@gmail.com on 10 Feb 2012 at 6:11

  • Changed state: Started

@GoogleCodeExporter
Copy link
Author

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 bjorn.ek...@gmail.com on 12 Feb 2012 at 6:11

@GoogleCodeExporter
Copy link
Author

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 christia...@gmail.com on 16 Feb 2012 at 1:05

@GoogleCodeExporter
Copy link
Author

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 bjorn.ek...@gmail.com on 16 Feb 2012 at 1:14

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

Original comment by bjorn.ek...@gmail.com on 1 May 2014 at 8:35

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

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

No branches or pull requests

1 participant