aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Where is the variable calculated? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Where is the variable calculated?" Watch "Where is the variable calculated?" New topic
Author

Where is the variable calculated?

Iarla O'Riada
Ranch Hand

Joined: Oct 06, 2012
Posts: 87

My EAR project has a .pom file which specifies a dependency version as a variable (which I've now commented and replaced with an absolute value).


When I use the variable, I get a build of version 4.0.0 whereas when I specify 4.0.1-SNAPSHOT I get the build from my .m2 repo which has the extra resources I've built it with.

Thing is, I've checked to see where the version for my-eng-ejb is being evaluated / retrieved from in:
The parent pom
EarContent/META-INF/application.xml
org.eclipse.wst.common.component

And they all specify 4.0.1-SNAPSHOT.

Where is 4.0.0 coming from then?

Tim Cooke
Bartender

Joined: Mar 28, 2008
Posts: 1232
    
  67

Your version declaration of ${y.version} will refer to a property defined in your pom.xml with that name


Tim Driven Development
Iarla O'Riada
Ranch Hand

Joined: Oct 06, 2012
Posts: 87

That's correct Tim Cooke, and it's defined as 4.0.1-SNAPSHOT there too. But the artifact that is built yields 4.0.0.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5845
    
    7

Run this from a command line in you basedir and post the result:

mvn dependency:tree

Most likely some other dependency is also referencing the same dependency and Maven is choosing the non-snapshot version over the snapshot version.

The other thing you can do is run mvn with the -v option, redirect the output to a file and examine it looking for reference to that dependency to see how Maven is going about choosing a version to use.

JBoss In Action
Iarla O'Riada
Ranch Hand

Joined: Oct 06, 2012
Posts: 87

Thank you Peter Johnson. I tried to attach the output of "mvn dependency:tree", but the forum won't allow it (.txt or .zip). I'm reluctant to put project info from my (newly joined) company online where it can be easily indexed by search engines. I didn't realize this was an issue here and might make it difficult for me to use JavaRanch for more project-specific stuff, but the info you gave me will help me track down the issue I hope. I will rebuild with -v also and see what comes from that when I build next.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5845
    
    7

I understand the necessity for keeping proprietary company information confidential. You can usually work around that in two ways:
a) come up with a small example that exhibits the same problem but doesn't include any proprietary information
b) obfuscate anything that could be proprietary (such as package names and JAR files name), but make sure that your renaming is consistent

But even with those restrictions, you can often get help here - we can give you hints on what to try and look at (such as the -v suggestion). Often that can be helpful.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Where is the variable calculated?