Maven在添加依赖项时复制JAR

xandross:

我目前正在使用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目录,因此,当我想对Portlet进行RUN / DEBUG时,这些库将不包括在内。

题:

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

如果没有一个完美的解决方案来解决问题#1,那么我不介意此步骤是否包含在“ mvn install”编译/目标中。

最好不要使用ant-task,而是使用maven自己的复制实用程序(如果存在)。

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

谢谢

麦克道尔:

这是我从一个旧的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>

这已应用于RAD创建的目录结构(版本7.5,目标是WAS 7上的Portal 6.5.x)。这不是唯一的方法,我敢肯定pom可以改进,但是它达到了目的。适当添加您的依赖项。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章