Skip to content

echebbi/kazejiyu-tycho-archetype

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tycho Archetype

Build Status Download

A Maven Archetype that can be used to generate the architecture of a Tycho project.

Sample project

This repository contains a sample project that can be looked up to see how a project generated by this archetype looks like.

Usage

As any other archetype, the Tycho Archetype can be used from the command line. It is identified by the following properties:

Property Value
Group ID fr.kazejiyu.maven.archetypes
Artifact ID kazejiyu-tycho-archetype
Version (see Bintray badge above)

Type the following command to use the archetype and to start the generation of a new project:

mvn archetype:generate -DarchetypeGroupId=fr.kazejiyu.maven.archetypes -DarchetypeArtifactId=kazejiyu-tycho-archetype -DarchetypeRepository=https://dl.bintray.com/kazejiyu/maven

You can alternatively clone this repository then install the archetype in your local installation by typing mvn install

Generated files

The archetype follows Lars Vogel advices on how a Tycho project should be structured. More specifically, it generates the following architecture:

│   pom.xml
│
├───.mvn
│       extensions.xml
│
├───bundles
│       pom.xml
│
├───features
│       pom.xml
│
├───releng
│   │   pom.xml
│   │
│   ├───<artifactId>.releng.p2
│   │       .project
│   │       category.xml
│   │       pom.xml
│   │
│   └───<artifactId>.releng.targetplatform
│           .project
│           <artifactId>.releng.targetplatform.target
│           pom.xml
│
└───tests
        pom.xml

Use the generated project

Table of Contents

Note: please take a look at the Wiki for further explanations on how to use the generated project

Build the project

The generated project can be built with Maven via mvn clean package.

Create a plug-in

Location

All the plug-ins should be located under the bundles/ folder. For instance, adding a fr.kazejiyu.foo.core plug-in to the project would result in the following tree structure:

.
├───bundles
│   │   pom.xml
│   └───fr.kazejiyu.foo.core
│       │   .classpath
│       │   .project
│       │   build.properties
│       ├───.settings
│       │       org.eclipse.jdt.core.prefs
│       ├───bin
│       ├───META-INF
│       │       MANIFEST.MF
│       └───src

Add to Maven build

In order to be taken into account by Maven, the plug-in must be added as a sub-module of the bundles module. To this end, the bundles/pom.xml must be enhanced with a <module> tag as follows:

<?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>
	
	<groupId>fr.kazejiyu.foo</groupId>
	<artifactId>fr.kazejiyu.foo.bundles</artifactId>
	<packaging>pom</packaging>
	
        ...
        
        <modules>
                <module>fr.kazejiyu.foo.core</module>
        </modules>    
</project>

Create a test plug-in

Location

All the test plug-ins should be located under the tests/ folder. For instance, adding a fr.kazejiyu.foo.core.tests plugin-in to the project would result in the following tree structure:

.
└───tests
    │   pom.xml
    └───fr.kazejiyu.foo.core.tests
        │   .classpath
        │   .project
        │   build.properties
        │   pom.xml
        ├───.settings
        │       org.eclipse.jdt.core.prefs
        ├───META-INF
        │       MANIFEST.MF

Add to Maven build

In order to be taken into account by Maven, the plug-in must be added as a sub-module of the tests module. To this end, the tests/pom.xml must be enhanced with a <module> tag as follows:

<?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>
	
	<groupId>fr.kazejiyu.piou</groupId>
	<artifactId>fr.kazejiyu.foo.tests</artifactId>
	<packaging>pom</packaging>
	
        ...
        
        <modules>
                <module>fr.kazejiyu.foo.core.tests</module>
        </modules>    
</project>

Moreover, a pom.xml must be added to the fr.kazejiyu.foo.core.tests folder ; its aim is to indicate to Tycho that the plug-in holds tests. This file looks like:

<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/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
    <groupId>fr.kazejiyu.piou</groupId>
    <artifactId>fr.kazejiyu.foo.core.tests</artifactId>
    <packaging>eclipse-test-plugin</packaging>

	<parent>
		<groupId>fr.kazejiyu.foo</groupId>
		<artifactId>fr.kazejiyu.foo.tests</artifactId>
		<version>1.0.0-SNAPSHOT</version>
	</parent>
</project>

Note: the important thing here is the eclipse-test-plugin packaging.

Execute the tests

The tests can be executed with mvn verify.

/!\ Caution: don't forget to add the org.junit and its dependencies to the target platform, otherwise the Maven build will fail. JUnit plug-ins can be found in the Orbit repository.

Create a feature

Location

All the features should be located under the features/ folder. For instance, adding a fr.kazejiyu.foo.feature plug-in to the project would result in the following tree structure:

.
├───features
│   │   pom.xml
│   └───fr.kazejiyu.foo.feature
│           .project
│           build.properties
│           feature.xml

Add to Maven build

In order to be taken into account by Maven, the plug-in must be added as a sub-module of the features module. To this end, the features/pom.xml must be enhanced with a <module> tag as follows:

<?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>
	
	<groupId>fr.kazejiyu.foo</groupId>
	<artifactId>fr.kazejiyu.foo.features</artifactId>
	<packaging>pom</packaging>
	
        ...
        
        <modules>
                <module>fr.kazejiyu.foo.feature</module>
        </modules>    
</project>

Configure the dependencies

The dependencies of a project should be managed through the use of a target platform. The archetype automatically generates an empty one called:

  • releng/<artifactId>.releng.targetplatform/<artifactId>.releng.targetplatform.target.

Since Tycho uses this target platform to configure Maven build, you should update this file each time your project requires a new dependency.

Generate an update site

Define the update site

Through p2 update sites, you can provide your users an easy way to download your plug-ins. The archetype automatically defines an empty one with:

  • releng/<artifactId>.releng.p2/category.xml.

This file can be modified from Eclipse IDE in order to add new features to the update site.

Update Tycho build

In order to tell Tycho to generate an update site, the releng/<artifactId>.releng.p2/pom.xml file must be modified to specify the right packaging :

<?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>
	
	<groupId>fr.kazejiyu.foo</groupId>
	<artifactId>fr.kazejiyu.foo.releng.p2</artifactId>
	<packaging>eclipse-repository</packaging>
    
	<parent>
		<groupId>fr.kazejiyu.foo</groupId>
		<artifactId>fr.kazejiyu.foo.releng</artifactId>
		<version>1.0.0-SNAPSHOT</version>
	</parent>
	
</project>

Note: by default, the line <packaging>eclipse-repository</packaging> is commented because Tycho build fails when trying to generate an empty update site.

Generate the update site

The command mvn package generates a functional update site in:

  • releng/<artifactId>.releng.p2/target/repository