美文新手..。
我使用git克隆下载了XSpec:
git clone https://github.com/xspec/xspec.git我设置了适当的环境变量。XSpec似乎工作得很好。
对于Maven插件,我使用的是:xspec-maven-plugin-1
为了创建Maven项目,我打开了一个(Windows)命令窗口并键入:
mvn -B archetype:generate -DgroupId=org.test.waypoints -DartifactId=waypoints -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4它创建了一个waypoint文件夹和几个子文件夹。
我在这个文件夹中放置了一个XSpec测试(waypoints.xspec):waypoints/src/test/xspec
我将我的XSLT程序(waypoints.xsl)放在这个文件夹中:waypoints/src/main/xsl
我打开了waypoint/头.xml,并将下面显示的插件元素添加到build/pluginManagement/plugins中。
https://github.com/xspec/xspec-maven-plugin-1的文档说:不要忘记向您的Saxon许可证添加依赖项。问题1:如何向我的Saxon许可证添加依赖项?我的Saxon许可证在这个文件夹中:C:\saxon\saxon-许可证
我不知道如何增加这种依赖性,但是,尽管如此,我还是继续前进。我在包含pom.xml的文件夹中打开了一个命令窗口,并键入:
mvn test这似乎没什么用。我收到一条消息:Nothing to compile - all classes are up to date
问题2:我应该在test命令之前运行其他Maven命令吗?
问题3: Maven如何知道如何使用XSpec代码?
问题4:下面显示的插件元素看起来正确吗?
<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>发布于 2020-11-17 21:58:05
Q4回答:
你的插件定义很好。如果它在/project/build/plugins下,就没有什么可添加的了。但是,如果它是在/project/build/pluginManagement/plugins下,插件只是配置,而不是声明。你必须在/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>一旦声明了插件(由execution元素绑定到test阶段),当mvn运行此测试阶段时,它将执行xspec-maven-plugin。
Q3回答:
xspec-maven-plugin在其默认配置中知道xspec文件在src/test/xspec下。它查找与*.xspec模式匹配的所有文件,并在每个文件上运行xspec套件。
xspec-maven-plugin通过依赖机制知道在哪里获得XSpec实现(您已经在插件依赖项中指定了XSpec版本),它将从xspec实现中获取xspec文件,以便在src/test/xspec中找到的每个xspec文件上运行xspec套件。
Q2回答:
不是的。mvn test就够了。在运行xspec-maven-plugin之前,所有绑定到test阶段之前的插件都会被执行。有关更多信息,请参见Maven生命周期。如果您的/project/packaging是jar,那么项目生命周期就是前面的链接中描述的。
Q1回答:
要看情况了!
my.orga.saxon.license:ee:10.1,可以添加到插件依赖项中,就像您为xspec实现所做的那样。这允许我避免在所有使用Saxon的项目中复制许可文件。如果您想这样做,请参阅Maven安装插件或Maven部署插件src/main/java或src/main/resources是一个很好的地方。我没有测试它(之前的子弹是用来解释的),但它应该能工作。更多...
您得到的消息,Nothing to compile...来自Maven生命周期,其中有一个compile阶段,其中编译了src/main/java下的java类。在接下来的阶段中,编译位于test-compile中的src/test/java、java测试类。也许,我应该在插件中定义一个xspec-compile目标,在test-compile阶段编译位于src/test/xspec中的xspec文件。每件事都是在一个目标内完成的。XSpec文件在test阶段执行,其中java单元测试被执行。
如果您需要一个使用XSpec单元测试的纯XSL Maven项目的示例,您可能会看到Matthieu Ricaud XML Utilites项目,它使用xspec-maven-plugin,但这里使用的是Saxon。
我没有开源项目,使用XSpec与撒克逊-EE,我很抱歉。
希望能帮上忙。如果您需要更多的精度,请不要犹豫通过私人邮件给我打电话,我会更新这个线程。
克利斯朵夫
https://stackoverflow.com/questions/64880813
复制相似问题