0

I have a Maven Project that was created from a pom file as described in the following link: Get MavenProject from just the POM.xml - pom parser? I have an unresolved dependency which I need to get values from. The values I get contain unresolved properties (for example: <version>${version}</version>). project.getProperties does not return properties like ${project.build.directory} or ${version} How can I get a list of ALL properties for this project?

for example I have this dependency and I cannot resolve it since ${version} was not resolved:

<dependency>
    <groupId>com.comp.sp</groupId>
    <artifactId>art</artifactId>    
    <version>${version}</version>
    <type>zip</type>
</dependency>
Community
  • 1
  • 1
user1116377
  • 629
  • 3
  • 15
  • 31
  • What are you trying to solve ? – khmarbaise Jan 01 '12 at 13:59
  • the question was changed with an example. see above. – user1116377 Jan 01 '12 at 14:17
  • Hm..Ok. you are using a property as a version marker which does not work with Maven...So the question is: Why don't you put the version into the pom and things are done? or define a properties section in the pom itself ? – khmarbaise Jan 01 '12 at 14:30
  • @khm variables in versions are fine, people do it all the time -- there are ways of messing up with it, of course. – bmargulies Jan 01 '12 at 14:48
  • @bmargulies I know...but i want to find out the reason for using them and reading the pom in that case.. – khmarbaise Jan 01 '12 at 15:01
  • OK, I see. user1116377, neither of us maven hackers here understand what you are trying to do and why you are trying to do it. Could you just write a shell script that runs mvn dependency:list and parses the output? – bmargulies Jan 01 '12 at 15:10
  • I can't because I don't have a regular maven project. assume I have a pom file sent to me and using my plugin I need to create a MavenProject from it (no problem) and then resolve the dependencies (no problem too). The only issue is resolving the properties for the dependencies. I really appreciate your help. – user1116377 Jan 01 '12 at 19:29

2 Answers2

0

Take a look at jcabi-aether util (I'm a developer), which is a wrapper around Apache Aether.

yegor256
  • 102,010
  • 123
  • 446
  • 597
0

Take a look at the Aether library which has examples in it which exactly solve your problem. (Take a look at here)..Officially Aehter is in the meantime move to Eclipse

khmarbaise
  • 92,914
  • 28
  • 189
  • 235