0

我正在尝试使用 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 版本以使用此插件?

4

2 回答 2

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>使用合适的classpath:/URI 在 maven-jdocbook-plugin 中配置:

<format>
  <formatName>html</formatName>
  <stylesheetResource>classpath:/docbook/html/chunk.xsl</stylesheetResource>
</format>
于 2013-10-10T10:34:25.973 回答
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>

我欢迎任何有关此过程的捷径的建议。

于 2013-07-15T00:57:14.263 回答