Maven to copy JAR when adding dependencies

xandross :

I'm currently using IBM Rational Application Development (IBM Eclipse distro) for Portlet development and having a small issue with Maven integration.

Here's the situation:

1) IBM RAD has the ability to deploy a Portlet directly from within itself (RUN/DEBUG)

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 dependencies are not copied to WebContent/WEB-INF/lib directory

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.

Question:

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?)

If there's no perfect solution for question #1, I don't mind if this step is included in the "mvn install" compile/goal.

Prefer not to use ant-task but instead maven own copy utility if exist.

If anyone has suggestions how to integrate Maven and IBM RAD for WebSphere Portlet development, feel free to add more answers.

Thanks

McDowell :

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>

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

IntelliJ adding jar dependencies

From Java

Generate jar file in Maven with dependencies and tests

From Java

Maven copy only specific dependencies

From Java

Including dependencies in a jar with Maven

From Java

Maven deploy jar with dependencies to repo

From Java

Maven failing to download jar dependencies

From Java

How To: Eclipse Maven install build jar with dependencies

From Java

Maven: Add local dependencies to jar

From Java

How can I run code locally with dependencies and exclude them when creating a Jar with Maven

From Java

Export maven as jar file with all dependencies

From Java

Maven + Tycho, adding Maven dependencies

From Java

Maven jar dependencies are displayed outside `Maven Dependencies` view

From Java

Maven jar with dependencies?

From Dev

Maven dependency plugin copy jar with dependencies

From Dev

Maven not adding all dependencies to jar

From Dev

Adding maven dependencies

From Dev

Only Jar-type local dependencies are supported when adding aar

From Dev

Maven jar without dependencies by default

From Dev

Copy dependencies with maven

From Dev

Building jar with dependencies maven

From Dev

Exception when starting Spring after adding Validation, conflicting maven dependencies

From Dev

How to copy jar-with-dependencies in my webapp\myfolder in maven Idea

From Dev

Maven building a jar with dependencies unpacked inside the JAR

From Dev

adding jar file dependencies

From Dev

The maven dependencies are not added to the jar in eclipse

From Dev

Maven : Custom .jar not resolving the correct dependencies when referenced

From Dev

jar download with dependencies from maven

From Dev

Maven shade plugin - Jar and dependencies

From Dev

Maven copy dependencies with full jar name

Related Related

  1. 1

    IntelliJ adding jar dependencies

  2. 2

    Generate jar file in Maven with dependencies and tests

  3. 3

    Maven copy only specific dependencies

  4. 4

    Including dependencies in a jar with Maven

  5. 5

    Maven deploy jar with dependencies to repo

  6. 6

    Maven failing to download jar dependencies

  7. 7

    How To: Eclipse Maven install build jar with dependencies

  8. 8

    Maven: Add local dependencies to jar

  9. 9

    How can I run code locally with dependencies and exclude them when creating a Jar with Maven

  10. 10

    Export maven as jar file with all dependencies

  11. 11

    Maven + Tycho, adding Maven dependencies

  12. 12

    Maven jar dependencies are displayed outside `Maven Dependencies` view

  13. 13

    Maven jar with dependencies?

  14. 14

    Maven dependency plugin copy jar with dependencies

  15. 15

    Maven not adding all dependencies to jar

  16. 16

    Adding maven dependencies

  17. 17

    Only Jar-type local dependencies are supported when adding aar

  18. 18

    Maven jar without dependencies by default

  19. 19

    Copy dependencies with maven

  20. 20

    Building jar with dependencies maven

  21. 21

    Exception when starting Spring after adding Validation, conflicting maven dependencies

  22. 22

    How to copy jar-with-dependencies in my webapp\myfolder in maven Idea

  23. 23

    Maven building a jar with dependencies unpacked inside the JAR

  24. 24

    adding jar file dependencies

  25. 25

    The maven dependencies are not added to the jar in eclipse

  26. 26

    Maven : Custom .jar not resolving the correct dependencies when referenced

  27. 27

    jar download with dependencies from maven

  28. 28

    Maven shade plugin - Jar and dependencies

  29. 29

    Maven copy dependencies with full jar name

HotTag

Archive