Coder Social home page Coder Social logo

Comments (9)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024
Hi
I has been a while since I had a custom sort order file outside the actual 
plugin, but this is how we solved it then. 

Create a maven child module that contains resources (such as sort order files, 
logging configuration or findbugs configuration etc). (see attachment)
Then refer to the module in your sortpom plugin configuration (at top level).
        <plugin>
          <groupId>com.google.code.sortpom</groupId>
          <artifactId>maven-sortpom-plugin</artifactId>
          <version>0.2.3</version>
          <configuration>
            <createBackupFile>false</createBackupFile>
            <encoding>${project.build.sourceEncoding}</encoding>
            <sortOrderFile>sortpom/order.xml</sortOrderFile>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>my-project-group-id</groupId>
              <artifactId>plugin-resources</artifactId>
              <version>1.0</version>
            </dependency>
          </dependencies>
        </plugin>

In those days we had to do this for checkstyle configuration too. 

That said, I agree with you. It would be much easier to specify the 
configuration once at top level.
I can have a look at the code and see if there is a possibility to keep the 
configuration in the parent module.
Please tell me if the resource module solves your problem (at least temporary)

Original comment by [email protected] on 30 Jun 2014 at 1:49

  • Changed state: Accepted
  • Added labels: Type-Enhancement, Priority-Low
  • Removed labels: Type-Defect, Priority-Medium

Attachments:

from sortpom.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024
Hi,
yes, I tried your suggestion and it worked. So that's a fair workaround for me.
Thanks,

Original comment by [email protected] on 1 Jul 2014 at 7:01

from sortpom.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024
I made an investigation and found out that an new instance of the plugin class 
is created for each module it traverses, but the class instance is the same.

This means that a working configuration in the top module can be saved in a 
static variable. That configuration can then be reused when traversing sub 
modules (if another configuration cannot be found). 

Potential problems:
It can mess with Maven parallel builds, but the risk is quite low.
It will probably not work at all with Maven 2, but then the plugin will just 
report that the configuration cannot be found as before.
The solution will definitely not work if a sub module is formatted directly 
from command line.

Now that I think about it, I wonder if I should save the whole configuration or 
the absolute path to the configuration in the static variable.

So what do you think?

Original comment by [email protected] on 2 Jul 2014 at 7:25

from sortpom.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024
Thanks for looking into this.

Unfortunately I currently don't have time to dig into the code :/ . All I can 
say is that from a (my) user perspective it is really undesirable to have the 
build fail hard just because of POM element sorting, whatever the root cause.

Original comment by [email protected] on 6 Jul 2014 at 11:49

from sortpom.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024
Sorry for the delay.

I am now in the testing phase of the implementation and I reread your question. 
When you run your whole project from the top-level, does the child modules 
compile as well? 

Does your problem only occur when you compile a child module directly? 

Original comment by [email protected] on 28 Jul 2014 at 9:54

from sortpom.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024
Hey, yes, and yes, that's the problem exactly.

I can run 'mvn install' only from inside the parent module. When I run 'mvn 
install' from inside a child module, the build fails because sortpom can't find 
the sort order file (I have sortpom bound to a lifecycle phase).

Original comment by [email protected] on 3 Aug 2014 at 9:43

from sortpom.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024
Doh!! Seems that I was busy solving the wrong problem. I will have to go back 
to the drawing board. 

I am not sure how to reach resources from a parent module while the parent 
isn't in the current build process.
You will get a update of the investigation if and when I find something.

Original comment by [email protected] on 6 Aug 2014 at 7:43

from sortpom.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024
Sorry. I have not found a way to directly access parent resources. 

I have three suggestions:
1. Separate resource module (as shown earilier)
2. Similar solution: 
http://javasplitter.blogspot.se/2011/08/sharing-configuration-files-from-maven.h
tml
3. If you can access your version control system through an URL, use that URL 
as filename in the pom. Example:           
<sortOrderFile>http://sortpom.googlecode.com/git/sorter/src/test/resources/diffo
rder/differentOrder.xml</sortOrderFile>

Regards

Original comment by [email protected] on 10 Aug 2014 at 10:37

from sortpom.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 30, 2024

Original comment by [email protected] on 15 Aug 2014 at 8:35

  • Changed state: WontFix

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.