Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-5783

Maven axis2-repo-maven-plugin + Maven WAR plugin with *.mar artifacts

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Not A Problem
    • Affects Version/s: 1.7.3
    • Fix Version/s: None
    • Component/s: Tools
    • Labels:
      None

      Description

      I have a conflict currently between the 'axis2-repo-maven-plugin' and the 'maven-war-plugin'.

      At some point someone upgraded the Maven WAR plugin so that it automatically packs any "<type>mar</type>" runtime dependency into the resulting WAR. Unfortunately it is also not possible to disable this "feature" on the maven-war-plugin.

      I want to use the axis2-repo-maven-plugin to place different ".mar" artifacts into two different Axis2 repositories in the same WAR (i.e. WEB-INF/modules and WEB-INF/client/modules). While the axis2-repo-maven-plugin does its job perfectly, the WAR plugin always runs last and packs ALL MAR artifacts into WEB-INF/modules.

      My "workaround" which is most likely not release-viable was to change the axis2-repo-maven-plugin CreateRepositoryMojo.java so that it works on MAR artifacts with scope "provided" instead of "runtime" and "@requiresDependencyResolution compile" instead of "runtime". This keeps the WAR plugin from packing them automatically and allows me to run two separate executions for my two repositories.

      /**
       * Creates an Axis2 repository from the project's runtime dependencies. This goal is typically
       * used to build an Axis2 repository that will be packaged into some kind of distribution.
       * 
       * @goal create-repository
       * @phase package
       * @requiresDependencyResolution compile
       */
      public class CreateRepositoryMojo extends AbstractCreateRepositoryMojo {
          /**
           * The output directory where the repository will be created.
           * 
           * @parameter default-value="${project.build.directory}/repository"
           */
          private File outputDirectory;
          
          @Override
          protected String getScope() {
              return Artifact.SCOPE_PROVIDED;
          }
      
          @Override
          protected File getOutputDirectory() {
              return outputDirectory;
          }
      }
      

      I am not sure what a release-viable solution would look like...or even if it is a concern for this plugin(?!?). The best-possible solution would be an option to exclude .mar artifacts in the maven-war-plugin ... but if possible I want to get away from having to customize the Axis2 Plugin with every new release.

        Activity

        Hide
        veithen Andreas Veithen added a comment -

        Some time ago I wrote a blog post discussing this problem:

        http://veithen.github.io/2015/01/11/axis2-modules-war-packaging.html

        Please let me know what you think about the solution proposed in that article.

        Show
        veithen Andreas Veithen added a comment - Some time ago I wrote a blog post discussing this problem: http://veithen.github.io/2015/01/11/axis2-modules-war-packaging.html Please let me know what you think about the solution proposed in that article.
        Hide
        JWT007 Jeff Thomas added a comment -

        Hello Andreas,

        I am familiar with that post .

        The thing is... and here is probably a grey area... your suggestion works great for the final WAR archive. Which means that the modules will / can be excluded from the final WAR.

        The problem is really with the development environment when working with WARs that do this. This means on both Eclipse (m2e-wtp Plugin) and Intellij, an exploded WAR is built and used for testing the WAR (i.e. in Tomcat). No matter what you do, the packaging excludes do not apply to this exploded WAR ... the filters are applied to generate the end-WAR from the exploded-WAR. So during development, all MARs always end up in WEB-INF/modules.

        Show
        JWT007 Jeff Thomas added a comment - Hello Andreas, I am familiar with that post . The thing is... and here is probably a grey area... your suggestion works great for the final WAR archive. Which means that the modules will / can be excluded from the final WAR. The problem is really with the development environment when working with WARs that do this. This means on both Eclipse (m2e-wtp Plugin) and Intellij, an exploded WAR is built and used for testing the WAR (i.e. in Tomcat). No matter what you do, the packaging excludes do not apply to this exploded WAR ... the filters are applied to generate the end-WAR from the exploded-WAR. So during development, all MARs always end up in WEB-INF/modules.
        Hide
        veithen Andreas Veithen added a comment -

        I think the only reasonable solution for this problem is to submit a patch for the maven-war-plugin that would allow to disable the feature introduced by MWAR-193.

        Show
        veithen Andreas Veithen added a comment - I think the only reasonable solution for this problem is to submit a patch for the maven-war-plugin that would allow to disable the feature introduced by MWAR-193 .
        Hide
        JWT007 Jeff Thomas added a comment -

        Hi Andreas,
        thanks for the tip on MWAR 193.
        After looking at the source code of the maven-war-plugin (ArtifactsPackagingTask) I noticed that MAR artifacts configured as optional are not added to the WAR. I tested this and it works like a charm.

        The only other caveat is that the MAR plugins have to be defined with scope runtime for them to be picked up by the 'axis2-repo-maven-plugin'.

        So a working dependency in this case is:

            <!-- Axis2 MAR (module-archive): AXIS2 addressing module. -->
            <dependency>
              <groupId>org.apache.axis2</groupId>
              <artifactId>addressing</artifactId>
              <version>1.7.3</version>
              <type>mar</type>
              <scope>runtime</scope>
              <optional>true</optional>
            </dependency>
        

        Maybe you want to add a hint to your ^^ blog post? I know as I was looking at this problem while googling there were a few other people with the same problem.

        With this configuration, I no longer need to patch my 'axis2-repo-maven-plugin' MOJO for this problem.

        From my side the issue can be closed.

        Show
        JWT007 Jeff Thomas added a comment - Hi Andreas, thanks for the tip on MWAR 193. After looking at the source code of the maven-war-plugin (ArtifactsPackagingTask) I noticed that MAR artifacts configured as optional are not added to the WAR. I tested this and it works like a charm. The only other caveat is that the MAR plugins have to be defined with scope runtime for them to be picked up by the 'axis2-repo-maven-plugin'. So a working dependency in this case is: <!-- Axis2 MAR (module-archive): AXIS2 addressing module. --> <dependency> <groupId> org.apache.axis2 </groupId> <artifactId> addressing </artifactId> <version> 1.7.3 </version> <type> mar </type> <scope> runtime </scope> <optional> true </optional> </dependency> Maybe you want to add a hint to your ^^ blog post? I know as I was looking at this problem while googling there were a few other people with the same problem. With this configuration, I no longer need to patch my 'axis2-repo-maven-plugin' MOJO for this problem. From my side the issue can be closed.
        Hide
        JWT007 Jeff Thomas added a comment -

        As mentioned in last comment, the correct combination of dependency parameters allowsa viable implementation.

        Show
        JWT007 Jeff Thomas added a comment - As mentioned in last comment, the correct combination of dependency parameters allowsa viable implementation.

          People

          • Assignee:
            Unassigned
            Reporter:
            JWT007 Jeff Thomas
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development