问题描述
我目前正在使用IBM Rational Application Development(IBM Eclipse发行版)进行Portlet开发,并且在Maven集成方面存在一个小问题。
I'm currently using IBM Rational Application Development (IBM Eclipse distro) for Portlet development and having a small issue with Maven integration.
以下是这种情况:
1)IBM RAD能够直接从内部部署Portlet(RUN / DEBUG)
1) IBM RAD has the ability to deploy a Portlet directly from within itself (RUN/DEBUG)
在此例如,我根本没有使用Maven生成的WAR,因为IBM RAD似乎自动创建了WAR并将其推送到IBM WebSphere Portal。到目前为止,这不是什么大不了的事。
In this case, I'm not using Maven generated WAR at all because IBM RAD seems to create the WAR themselves automagically and push it to IBM WebSphere Portal. Which isn't a big deal so far.
2)Maven依赖项未复制到WebContent / WEB-INF / lib目录
2) Maven dependencies are not copied to WebContent/WEB-INF/lib directory
IBM有自己的目录结构:WebContent / WEB-INF和WebContent / META-INF。如果我更新pom.xml以包含新的依赖项,那些JARS将不会被复制到WebContent / WEB-INF / lib目录,因此当我想要运行/调试portlet时,这些库将不会包含在内。
IBM has its own directory structure: WebContent/WEB-INF and WebContent/META-INF. If I updated pom.xml to include new dependencies, those JARS will not be copied to the WebContent/WEB-INF/lib directory hence when I wanted to RUN/DEBUG the portlet, those libraries will not be included.
问题:
有没有办法将新的JAR自动复制到WebContent / WEB-INF / lib文件夹中我更新了pom.xml? (如果是这样,那应该是哪个生命周期?)
Is there a way to copy the new JARs automatically to the WebContent/WEB-INF/lib folder as soon as I update the pom.xml? (if so, which lifecycle this should be in?)
如果问题#1没有完美的解决方案,我不介意这一步是否包括在 mvn安装编译/目标。
If there's no perfect solution for question #1, I don't mind if this step is included in the "mvn install" compile/goal.
不希望使用ant-task,而是使用maven自己的复制实用程序(如果存在)。
Prefer not to use ant-task but instead maven own copy utility if exist.
如果有人建议如何集成Maven和IBM RAD以进行WebSphere Portlet开发,可以随意添加更多答案。
If anyone has suggestions how to integrate Maven and IBM RAD for WebSphere Portlet development, feel free to add more answers.
谢谢
推荐答案
这是我从旧的RAD项目中选择的Maven 2 pom.xml骨架:
Here's a Maven 2 pom.xml skeleton I picked out of an old RAD project:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>foo</groupId>
<artifactId>fooproject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>US-ASCII</project.build.sourceEncoding>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<finalName>${project.artifactId}-${project.version}</finalName>
<resources>
<resource>
<directory>src</directory>
<includes><include>**/*.properties</include></includes>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-beta-1</version>
<configuration>
<webappDirectory>${project.basedir}/WebContent</webappDirectory>
<warSourceDirectory>${project.basedir}/WebContent</warSourceDirectory>
<webXml>${project.basedir}/WebContent/WEB-INF/web.xml</webXml>
<packagingIncludes>**/*.properties,**/*.jsp,**/*.jar,**/*.class,theme/**/*,images/**/*,**/*.xml,**/*.swf,**/*.tld,**/*.txt</packagingIncludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- compile classpath -->
</dependencies>
</project>
这适用于由RAD创建的目录结构(版本7.5,目标是Portal 6.5.x on WAS 7)。这不是唯一的方法,我确信可以改进pom,但它有助于实现它的目的。根据需要添加依赖项。
This was applied to the directory structure as created by RAD (version 7.5, targetting Portal 6.5.x on WAS 7). This isn't the only way to do it and I'm sure the pom could be improved upon, but it served its purpose. Add your dependencies as appropriate.
这篇关于Maven在添加依赖项时复制JAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!