Using Faktor-IPS Projects as Maven Dependencies

Motivation

In many Java projects, Maven is used as a build tool and for dependency management. Therefore, it also makes sense to use Maven to map the dependencies between Faktor-IPS projects.

Settings

First of all, you need to copy some settings from the .ipsproject file into the manifest (META-INF/MANIFEST.MF) in all Faktor-IPS projects that are to be referenced by Maven. The settings are described in the
Documentation on using Faktor-IPS projects as OSGi bundles, in the META.INF/MANIFEST.MF section(German only).

Then in the .ipsproject file of all the referenced Faktor-IPS projects the IpsObjectPath should be adjusted. Instead of the previously referenced projects, an entry for the Maven-Classpath-Container has to be provided:

<Entry container="JDTClasspathContainer" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER" reexported="false" type="container"/>

In addition, some settings in Maven are recommended, so that all the built JARs contain the required information.

  • The model or product folders should be added as resources unless they are in the usual Maven structure:
    <resource>
        <directory>model</directory>
        <targetPath>model</targetPath>
    </resource>
    
  • If the source code for the formulas is generated, then Maven must contain instruction to build it in the derived folder:
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
            <execution>
                <id>add-source</id>
                <phase>generate-sources</phase>
                <goals><goal>add-source</goal></goals>
                <configuration>
                    <sources><source>${project.basedir}/derived</source></sources>
                </configuration>
            </execution>
        </executions>
    </plugin>
    
  • The handwritten MANIFEST must be used by Maven:
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
            <execution>
                <id>default-jar</id>
                <phase>package</phase>
                <goals>
                    <goal>jar</goal>
                </goals>
                <configuration>
                <archive>
                    <addMavenDescriptor>false</addMavenDescriptor>
                    <manifestFile>META-INF/MANIFEST.MF</manifestFile>
                </archive>
                </configuration>
            </execution>
        </executions>
    </plugin>
    

Faktor-IPS-Build with Maven

If you would like to check the artifacts built by Faktor-IPS in Eclipse and use them in Maven bundles, and also run the Faktor-IPS-Build for example on a build server, you can use the Maven plugin Tycho along with a headless Eclipse. Please do not hesitate to contact us if you have any questions. For a custom Maven plugin which simplifies this step, we are currently looking for customers who want to participate in the development.