Maven assemble plugin in extensions

Hi there,

In order to package and distribute my own extension and install it on someone else’s OpenRefine installation, I use the maven-assembly-plugin with a simple config.

It simply creates a zip of the module folder and I wonder if that should be added to the sample extension in the main repo.

  • extension-zip.xml
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.1"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.1 http://maven.apache.org/xsd/assembly-2.1.1.xsd">
    <id>zip</id>
    <includeBaseDirectory>true</includeBaseDirectory>

    <formats>
        <format>zip</format>
    </formats>
    <fileSets>
        <fileSet>
            <directory>${project.basedir}/module</directory>
        </fileSet>
    </fileSets>
</assembly>
  • pom.xml:
  <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-assembly-plugin</artifactId>
      <executions>
          <execution>
              <phase>package</phase>
              <goals>
                  <goal>single</goal>
              </goals>
              <configuration>
                  <appendAssemblyId>false</appendAssemblyId>
                  <descriptors>
                      <descriptor>${project.basedir}/extension-zip.xml</descriptor>
                  </descriptors>
              </configuration>
          </execution>
      </executions>
  </plugin>

mvn package or mvn install then output the zip file which can be simply unpacked in an existing Refine installation.

wdyt?

Thanks for sharing!

I have also used similar a similar approach for various extensions. In general, if your module extends the backend, you will also need to make sure that either the build is configured to output the corresponding .class and .jar files appropriately in that module subdirectory, or you can include them at packaging time by extending the assembly definition.

I don’t know if the main repository is the best place to store those examples as such. I think they are more useful as part of a complete example with a pom.xml file and corresponding project structure. But surely it would be worth mentioning this in the documentation (with a pointer to a fully fledged example).

I think it would be nice to offer a Maven archetype for OpenRefine extensions - I am not super familiar with archetypes but I think they are designed precisely for use cases like this one.