将 BIRT 运行时覆盖到正确的 WAR 位置
我试图让 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-dependency-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));
I'm trying to get Maven to assemble a WAR with the BIRT runtime in a useful location within the WAR.
The BIRT runtime is in the pom.xml as
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>report-engine</artifactId>
<version>2.3.2</version>
<type>zip</type>
<scope>runtime</scope>
</dependency>
The desired outcome of overlaying this is something like
ReportEngine/lib/* -> WEB-INF/lib
ReportEngine/configuration/* -> WEB-INF/platform/configuration
ReportEngine/plugins/* -> WEB-INF/platform/plugins
My overlay configuration looks like
<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>
Of course, when running mvn war:exploded
I'm seeing
ReportEngine/lib/* -> WEB-INF/lib/ReportEngine/lib/
ReportEngine/configuration/* -> WEB-INF/platform/configuration/ReportEngine/lib/
ReportEngine/plugins/* -> WEB-INF/platform/plugins/ReportEngine/lib/
This relates, same sort of problem, no answer
http://www.coderanch.com/t/447258/Ant-Maven-Other-Build-Tools/Maven-war-dependencies-moving-files
Bonus points for pointing out how I can tidy this up a bit by having it all work from within WEB-INF/birt-runtime
Edit:
The reason for the locations specified above are that they match those indicated in http://wiki.eclipse.org/Servlet_Example_%28BIRT%29_2.1 and when I fritz with the Tomcat installation to mimic this, it all seems to work. It would be ideal if I could simply overlay the zip into WEB-INF/birt-runtime and then set the engine config appropriately, but I've not found that to work as yet.
Eg:
engineConfig = new EngineConfig();
engineConfig.setEngineHome("WEB-INF/birt-runtime");
engineConfig.setPlatformContext(new PlatformServletContext(servletContext));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更新:在重读这个问题时,我意识到我错过了测试项目中的子目录,所以它当然对我有用,对此感到抱歉。
据我所知,战争覆盖或依赖插件中不存在将工件的子文件夹解压到目录并排除路径的父元素的机制,两者都会为您提供完整的相对路径。
但是,您可以使用 unpack 目标将存档解压到临时文件夹,然后使用 antrun-plugin 将所需的子文件夹复制到其最终放置的位置。
以下配置就可以做到这一点(我尚未对此进行测试,因此如果有任何遗漏,请参阅文档以了解确切的详细信息)。请注意,执行是在同一阶段,但只要 dependency-plugin 在 antrun-plugin 之前配置,它就会首先执行。请注意,prepare-package 是 Maven 2.1 的新功能,如果您使用的是旧版本,则需要使用另一个阶段。
Update: On rereading the question I realise I missed out the sub-directories from my test project, so of course it worked for me, sorry for that.
As far as I know there exists no mechanism in either the war overlay or the dependency-plugin to unpack sub-folders of artifacts to a directory and exclude the parent elements of the path, both are going to give you the full relative path.
You can however use the unpack goal to unpack the archive to a temporary folder, then use the antrun-plugin to copy the required subfolders to their final resting places.
The following configuration would do just that (I've not yet tested this so apologies if there are any omissions, see the documentation for exact details). Note the executions are in the same phase, but as long as the dependency-plugin is configured before the antrun-plugin it would be executed first. Note, the prepare-package is new for Maven 2.1, if you're on an older version you'd need to use another phase.
没有真正回答我自己的问题,而是回复上面的 Rich Seller :)
试图让它与
mvn dependency:unpack
一起工作,文档说将其从执行节点中取出。不确定这是否是结果的原因,但这最终与我最初的战争插件尝试基本相同。
我在文档中没有看到任何依赖解包可以提供帮助的内容。我会再试一次tmrw。
Not really answering my own question, responding to Rich Seller above :)
Trying to get this to work with
mvn dependency:unpack
, the docs say to take it out of the executions node. Not sure if that is the cause of the result, but this ends up withbasically the same as my initial war-plugin attempt.
I don't see anything in the docs for depedency-unpack to assist. I'll try again tmrw.