Re: Parsing pom.xml

2018-12-09 Thread Robert Scholte
On Sun, 09 Dec 2018 13:44:52 +0100, Andres Almiray wrote: Hi Laird, Thanks, this all is very useful :-) One more thing, if I needed to read the contents of a settings.xml file, I suppose there's a similar API that make this work? Of course, better give you the complete overview :) :

Re: Parsing pom.xml

2018-12-09 Thread Andres Almiray
Hi Laird, Thanks, this all is very useful :-) One more thing, if I needed to read the contents of a settings.xml file, I suppose there's a similar API that make this work? Best, Andres --- Java Champion; Groovy Enthusiast JCP EC Associate Seat

Re: Parsing pom.xml

2018-12-09 Thread Elliotte Rusty Harold
On Sat, Dec 8, 2018 at 12:58 PM Oliver Drotbohm wrote: > > If it's about pure XML parsing and tweaking the information and building the > model is not required, XmlBeam [0] is a lightweight alternative to map the > entire file to a Java object. We use that in the Spring Data release >

Re: Parsing pom.xml

2018-12-08 Thread Laird Nelson
I forgot to mention: if you want to do this all "by hand", i.e. not rely on JSR 330 containers, you want to look here ( https://maven.apache.org/resolver/apidocs/index.html?org/eclipse/aether/impl/DefaultServiceLocator.html) and work backwards. Best, Laird -- https://about.me/lairdnelson On Sat,

Re: Parsing pom.xml

2018-12-08 Thread Laird Nelson
This is all near and dear to my heart. First, some terminology clearing up: the Maven internals rely on a JSR-330 implementation (javax.inject.*), not CDI (javax.enterprise.inject.*). CDI is a JSR-330 implementation, but so is Guice, HK2, etc. I believe that the internals of Maven rely on

Re: Parsing pom.xml

2018-12-08 Thread Robert Scholte
On Sat, 08 Dec 2018 21:52:16 +0100, Andres Almiray wrote: So far so good, I can parse POM files and read data. This works fine as long as I don't have to access a parent POM. @Robert: I suspect your first suggestion may be needed in order to resolve parent POM files as artifacts, isn't

Re: Parsing pom.xml

2018-12-08 Thread Andres Almiray
So far so good, I can parse POM files and read data. This works fine as long as I don't have to access a parent POM. @Robert: I suspect your first suggestion may be needed in order to resolve parent POM files as artifacts, isn't that right? Best, Andres

Re: Parsing pom.xml

2018-12-08 Thread Robert Scholte
Ah, you might be lucky with this solution :) On Sat, 08 Dec 2018 19:20:59 +0100, Andres Almiray wrote: Looks like I found the answer to instantiating the ModelBuilder new DefaultModelBuilderFactory().newInstance() From the javadoc: * A factory to create model builder instances when

Re: Parsing pom.xml

2018-12-08 Thread Andres Almiray
Looks like I found the answer to instantiating the ModelBuilder new DefaultModelBuilderFactory().newInstance() >From the javadoc: * A factory to create model builder instances when no dependency injection is available. Note: This class is * only meant as a utility for developers that want

Re: Parsing pom.xml

2018-12-08 Thread Robert Scholte
Hi Andres, this is what you need to do: @Inject private ModelBuilder builder; (or with @Requiment when using only plexus annotations) This means you need your code to run in a CDI container. If you use Sisu[1] you can mix Plexus and JSR330 annotations. Maven & JSR-330[2] Should explain

Re: Parsing pom.xml

2018-12-08 Thread Andres Almiray
HI Oliver, Nice! However that approach may require mapping all possible elements, including plugins and more. The ModelBuilder should take care of that, isn't it? Cheers, Andres --- Java Champion; Groovy Enthusiast JCP EC Associate Seat

Re: Parsing pom.xml

2018-12-08 Thread Oliver Drotbohm
If it's about pure XML parsing and tweaking the information and building the model is not required, XmlBeam [0] is a lightweight alternative to map the entire file to a Java object. We use that in the Spring Data release automation. Declare an interface containing accessors backed by XPath

Re: Parsing pom.xml

2018-12-08 Thread Andres Almiray
Thank you Robert! It looks like org.apache.maven.model.Model.DefaultModelBuilder provides the behavior I need given this method found in its contract ModelBuildingResult build( ModelBuildingRequest request ) throws ModelBuildingException; ModelBuildingResult gives me access to the

Re: Parsing pom.xml

2018-12-08 Thread Robert Scholte
The ModelBuilder[1] is what you are looking for, and yes it does a LOT :) Be aware that it is using CDI, so to make use of it you'll need sisu/guice too. Robert [1] https://maven.apache.org/ref/3.6.0/maven-model-builder/ On Sat, 08 Dec 2018 18:20:51 +0100, Andres Almiray wrote: Of

Re: Parsing pom.xml

2018-12-08 Thread Andres Almiray
Of course. This is definitely not a plugin project. My goal is to have an in-memory representation of the POM as defined by a source pom.xml, to later transform/enrich it and write it back. As a side effect this tool can calculate statics on usage patterns and recommend some others. Best, Andres

Re: Parsing pom.xml

2018-12-08 Thread Enrico Olivelli
Il sab 8 dic 2018, 18:09 Andres Almiray ha scritto: > Hello everyone, > > I have the need of building a model based on the data defined in a pom.xml > file. > What would be the best way to read, parse, and obtain such model using > standard Maven APIs? > Could you given some more context? I

Parsing pom.xml

2018-12-08 Thread Andres Almiray
Hello everyone, I have the need of building a model based on the data defined in a pom.xml file. What would be the best way to read, parse, and obtain such model using standard Maven APIs? Best, Andres --- Java Champion; Groovy Enthusiast JCP EC Associate

Re: Maven parsing pom.xml incorrectly

2013-09-18 Thread Dennis Lundberg
This mailing list is used only for automated responses from our issue tracker. Please use us...@maven.apache.org instead. On Tue, Sep 17, 2013 at 6:55 PM, Andrew Pennebaker apenneba...@42six.com wrote: I'm using Thrift in my Maven project, compiling my .thrift code to .java as part of the

Re: Maven parsing pom.xml incorrectly

2013-09-18 Thread Greg Trasuk
Hi Andrew: Unfortunately, that's in the XML spec, not Maven. '--' is not permitted in comments. I'm not aware of any workaround, though I'd be interested to hear one. Putting the line that contains the offending '--' does not work. Sorry, Greg. On Wed, 2013-09-18 at 04:59, Dennis Lundberg

RE: Maven parsing pom.xml incorrectly

2013-09-18 Thread Brian Withnell
to -- when uncommenting. Hope this helps, Dan -Original Message- From: Andrew Pennebaker [mailto:apenneba...@42six.com] Sent: Tuesday, September 17, 2013 12:55 PM To: Maven Issues Subject: Maven parsing pom.xml incorrectly I'm using Thrift in my Maven project, compiling my .thrift

RE: Maven parsing pom.xml incorrectly

2013-09-18 Thread Dan Taylor
Pennebaker [mailto:apenneba...@42six.com] Sent: Tuesday, September 17, 2013 12:55 PM To: Maven Issues Subject: Maven parsing pom.xml incorrectly I'm using Thrift in my Maven project, compiling my .thrift code to .java as part of the generate-sources step. To do this, I use the maven antrun plugin in my