Cilia/Getting Started Tutorial/Project Creation

From Wiki Adele Team
Jump to: navigation, search

Creating a new project

For building Cilia projects we use the Apache Maven project management software. Maven compiles the Java code, adds the appropriated metadata to the components and creates OSGi standard bundles (jar files). To have an idea about Maven you can follow the Maven in 5 minutes tutorial.

Project Structure

A Cilia project should follow this structure :

  src/java : java sources files of the project.
  src/resources/metadata.xml : Cilia descriptor file.
  pom.xml : maven script file.

A sample project structures is shown in next image:

Maven-structure.png

Sample Maven Script File

This file is used to describe the project, information to be used is:

  • identification : project name, version, type of packaging, etc.
  • repository : repository of artifacts to be used in compilation task.
  • dependencies : project dependencies, in Cilia project dependencies in Cilia Core and Cilia runtime are used suddenly.
  • build: the target platform of Cilia is OSGi, then the build process includes the maven-bundle-plugin and the maven-ipojo-plugin like they are used in this sample pom file.


<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
  xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>


  <!-- Project Identification -->
  <groupId>fr.liglab.adele.cilia</groupId>
  <artifactId>hello-mediator</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>bundle</packaging>
  <name>Hello Mediator</name>

  <!-- Repositories List -->
  <repositories>
    <repository>
      <id>maven-cilia-repository-release</id>
      <name>Cilia - Release</name>
      <url>http://repository-cilia.forge.cloudbees.com/release/</url>
      <layout>default</layout>
    </repository>
    <repository>
      <id>maven-cilia-repository-snapshot</id>
      <name>Cilia - Snapshot</name>
      <url>http://repository-cilia.forge.cloudbees.com/snapshot/</url>
      <layout>default</layout>
    </repository>
  </repositories>

  <!-- Dependencies Description-->
  <dependencies>
    <dependency>
      <groupId>fr.liglab.adele.cilia</groupId>
      <artifactId>cilia-core</artifactId>
      <version>CURRENT_VERSION</version>
    </dependency>
    <dependency>
      <groupId>fr.liglab.adele.cilia</groupId>
      <artifactId>cilia-runtime</artifactId>
      <version>CURRENT_VERSION</version>
    </dependency>
  </dependencies>

  <!-- Build Description-->
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>1.4.3</version>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
            <Private-Package>fr.liglab.adele.cilia.components.mediators,fr.liglab.adele.cilia.components.mediators.monitor</Private-Package>
          </instructions>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-ipojo-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
          <execution>
            <goals>
              <goal>ipojo-bundle</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

Project Build

To build a Cilia project with maven use this command in a OS console:

  mvn clean install

You can also use a pluging for your IDE as M2Eclipse.