Maven Ear Plugin
  1. Maven Ear Plugin
  2. MEAR-148

In an ear which has skinny wars, want to include the same jar in shared lib of ear as well as in the war

    Details

    • Type: New Feature New Feature
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.7
    • Fix Version/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      I have the following artifacts

      MyWar1.war depends on MyJar.jar and SomeThirdParty.jar
      MyWar2.war depends on MyJar.jar
      MyJar.jar also depends on SomeThirdParty.jar

      Now I want to create an ear with MyWar1 and MyWar2, and I want to make them skinny wars so that MyJar.jar should not be included in both the wars.
      For some reason, the SomeThirdParty.jar has to be in the WEB-INF/lib directory of MyWar1.war

      Here is the structure I want:

      MyEar.ear
      - lib
          - MyJar.jar
          - SomeThirdParty.jar
      - MyWar1.war
          - WEB-INF/lib/SomeThirdParty.jar
      - MyWar1.war
      

      As you can see, I want the SomeThirdParty.jar in MyWar1 as well as in the lib directory.
      Is there any way to achieve it if I am using <skinnyWars>true</skinnyWars>?

      If not, we should have some way of doing this, maybe by supporting nested <dependencies> in the <webmodule> tag which would override the skinnyWars behavior for the listed dependencies like

      <webModule>
        <groupId>my.groupId</groupId>
        <artifactId>my.artifactId</artifactId>
        <dependencies>
          <dependency>
            <groupId>SomeThirdParty.jar.groupId</groupId>
            <artifactId>SomeThirdParty.jar</artifactId>
            <version>SomeThirdParty.jar.version</version>
          </dependency>
        </dependencies>
      </webModule>
      

        Activity

        Hide
        Dennis Lundberg added a comment -

        For MyWar1 you can use <packagingIncludes> to include only SomeThirdParty.jar, see
        http://maven.apache.org/plugins/maven-war-plugin/examples/skinny-wars.html

        However, I don't see why you would want to have SomeThirdParty.jar in the lib folder of MyEar.

        Show
        Dennis Lundberg added a comment - For MyWar1 you can use <packagingIncludes> to include only SomeThirdParty.jar, see http://maven.apache.org/plugins/maven-war-plugin/examples/skinny-wars.html However, I don't see why you would want to have SomeThirdParty.jar in the lib folder of MyEar.
        Hide
        Tejas Pajai added a comment -

        Dennis, as per your suggestion, I would have to modify pom.xml in two projects. I was trying to avoid that by using maven-ear-plugin as per this example:
        http://maven.apache.org/plugins/maven-ear-plugin/examples/skinny-wars.html

        Show
        Tejas Pajai added a comment - Dennis, as per your suggestion, I would have to modify pom.xml in two projects. I was trying to avoid that by using maven-ear-plugin as per this example: http://maven.apache.org/plugins/maven-ear-plugin/examples/skinny-wars.html
        Hide
        Robert Scholte added a comment -

        I've seen comparable projects which were originally built with Ant. In order to get the same ear something like this was required.
        It is indeed something which has to be solved per webmodule, but I would suggest a different way of configuration:

        <webModule>
          <groupId>my.groupId</groupId>
          <artifactId>my.artifactId</artifactId>
          <skinnedDependencies>
            <includes>
              <include>groupId:artifactId[:type[:classifier]]</include> <!-- default *:* which means everything-->
            </includes>
            <excludes>
              <exclude>groupId:artifactId[:type[:classifier]]</exclude>
            </excludes>
          </skinnedDependencies>
        </webModule>
        

        Not sure if skinnedDependencies is the right/best term.

        Show
        Robert Scholte added a comment - I've seen comparable projects which were originally built with Ant. In order to get the same ear something like this was required. It is indeed something which has to be solved per webmodule, but I would suggest a different way of configuration: <webModule> <groupId> my.groupId </groupId> <artifactId> my.artifactId </artifactId> <skinnedDependencies> <includes> <include> groupId:artifactId[:type[:classifier]] </include> <!-- default *:* which means everything--> </includes> <excludes> <exclude> groupId:artifactId[:type[:classifier]] </exclude> </excludes> </skinnedDependencies> </webModule> Not sure if skinnedDependencies is the right/best term.
        Hide
        Mario Däpp added a comment -

        You could use the dependencies-plugin to workaround this issue:
        1. Change the scope of the dependency to provided (the dependency will remain in the WAR as a result of this)
        2. Add this to your pom.xml

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <executions>
            <execution>
              <goals>
                <goal>copy-dependencies</goal>
              </goals>
              <configuration>
                <includeScope>provided</includeScope>
                <outputDirectory>${project.build.directory}/${project.build.finalName}/lib</outputDirectory>
              </configuration>
            </execution>
          </executions>
        </plugin>
        
        Show
        Mario Däpp added a comment - You could use the dependencies-plugin to workaround this issue: 1. Change the scope of the dependency to provided (the dependency will remain in the WAR as a result of this) 2. Add this to your pom.xml <plugin> <groupId> org.apache.maven.plugins </groupId> <artifactId> maven-dependency-plugin </artifactId> <executions> <execution> <goals> <goal> copy-dependencies </goal> </goals> <configuration> <includeScope> provided </includeScope> <outputDirectory> ${project.build.directory}/${project.build.finalName}/lib </outputDirectory> </configuration> </execution> </executions> </plugin>

          People

          • Assignee:
            Unassigned
            Reporter:
            Tejas Pajai
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: