Skip to content
Laurent Jourdren edited this page Apr 11, 2017 · 6 revisions

Maven simplify the management of project dependencies. It is not mandatory to use Maven for writing Eoulsan plug-in but it is quite harder without.

Creating a new project

  • First we generate the skeleton of our plugin with Maven.
$ mvn archetype:generate \
  -DarchetypeGroupId=org.apache.maven.archetypes \
  -DarchetypeArtifactId=maven-archetype-quickstart \
  -DgroupId=com.example \
  -DartifactId=myeoulsanplugin \
  -Dversion=0.1-alpha-1 \
  -Durl=http://example.com/eoulsanplugin \
  -DinteractiveMode=false
  • You will obtain the following files. Samples App.java and AppTest.java files will not be used in your plug-in. You can remove them but keep the com.example package folders.
eoulsanplugin
├── pom.xml
└── src
    ├── main
    │   └── java
    │       └── com
    │           └── example
    │               └── App.java
    └── test
        └── java
            └── com
                └── example
                    └── AppTest.java
  • Next edit the pom.xml at the root of the project to add the Eoulsan dependency and the ENS repository where Eoulsan dependency is available. We recommand to use JUnit 4.11 instead of JUnit 3.8.1. Don't forget to set the version of Eoulsan that you want to use:
  <repositories>
    <repository>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <id>ens</id>
      <name>ENS repository</name>
      <url>http://outils.genomique.biologie.ens.fr/maven2</url>
    </repository>
  </repositories>
        
  <dependencies>
    <dependency>
      <groupId>fr.ens.transcriptome</groupId>
      <artifactId>eoulsan</artifactId>
      <version>2.0-alpha7</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  • In the pom.xml add also a build section to set the compilation mode to java 7 and set the path of the java resources. The src/main/java/files folder is where the developer put resource files (e.g. binaries, R script...) and the src/main/java/META-INF directory is for the metadata of your plug-in.
  <build>
    <resources>
      <resource>
        <directory>src/main/java/files</directory>
      </resource>
      <resource>
        <directory>src/main/java/META-INF</directory>
        <targetPath>META-INF</targetPath>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
    </plugins>
  </build>

Create Eclipse project file from Maven

  • Now you can generate an eclipse project with :
$ mvn eclipse:eclipse  -DdownloadSources=true -DdownloadJavadocs=true
  • A warning message may appear if some source or javadoc dependencies cannot be found.
  • To import the project in Eclipse, go to File > Import... > General > Existing projects into Workspace and select the root directory of the myeoulsanplugin project. By clicking on the finish button, myeoulsanlugin will be imported into Eclipse workspace.

Compile your project with Maven

The compilation is quite simple, at the root of your project launch:

$ mvn clean install

This command line will clean the target directory before lauching the compilation. You will obtain a myeoulsanplugin-0.1-alpha-1.jar jar archive that contains your plug-in in the target directory

Creating documentation for your plug-in

With Maven it is quite easy create a website for your plugin. Go to the Maven site documentation to see how to write it. Once your documentation files are ready, you can generate it with the next command line:

$ mvn site

Installing your plug-in

To install an Eoulsan plugin, you just have to copy the generated jar file from the target directory of your project to the lib directory of your Eoulsan installation. Your plug-in is now ready to use.