我正在尝试让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));
答案 0 :(得分:1)
更新:在重新阅读问题时,我意识到我错过了测试项目中的子目录,所以当然它对我有用,对不起。
据我所知,在war覆盖或dependency-plugin中没有机制将工件的子文件夹解包到目录中并排除路径的父元素,两者都会给你完整的亲戚路径。
然而,您可以使用解包目标将存档解压缩到临时文件夹,然后使用antrun-plugin将所需的子文件夹复制到最终的休息位置。
以下配置就是这样做的(我还没有对此进行测试,如果遗漏有任何遗漏,请参阅文档以获取确切的详细信息)。请注意,执行处于同一阶段,但只要在antrun-plugin之前配置dependency-plugin,它就会先执行。请注意,准备包是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>
答案 1 :(得分:0)
没有真正回答我自己的问题,回复上面的Rich Seller:)
试图让这个与mvn dependency:unpack
一起使用,文档说要把它从执行节点中取出来。不确定这是否是结果的原因,但最终以
WEB-INF/lib/ReportEngine/lib
WEB-INF/platform/ReportEngine/configuration
WEB-INF/platform/ReportEngine/plugins
与我最初的war-plugin尝试基本相同。 我没有在文档中看到任何依赖 - 解压缩帮助。我会再试一次。
<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>