0

Maven newbie...

I downloaded XSpec using git clone:

git clone https://github.com/xspec/xspec.git

I set the appropriate environment variables. XSpec seems to work fine.

For the Maven plugin, I am using: xspec-maven-plugin-1

To create a Maven project I opened a (Windows) command window and typed:

mvn -B archetype:generate -DgroupId=org.test.waypoints -DartifactId=waypoints -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4

That created a waypoints folder along with several subfolders.

I put an XSpec test (waypoints.xspec) in this folder: waypoints/src/test/xspec

I put my XSLT program (waypoints.xsl) in this folder: waypoints/src/main/xsl

I opened waypoints/pom.xml and added the plugin element shown below into build/pluginManagement/plugins.

The document at https://github.com/xspec/xspec-maven-plugin-1 says: Don't forget to add a dependency to your Saxon license. Question #1: How do I add a dependency to my Saxon license? My Saxon license is in this folder: C:\SAXON\saxon-license

I didn't know how to add that dependency but, nonetheless, I pushed ahead. I opened a command window in the folder containing pom.xml and typed:

mvn test

That didn't seem to do much. I got this message: Nothing to compile - all classes are up to date

Question #2: Should I be running some other Maven command prior to the test command?

Question #3: How does Maven know to use the XSpec code?

Question #4: Does the plugin element shown below look correct?

<plugin>
    <groupId>io.xspec.maven</groupId>
    <artifactId>xspec-maven-plugin</artifactId>
    <version>2.0.0</version>
    <dependencies>
        <dependency>
            <groupId>net.sf.saxon</groupId>
            <artifactId>saxon-ee</artifactId>
            <version>10.1</version>
        </dependency>
        <dependency>
            <groupId>io.xspec</groupId>
            <artifactId>xspec</artifactId>
            <version>1.6.0</version>
        </dependency>
    </dependencies>
    <configuration>
        <generateSurefireReport>true</generateSurefireReport>
        <saxonOptions></saxonOptions>
    </configuration>
    <executions>
        <execution>
            <phase>test</phase>
            <goals>
                <goal>run-xspec</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Roger Costello
  • 3,007
  • 1
  • 22
  • 43

1 Answers1

2

Q4 answer :

Your plugin definition is good. If it is under /project/build/plugins, nothing to add. But if it is under /project/build/pluginManagement/plugins, the plugin is only configured, but not declared. You have to declare it under /project/build/plugins/.

<project ...>
  <build>
    <pluginManagement>
      <plugins>
        <!-- your code you put previously in this thread -->
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>io.xspec.maven</groupId>
        <artifactId>xspec-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
</project>

Once plugin is declared, as it is bind (by the execution element) to the test phase, when mvn runs this test phase, it executes the xspec-maven-plugin.

Q3 answer :

xspec-maven-plugin, in its default configuration, knows that xspec files are under src/test/xspec. It looks for all files that match *.xspec pattern, and run the xspec suite on each of them.

xspec-maven-plugin, thru a dependency mechanism, knows where to get XSpec implementation (you've specified XSpec version in plugin dependencies), and it will get the xspec files from xspec implementation to run the xspec suite on each xspec file found in src/test/xspec.

Q2 answer :

No. mvn test is enough. Before running xspec-maven-plugin, all plugins bound to phase that are before test phase are executed. See Maven Lifecycle for more informations. If your /project/packaging is jar, then project lifecycle is the one described in previous link.

Q1 answer :

It depends !

  • I wrap my Saxon licence file in a jar file, and I put this jar file in my enterprise artifact repository. So, I have an artifact my.orga.saxon.license:ee:10.1 that I can add to my plugin dependencies, as you've done for xspec implementation. This allows me to avoid copy the licence file in all projects that use Saxon EE. If you want to do so, see Maven Install plugin or Maven deploy plugin
  • You can put your licence file in a place where it will be added to classpath. src/main/java or src/main/resources is a good place for this. I didn't test it (previous bullet for explanation), but it should work.

More...

The message you get, Nothing to compile... comes from Maven Lifecycle, where there is a compile phases, where java classes found under src/main/java are compiled. In a following phase, test-compile, java test classes located in src/test/java are compiled. Probably, I should define a xspec-compile goal in my plugin, to compile xspec files located in src/test/xspec at test-compile phase. Everything is done in a single goal. XSpec files are executed in test phase, where java unit test are executed.

If you need an example of a pure-XSL Maven project, with XSpec unit tests, you may have a look at Matthieu Ricaud XML Utilites Project, it uses xspec-maven-plugin, but here with Saxon-HE.

I have no Open Source project that uses XSpec with Saxon-EE, I'm sorry.

Hope this help. If you need more precisions, do not hesitate to ring me by private mail, I'll update this thread.

Christophe