Coder Social home page Coder Social logo

Sort properties alphabetically about sortpom HOT 8 CLOSED

ekryd avatar ekryd commented on August 30, 2024
Sort properties alphabetically

from sortpom.

Comments (8)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024
[deleted comment]

from sortpom.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.