Dependencies, repos and packages in pom file

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered
My understanding is that in the pom.xml file, I can specify

1) the necessary packages my bundle refers to in <import-package>
2) the repo to download the JARs under repository> and
3) the dependencies within <dependency>

While I know the packages needed for my bundle, my build fails due to issues with downloading from remote repos (I use the ODL release repo in https://wiki.opendaylight.org/view/Infrastructure:Nexus) most of the time.

My questions are: 

1. What remote repository is it advisable to use? Or is it needed at all as I find the JARs I need in the plugin directory of opendaylight in our kit?

2. How could I find out what version of sal to use when specifying the dependency in 

<dependencies>
        <dependency>
                     <groupId>org.opendaylight.controller</groupId>
                     <artifactId>sal</artifactId>
                     <version>0.7.0</version>
         </dependency>
</dependencies>
Photo of Chandrasekaran, Arun

Chandrasekaran, Arun, Alum

  • 342 Points 250 badge 2x thumb

Posted 4 years ago

  • 0
  • 1
Photo of Rob Gries

Rob Gries

  • 80 Points 75 badge 2x thumb
1.  Our project uses the Nexus opendaylight.release repository as well.  We haven't had any issues with it yet.

2.  We use a parent pom.xml that manages all dependencies in the repository because it removes the need to specify version numbers for the dependencies.

The parent can be specified as follows (version number can be replaced with other valid versions):

<parent>
        <groupId>org.opendaylight.controller</groupId>
        <artifactId>commons.opendaylight</artifactId>
        <version>1.4.2-Helium</version>
</parent>

Once you have included the parent pom.xml, you can include dependencies as follows:

<dependency>
        <groupId>org.opendaylight.controller</groupId>
        <artifactId>sal</artifactId>
</dependency>


Note:  you can find alternate commons.opendaylight versions in the following link

https://nexus.opendaylight.org/content/repositories/opendaylight.release/org/opendaylight/controller/commons.parent/ 

Best Regards,
Rob
Photo of Chandrasekaran, Arun

Chandrasekaran, Arun, Alum

  • 342 Points 250 badge 2x thumb
Thanks Rob. Could you tell me if you use just a single pom.xml file for your entire project? I want to know where I should place the parent pom info and I have a single pom file for my entire project. Your answer suggests you have a parent pom file and some module-related pom files that refer to the parent.

I thought specifying the parent pom info within my pom file would work (see below) but it does not.  Here is my pom file:

<project>
    <parent>      
        <groupId>org.opendaylight.controller</groupId>
        <artifactId>commons.opendaylight</artifactId>
        <version>1.4.2-Helium</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.odl.myapp</groupId>
    <artifactId>sampleapp</artifactId>
    <version>0.1</version>
 
<build>
....build config info goes here......      
</build>

</project>

I get an error with this file that says "...1.4.2-Helium in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 2, column 10"
Photo of Chandrasekaran, Arun

Chandrasekaran, Arun, Alum

  • 342 Points 250 badge 2x thumb
Never mind! I got it working by writing up my pom file in a different way.  My parent info in the file above is wrong.