Skip to content

APAM project creation

snybril edited this page Jun 25, 2013 · 8 revisions

For building APAM 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.

Table of Contents

Project Structure

An APAM project should follow this structure:

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

A sample project structure is shown in next image:

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 (if needed)
  • build: the target platform of APAM is OSGi, then the build process includes the maven-bundle-plugin and the apam-maven-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.imag.adele.apam</groupId>
  <artifactId>hello-world</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>bundle</packaging>
  <name>Hello World Specification</name>
 
  <!-- Repositories List -->
  <pluginRepositories>
    <pluginRepository>
      <id>apam-plugin-repository</id>
      <url>https://repository-apam.forge.cloudbees.com/release/repository/</url>
      <snapshots>
	<enabled>true</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>
 
  <!-- Dependencies Description-->
  <dependencies>
  </dependencies>
 
  <!-- Build Description-->
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>2.3.7</version>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>          
            <Export-Package>fr.imag.adele.apam.hello.world.spec</Export-Package>
          </instructions>
        </configuration>
      </plugin>
      <plugin>
	<groupId>fr.imag.adele.apam</groupId>
	<artifactId>apam-maven-plugin</artifactId>
        <version>0.0.1</version>
	  <executions>
	    <execution>
	      <goals>
		<goal>apam-bundle</goal>
	      </goals>
	    </execution>
	</executions>
      </plugin>
    </plugins>
  </build>
</project>

Sample APAM descriptor file

This file provides APAM component description using the APAM DSL language. This description provide information about specification and/or implementation and/or instance.

Sample empty src/main/resources/metadata.xml:

<apam xmlns="fr.imag.adele.apam" xmlns:ipojo="org.apache.felix.ipojo"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xsi:schemaLocation="fr.imag.adele.apam http://repository-apam.forge.cloudbees.com/release/schema/ApamCore.xsd" >

  <!-- To be completed accordingly to the APAM Component Model -->

</apam>

Project Build

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

 mvn clean install

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

HOME > TECHNICAL DOCUMENTATION

1. [GETTING STARTED] (APAM-getting-started)
Syntax
Commands
Creating a Project
Creating Components
Creating Composites
[Using OBRMan] ()

2. [ADVANCED TOPICS] (APAM-advanced-topics)
Developing Dependency Managers
Developing Dynamic Managers
Providing APAM services using iPOJO
Using iPOJO Dependency Handler

3. [TUTORIALS] (APAM-tutorials)
APAM versus OSGi
iCASA simulation

4. [DEVELOPERS] (Developers)
Performing release


Clone this wiki locally