Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Tuesday, 22 October 2013

Basic pom.xml file for building a bundle in Open DayLight

Maven is something like makefile in linux. Maven helps in compilation. when you say 'mvn install' it reads the pom.xml file. pom.xml have various tags essential tags for creating basic pom.xml are as below. Please note i have put comments between <!-- --> which is standard xml comment tag.
pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

<!-- Do not change above lines. They provide xml version and maven version info -->
    <parent>
<!-- Everything inside this tab is your parents, i.e on top of which you will make your application   --> 
    <groupId>org.opendaylight.controller</groupId>
    <!-- its the project where your parent is located-->
    <artifactId>commons.opendaylight</artifactId>
    <!-- Parent application name-->
    <version>1.4.0-SNAPSHOT</version>
    <!-- Parents version-->
    <relativePath>../../commons/opendaylight</relativePath>
    <!-- Path where parent pom file is located-->
  </parent>
  <scm>
    <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
    <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
    <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main</url>
  </scm>
    <!-- Everything inside scm tag is for version controlling you can delete this tag if you want-->

  <artifactId>samples.userinfo</artifactId>
  <!-- this is your application name.  -->
  <version>0.0.1-SNAPSHOT</version>
  <!-- Your application version.  -->

  <packaging>bundle</packaging>
  <!-- Tells maven you want to create OSGi bundle.   -->


  <build>
  <!-- Information on how to build the code-->
    <plugins>
      <plugin>
      <!-- Info on which plugin to use from maven   -->
        <groupId>org.apache.felix</groupId>
        <!-- Project name for that plugin-->
        <artifactId>maven-bundle-plugin</artifactId>
        <!-- Kind of obvious we are making an OSGi bundle-->
        <version>2.3.6</version>
        <!-- Plugins option-->
        <extensions>true</extensions>
        <!-- Use extension for this project-->
        <configuration>
          <instructions>
            <Import-Package>
              org.opendaylight.controller.sal.core,
              org.slf4j,
            </Import-Package>
            <!-- Which package to import for building the code-->
            <Export-Package>
              org.opendaylight.controller.samples.userinfo
            </Export-Package>
          <!-- Name of the package, which will be exported-->
            <Bundle-Activator>
              org.opendaylight.controller.samples.userinfo.internal.Activator
            </Bundle-Activator>
           <!-- Address where OSGi activator is located -->


          </instructions>
          <manifestLocation>${project.basedir}/META-INF</manifestLocation>
           <!-- Address of OSGi META file -->
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
  <!-- Dependencies on exiting code>
    <dependency>
      <groupId>org.opendaylight.controller</groupId>
      <artifactId>sal</artifactId>
      <version>0.5.0-SNAPSHOT</version>
    </dependency>
  </dependencies>
</project>

For more information on how to make a simple application in open daylight controller click here

Tuesday, 15 October 2013

Create a symbolic link in linux

Well I was working on this project and so happens my development directory and deployment directory (where i compile the code) are different. Now its not possible every time to go back and forth and copy my development one into deployment. So i will create a symbolic link between them. For those who are new to term symbolic link; its a file which has the reference( an address to reach to original file) of linked file.Yes something what windows calls a shortcut file.
To create a symbolic link, just say

ln -s [source; in my case development dir]  [target; deployment dir]

Note: Linux will not create hard link between directories. So if you have created a directory as target; simply delete it and give just the name instead.

Adding some more point.There are two types of links - Symbolic link and Hard link. Hard link actually points to the physical data i.e. location where it is stored on disk. Symbolic links refer to just path of the file. So if you delete the original file symbolic link will go, but hard links will stay as it is.

To create hard link just say 'ln' no '-s' in option.