我正在尝试使用maven-jdocbook-plugin和maven 3运行docbook。
使用最小配置:
<plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jdocbook-plugin</artifactId>
<executions>
<execution>
<id>default-cli</id>
<goals>
<goal>generate</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
<configuration>
<sourceDirectory>src/main/doc/xml</sourceDirectory>
<sourceDocumentName>DocBook.xml</sourceDocumentName>
<formats>
<format>
<formatName>html</formatName>
<finalName>index.html</finalName>
</format>
</configuration>
</plugin>
我收到以下错误:
[ERROR] Failed to execute goal org.jboss.maven.plugins:maven-jdocbook-plugin:2.3.8:generate (default-cli) on project <project>: Execution default-cli of goal org.jboss.maven.plugins:maven-jdocbook-plugin:2.3.8:generate failed: could not locate resource [/html/chunk.xsl] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jboss.maven.plugins:maven-jdocbook-plugin:2.3.8:generate (default-cli) on project <project>: Execution default-cli of goal org.jboss.maven.plugins:maven-jdocbook-plugin:2.3.8:generate failed: could not locate resource [/html/chunk.xsl]
当我查看我当地的maven存储库时,我看到:
$ ls ~/.m2/repository/net/sf/docbook/docbook-xsl
$ 1.76.1
$ ls ~/.m2/repository/net/sf/docbook/docbook-xsl/1.76.1
$ _maven.repositories docbook-xsl-1.76.1.pom docbook-xsl-1.76.1.pom.sha1
所以有一个POM但没有库。
如果我为docbook-xsl提供了明确的依赖关系,它会下载内容(但我仍然会收到同样的错误):
<dependency>
<groupId>net.sf.docbook</groupId>
<artifactId>docbook-xsl</artifactId>
<version>1.76.1</version>
<classifier>ns-resources</classifier>
<type>zip</type>
</dependency>
我实际生成任何东西的唯一方法是给它一个版本的docbook-xsl,它有一个jar而不是zip:
<groupId>net.sf.docbook</groupId>
<artifactId>docbook-xsl-ns</artifactId>
<version>1.74.0</version>
如何让XSL模板的zip版本与此插件一起使用?
答案 0 :(得分:1)
正如您自己所说,请输入zip类型的依赖项:
<dependencies>
<dependency>
<groupId>net.sf.docbook</groupId>
<artifactId>docbook-xsl</artifactId>
<version>1.76.1</version>
<classifier>ns-resources</classifier>
<type>zip</type>
</dependency>
</dependencies>
您需要做的就是使用合适的<stylesheetResource>
URI在maven-jdocbook-plugin中配置classpath:/
:
<format>
<formatName>html</formatName>
<stylesheetResource>classpath:/docbook/html/chunk.xsl</stylesheetResource>
</format>
答案 1 :(得分:0)
这是我自己的问题解决方案:
带有jar包装的docbook-xsl库(1.74.0)在运行时会自动包含在maven-jdocbook-plugin的类路径中。
带zip包装的版本(1.76.1)不是,需要手动解压缩。我使用了maven-dependency-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-docbook-xsl</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>net.sf.docbook</groupId>
<artifactId>docbook-xsl</artifactId>
<version>1.76.1</version>
<type>zip</type>
<classifier>ns-resources</classifier>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
然后我将maven-jdocbook-plugin指向此包中的样式表:
<formats>
<format>
<formatName>html</formatName>
<stylesheetResource>file:${project.build.directory}/docbook/html/chunk.xsl</stylesheetResource>
<finalName>index.html</finalName>
</format>
<format>
<formatName>pdf</formatName>
<stylesheetResource>file:${project.build.directory}/docbook/fo/docbook.xsl</stylesheetResource>
<finalName>${project.artifactId}-${project.version}.pdf</finalName>
</format>
<format>
<formatName>html_single</formatName>
<stylesheetResource>file:${project.build.directory}/docbook/html/docbook.xsl</stylesheetResource>
<finalName>index.html</finalName>
</format>
</formats>
我欢迎任何有关此过程的捷径的建议。