You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mark_E <ma...@trustvesta.com> on 2007/11/01 19:56:06 UTC

How to properly set jar versions for builds

I am having an issue setting jar versions in Maven and trying to resolve this
through Best Practices

What I have is my project pom.xml that will build project MyJar. In the Pom,
I have dependencies setup like this

    <dependency>
      <groupId>org.apache</groupId>
      <artifactId>xalan</artifactId>
      <version>${xalanVersion}</version>
    </dependency>

In my settings.xml, I control the version that is current, for example

<xalanVersion>2.4.1</xalanVersion>

This works great. I build MyJar, it resolves the version of xalan required
to build it and it installed MyJar.jar and MyJar.pom into the repository

Now, here is where the problem comes up.

I try to build MyJar2. It is dependent upon MyJar to compile. So I have this
dependency listed in my pom.xml for MyJar2

    <dependency>
      <groupId>com.mycompany</groupId>
      <artifactId>MyJar</artifactId>
      <version>${MyJarVersion}</version>
    </dependency>

And in settings.xml, I have

<MyJarVersion>1/0</MyJarVersion>

Now, when I try to compile MyJar2, it sees that I need MyJar so it tries to
download the pom for MyJar from the repository however for some reason, when
it sees the pom for MyJar, it becomes confused on what settings.xml to use.
It cannot resolve dependencies anymore. If I go into the repository and
delete the pom in the MyJar folder then try to compile it works just fine.

 I do have the settings.xml in /home/user/.m2 linked to the the
/usr/local/maven-2.0.7/conf folder where the default settings.xml lives


So, I think I am doing it wrong. How do others handle this? I have tried
creating a parent pom with the version in it and then referencing the parent
pom in the child pom but that does not seem to work either. I know I am
missing something but sometimes, you overlook the easist things and you need
another set of eyes to look at it and say ah, this is why.

I suppose I could just have the build script delete the pom from the
repository after it loads the jar but I know that is a hack and not the
right way to do it. 

Any help or  suggestions would be much appreciated.

Regards,
Mark
-- 
View this message in context: http://www.nabble.com/How-to-properly-set-jar-versions-for-builds-tf4733418s177.html#a13535119
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to properly set jar versions for builds

Posted by Michael McCallum <gh...@apache.org>.
the right way is not not externalise the versions a pom should be the formal 
defiintion of your project at an instant of time... if you externalise 
information the contract breaks down as you have discovered...

if you need to provide a common place for 3rd party library versions for your 
projects you can create pom or empty projects which include the deps to the 
3rd party project, i find that works very well...

e.g.

my.company.composite.xml 1.X
 -> xalan 2.4.1
 -> xerces 2.7.1

my.company.project.a
 -> my.company.company.xml [1,2-!)

my.company.project.b
 -> my.company.company.xml [1,2-!)



On Friday 02 November 2007 07:56, Mark_E wrote:
> I am having an issue setting jar versions in Maven and trying to resolve
> this through Best Practices
>
> What I have is my project pom.xml that will build project MyJar. In the
> Pom, I have dependencies setup like this
>
>     <dependency>
>       <groupId>org.apache</groupId>
>       <artifactId>xalan</artifactId>
>       <version>${xalanVersion}</version>
>     </dependency>
>
> In my settings.xml, I control the version that is current, for example
>
> <xalanVersion>2.4.1</xalanVersion>
>
> This works great. I build MyJar, it resolves the version of xalan required
> to build it and it installed MyJar.jar and MyJar.pom into the repository
>
> Now, here is where the problem comes up.
>
> I try to build MyJar2. It is dependent upon MyJar to compile. So I have
> this dependency listed in my pom.xml for MyJar2
>
>     <dependency>
>       <groupId>com.mycompany</groupId>
>       <artifactId>MyJar</artifactId>
>       <version>${MyJarVersion}</version>
>     </dependency>
>
> And in settings.xml, I have
>
> <MyJarVersion>1/0</MyJarVersion>
>
> Now, when I try to compile MyJar2, it sees that I need MyJar so it tries to
> download the pom for MyJar from the repository however for some reason,
> when it sees the pom for MyJar, it becomes confused on what settings.xml to
> use. It cannot resolve dependencies anymore. If I go into the repository
> and delete the pom in the MyJar folder then try to compile it works just
> fine.
>
>  I do have the settings.xml in /home/user/.m2 linked to the the
> /usr/local/maven-2.0.7/conf folder where the default settings.xml lives
>
>
> So, I think I am doing it wrong. How do others handle this? I have tried
> creating a parent pom with the version in it and then referencing the
> parent pom in the child pom but that does not seem to work either. I know I
> am missing something but sometimes, you overlook the easist things and you
> need another set of eyes to look at it and say ah, this is why.
>
> I suppose I could just have the build script delete the pom from the
> repository after it loads the jar but I know that is a hack and not the
> right way to do it.
>
> Any help or  suggestions would be much appreciated.
>
> Regards,
> Mark

-- 
Michael McCallum
Enterprise Engineer
mailto:gholam@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org