代码之家  ›  专栏  ›  技术社区  ›  ptomli

将BIRT运行时覆盖到正确的战争位置

  •  3
  • ptomli  · 技术社区  · 16 年前

    我正试图让Maven在战争中的一个有用位置用BIRT运行库来组装一场战争。

    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运行时中,然后适当地设置引擎配置,这将是理想的选择,但是我还没有发现它可以工作。

    如:

    engineConfig = new EngineConfig();
    engineConfig.setEngineHome("WEB-INF/birt-runtime");
    engineConfig.setPlatformContext(new PlatformServletContext(servletContext));
    
    2 回复  |  直到 16 年前
        1
  •  1
  •   Rich Seller    16 年前

    更新:在重读这个问题时,我意识到我遗漏了我的测试项目中的子目录,所以它当然对我有效,对此我感到抱歉。

    据我所知,在war overlay或依赖插件中都没有将工件的子文件夹解包到目录并排除路径的父元素的机制,这两者都将为您提供完整的相对路径。

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

    下面的配置就是这样做的(我还没有对此进行测试,所以如果有任何遗漏,请参阅文档了解确切的细节,非常抱歉)。注意,执行处于同一阶段,但是只要在Antrun插件之前配置了依赖插件,就可以首先执行它。注意,准备包对于Maven2.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>
    
        2
  •  0
  •   ptomli    16 年前

    没有真正回答我自己的问题,回答上面的富有卖家:)

    试着让这个工作 mvn dependency:unpack 文档说要将其从“执行”节点中删除。不确定这是否是导致结果的原因,但最终结果是

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

    基本上与我最初的战争插件尝试相同。 我看不到任何文件中的代普登西解包协助。我再试试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>
    
    推荐文章