Comments (9)
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.
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.
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.
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.
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.
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.
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.
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.
Original comment by [email protected]
on 15 Aug 2014 at 8:35
- Changed state: WontFix
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.