Search code examples
javamavenjenaontologyschemagen

Jena schemagen in maven processing multiple ontologies


I am working on a project which uses multiple ontologies defined over several files. I am hoping to use Jena to generate the java classes to help with development but I can't seem to find a way to have Jena process multiple files as a maven goal.

I have never used Jena through maven before but I have used it on the command line (never for multiple ontologies at the same time).

The relevant part of my pom.xml is listed below (this was largely copied from the Jena website):

<plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>java</goal>
                    </goals>
                    <configuration>
                        <mainClass>jena.schemagen</mainClass>
                        <commandlineArgs>
                            --inference \
                            -i ${basedir}/src/main/resources/ontologies/exception.owl \
                            --package com.borwell.dstl.mexs.ontology \
                            -o ${project.build.directory}/generated-sources/java \
                        </commandlineArgs>
                        <commandlineArgs>
                            --inference \
                            -i ${basedir}/src/main/resources/ontologies/location.owl \
                            --package com.borwell.dstl.mexs.ontology \
                            -o ${project.build.directory}/generated-sources/java \
                        </commandlineArgs>
                    </configuration>
                </execution>
            </executions>
        </plugin>
</plugins>

I have had a good look around on the Jena website and other sites (my googlefoo is usually quite good) but I have been unable to find anyone else having this problem or any documentation explaining how to do this. Any help on this would be very useful.


Solution

  • After more generalised searching and thanks to DB5 I have found the solution to be multiple executions. I was hoping for a more elegant solution but this does work.

    Credit to DB5