Wiki

Clone wiki

Okapi / PortingEclipseStructureToMaven

For Those without Patience

  • If a parent pom (steps, framework, filters, etc...) does not exist in the appropriate directory, then create one like so - this is a POM project that produces no compiled code:
    <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">
       <parent>
          <artifactId>build-okapi</artifactId>
          <groupId>net.sf.okapi</groupId>
          <version>1.0.0</version>
       </parent>
       <artifactId>build-{DIRECTORY NAME}</artifactId>
       <packaging>pom</packaging>
       <modelVersion>4.0.0</modelVersion>
       <name>Okapi {DIRECTORY NAME} Build</name>
       <modules>
           <module>{CHILD DIRECTORY NAME}</module>
           <module>filters</module>
           <!--... etc ...-->
       </modules>
    </project>
    
  • Change all {} with something valid

  • Create a src/main/java directory in the module
  • Move all source code into the new directory, creating src/main/java/net/sf ...
  • Move all non-java files from the src/main/java... directory to the src/main/resources directory, either keeping the same directory structure (package) or changing the code to load from "/"
  • Create a src/test/java directory
  • Copy all of the test code from the test module into this directory, creating /src/test/java/net/sf...
  • Move all non-java files from the src/test/java... directory to the src/test/resources directory, either keeping the same directory structure (package) or changing the code to load from "/". i.e. change ....class.loadResource("some-file.xsl") to .class.loadResource("/some-file.xsl") (if you want to).
  • Copy the following pom.xml contents in your module-directory/pom.xml file.
    <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">
       <parent>
          <artifactId> (CHANGE ME) parent-artifact-id</artifactId>
          <groupId>net.sf.okapi</groupId>
          <version>1.0.0</version>
       </parent>
       <modelVersion>4.0.0</modelVersion>
       <!--Should match the directory name-->
       <artifactId> (CHANGE ME) module-artifact-id</artifactId>
       <!--Used for display purposes only-->
       <name> (CHANGE ME) Artifact Display Name</name>
       <dependencies>
          <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId> (CHANGE ME or REMOVE ME) common.filters</artifactId>
            <version>${project.version}</version>
          </dependency>
       </dependencies>
       <build>     
         <plugins>
             <plugin>
               <artifactId>maven-jar-plugin</artifactId>
               <configuration>
                  <!--All JAR projects will have this same configuration -->
                  <!-- This projects generated JAR will look like: net.sf.okapi.common.pipeline-1.0.0.jar -->
                  <finalName>${pom.groupId}.${pom.artifactId}-${pom.version}</finalName>
               </configuration>
             </plugin>
         </plugins>
      </build>
    </project>
    
  • Change the fields that say CHANGEME
  • Type "mvn test" into the command line and verify successful build

Updated