Maven在添加依赖项时复制JAR

xan*_*oss 9 java portlet maven ibm-rad

我目前正在使用IBM Rational Application Development(IBM Eclipse发行版)进行Portlet开发,并且在Maven集成方面存在一个小问题.

情况如下:

1)IBM RAD能够直接从内部部署Portlet(RUN/DEBUG)

在这种情况下,我根本不使用Maven生成的WAR,因为IBM RAD似乎自动创建了WAR并将其推送到IBM WebSphere Portal.到目前为止,这不是什么大问题.

2)Maven依赖项不会复制到WebContent/WEB-INF/lib目录

IBM有自己的目录结构:WebContent/WEB-INF和WebContent/META-INF.如果我更新pom.xml以包含新的依赖项,那些JARS将不会被复制到WebContent/WEB-INF/lib目录,因此当我想要RUN/DEBUG这个portlet时,这些库将不会包含在内.

题:

有没有办法在我更新pom.xml后自动将新JAR复制到WebContent/WEB-INF/lib文件夹?(如果是这样,那应该是哪个生命周期?)

如果问题#1没有完美的解决方案,我不介意这个步骤是否包含在"mvn install"编译/目标中.

不希望使用ant-task,而是使用maven自己的复制实用程序(如果存在).

如果有人建议如何集成Maven和IBM RAD以进行WebSphere Portlet开发,请随时添加更多答案.

谢谢

McD*_*ell 2

这是我从旧的 RAD 项目中挑选的 Maven 2 pom.xml 框架:

<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>
Run Code Online (Sandbox Code Playgroud)

这适用于 RAD 创建的目录结构(版本 7.5,针对 WAS 7 上的 Portal 6.5.x)。这不是唯一的方法,我确信 pom 可以改进,但它达到了它的目的。根据需要添加您的依赖项。