3

我试图让 Maven 在 WAR 中的一个有用位置组装一个带有 BIRT 运行时的 WAR。

BIRT 运行时位于 pom.xml 中

<dependency>
  <groupId>org.eclipse.birt</groupId>
  <artifactId>report-engine</artifactId>
  <version>2.3.2</version>
  <type>zip</type>
  <scope>runtime</scope>
</dependency>

覆盖它的期望结果类似于

ReportEngine/lib/*           -> WEB-INF/lib 
ReportEngine/configuration/* -> WEB-INF/platform/configuration 
ReportEngine/plugins/*       -> WEB-INF/platform/plugins 

我的覆盖配置看起来像

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <overlays>
      <overlay>
        <groupId>org.eclipse.birt</groupId>
        <artifactId>report-engine</artifactId>
        <type>zip</type>
        <includes>
          <include>ReportEngine/lib/*</include>
        </includes>
        <targetPath>WEB-INF/lib</targetPath>
      </overlay>
      <overlay>
        <groupId>org.eclipse.birt</groupId>
        <artifactId>report-engine</artifactId>
        <type>zip</type>
        <includes>
          <include>ReportEngine/configuration/*</include>
          <include>ReportEngine/plugins/*</include>
        </includes>
        <targetPath>WEB-INF/platform</targetPath>
      </overlay>
    </overlays>
  </configuration>
</plugin>

当然,跑步时mvn war:exploded我看到

ReportEngine/lib/*           -> WEB-INF/lib/ReportEngine/lib/ 
ReportEngine/configuration/* -> WEB-INF/platform/configuration/ReportEngine/lib/ 
ReportEngine/plugins/*       -> WEB-INF/platform/plugins/ReportEngine/lib/

这涉及到同样的问题,没有答案 http://www.coderanch.com/t/447258/Ant-Maven-Other-Build-Tools/Maven-war-dependencies-moving-files

指出我如何通过让这一切都从内部工作来稍微整理一下的奖励积分WEB-INF/birt-runtime

编辑:

上面指定位置的原因是它们与http://wiki.eclipse.org/Servlet_Example_%28BIRT%29_2.1中指示的位置相匹配,当我使用 Tomcat 安装来模仿这一点时,一切似乎都有效。如果我可以简单地将 zip 覆盖到 WEB-INF/birt-runtime 中,然后适当地设置引擎配置,那将是理想的,但我还没有发现它可以工作。

例如:

engineConfig = new EngineConfig();
engineConfig.setEngineHome("WEB-INF/birt-runtime");
engineConfig.setPlatformContext(new PlatformServletContext(servletContext));
4

2 回答 2

1

更新:在重新阅读问题时,我意识到我错过了测试项目中的子目录,所以它当然对我有用,对此感到抱歉。

据我所知,战争覆盖或依赖插件中不存在将工件的子文件夹解压缩到目录并排除路径的父元素的机制,两者都会为您提供完整的相对路径。

但是,您可以使用 unpack 目标将存档解压缩到一个临时文件夹,然后使用antrun-plugin将所需的子文件夹复制到它们的最终存放位置。

以下配置可以做到这一点(我还没有测试过,如果有任何遗漏,请参阅文档以获取详细信息)。请注意,执行处于同一阶段,但只要在 antrun-plugin 之前配置了依赖插件,它将首先执行。注意,prepare-package 对于 Maven 2.1 来说是新的,如果你使用的是旧版本,你需要使用另一个阶段。

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <id>unpack-lib</id>
      <phase>prepare-package</phase>
      <goals>
        <goal>unpack</goal>
      </goals>
      <configuration>
        <artifactItems>
          <artifactItem>
            <groupId>org.eclipse.birt</groupId>
            <artifactId>report-engine</artifactId>
            <version>2.3.2</version>
            <type>jar</type>
            <overWrite>false</overWrite>
          </artifactItem>
        </artifactItems>
        <!--unpack all three folders to the temporary location-->
        <includes>ReportEngine/lib/*,ReportEngine/configuration/*,ReportEngine/plugins/*</includes>
        <outputDirectory>${project.build.directory}/temp-unpack</outputDirectory>
        <overWriteReleases>false</overWriteReleases>
      </configuration>
    </execution>
  </executions>
</plugin>
  <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
      <execution>
        <phase>prepare-package</phase>
        <configuration>
          <tasks>
            <!--now copy the configuration and plugin sub-folders to WEB-INf/platform-->
            <copy todir="${project.build.directory}/WEB-INF/platform">
              <fileset dir="${project.build.directory}/temp-unpack/ReportEngine/configuration"/>
              <fileset dir="${project.build.directory}/temp-unpack/ReportEngine/plugins"/>
            </copy>
            <!--copy the lib sub-folder to WEB-INf/lib-->
            <copy todir="${project.build.directory}/WEB-INF/lib">
              <fileset dir="${project.build.directory}/temp-unpack/ReportEngine/lib"/>
            </copy>
          </tasks>
        </configuration>
        <goals>
          <goal>run</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
于 2009-08-26T15:11:42.870 回答
0

没有真正回答我自己的问题,回复上面的 Rich Seller :)

试图让这个工作mvn dependency:unpack,文档说把它从执行节点中取出。不确定这是否是结果的原因,但最终结果是

WEB-INF/lib/ReportEngine/lib
WEB-INF/platform/ReportEngine/configuration
WEB-INF/platform/ReportEngine/plugins

与我最初的战争插件尝试基本相同。我在文档中没有看到任何需要 depedency-unpack 提供帮助的内容。我会再试一次tmrw。

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>

      <configuration>
        <artifactItems>
          <artifactItem>
            <groupId>org.eclipse.birt</groupId>
            <artifactId>report-engine</artifactId>
            <version>2.3.2</version>
            <type>zip</type>
            <overWrite>false</overWrite>
            <!--may not be needed, need to check-->
            <outputDirectory>${project.build.directory}/WEB-INF/lib</outputDirectory>
            <includes>ReportEngine/lib/*</includes>
          </artifactItem>

          <artifactItem>
            <groupId>org.eclipse.birt</groupId>
            <artifactId>report-engine</artifactId>
            <version>2.3.2</version>
            <type>zip</type>
            <overWrite>false</overWrite>
            <!--may not be needed, need to check-->
            <outputDirectory>${project.build.directory}/WEB-INF/platform</outputDirectory>
            <includes>ReportEngine/configuration/*,ReportEngine/plugins/*</includes>
          </artifactItem>
        </artifactItems>
      </configuration>
</plugin>
于 2009-08-26T15:42:57.110 回答