Using wf-build-plugin

wf-build-plugin is a custom Maven plug-in intended to carry out Widget Framework-specific tasks during the publication build process. It is not used in the standard build process, but you can make use of it by adding configuration elements to your publication POM file.

Currently wf-build-plugin has only one goal, xslt, which is designed to modify XML files (primarily Escenic publication resources) by executing a series of one or more XSL transformations. The xslt goal must be bound either to Maven's package phase or to a phase that runs after the package phase in the Maven build life-cycle.

In order to use wf-build-plugin to modify one of your publication resource files, you need to:

  • Write one or more XSL transformations that will make the changes you require.

  • Save the transformations somewhere in your project.

  • Add the necessary executions to the wf-build-plugin configuration in your publication POM file.

Two sample XSL transformations are included with the demo publication (in the demo/src/main/resources/xsl folder):

sort-groups-alphabetically.xsl

Gathers together all ui:group elements and sorts them alphabetically by their ui:label element.

filter-content-type.xsl

Removes duplicate content-type, field-group relation-type-group and ui:group elements.

So you could, for example, sort the ui:group elements in the demo publication's content-type resource by adding the following to the wf-build-plugin configuration in the publication's POM file:

<plugin>
  <groupId>com.escenic.widget-framework</groupId>
  <artifactId>wf-build-plugin</artifactId>
  <version>${wf.version}</version>
  <executions>
    <execution>
      <id>run-xslt</id>
      <goals>
        <goal>xslt</goal>
      </goals>
      <phase>package</phase>
      <configuration>
        <xsltJobs>
          <xsltJob>
            <resource>
              META-INF/escenic/publication-resources/escenic/content-type
            </resource>
            <transformers>
              <transformer>
                src/main/resources/xsl/sort-groups-alphabetically.xsl
              </transformer>
            </transformers>
          </xsltJob>
        </xsltJobs>
      </configuration>
    </execution>
  </executions>
</plugin>

wf-build-plugin has only one configuration element, xsltJobs. xsltJobs may contain one or more xsltJob elements, each of which must contain:

  • A resource element containing the path of the XML file to be processed.

  • A transformers element containing a sequence of one or more transformer, each of which contains the path of an XSL transformation to be applied to the resource.

If several transformer elements are present then they are applied in sequence, with the output from the first transformation being passed into the second and so on. So you could remove duplicates from the demo publication's content-type resource as well by adding another transformer element as follows:

<configuration>
  <xsltJobs>
    <xsltJob>
      <resource>
        META-INF/escenic/publication-resources/escenic/content-type
      </resource>
      <transformers>
        <transformer>
          src/main/resources/xsl/sort-groups-alphabetically.xsl
        </transformer>
        <transformer>
          src/main/resources/xsl/filter-content-type.xsl
        </transformer>
      </transformers>
    </xsltJob>
  </xsltJobs>
</configuration>

If you want to process more than one XML file in this way, then you can do so by adding multiple xsltJob elements, one for each file.