Grails
  1. Grails
  2. GRAILS-5839

Duplicate resources when using in-place plugins and building a project's war file

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.1
    • Fix Version/s: 1.2.2, 1.3-RC1
    • Component/s: Project infrastructure
    • Labels:
      None
    • Environment:
      JDK 1.6_17, XPSP2, grails 1.2.1

      Description

      Since our upgrade to grails 1.2.x we get the following warnings

      WARNING: Duplicate resource 'BootStrap', using the last one in compile order.
      WARNING: Duplicate resource 'Config', using the last one in compile order.
      WARNING: Duplicate resource 'DataSource', using the last one in compile order.
      WARNING: Duplicate resource 'BuildConfig', using the last one in compile
      ...
      

      These duplicates are coming from our inplace plugins. The documentation says:

      Notes on excluded Artefacts
      
      Although the create-plugin command creates certain files for you so that the plug-in can be run as a Grails application, 
      not all of these files are included when packaging a plug-in. The following is a list of artefacts created, but not included by package-plugin:
      
          * grails-app/conf/DataSource.groovy
          * grails-app/conf/UrlMappings.groovy
          * build.xml
          * Everything within /web-app/WEB-INF
      
      

      For the packaged plugins this is true as none of the .zip files of each plugin contains any of these resources.
      But wen building the war, these files are not excluded.

        Issue Links

          Activity

          Hide
          Malte Huebner added a comment -

          Just to clarify: "But wen building the war, these files are not excluded." means building the project's war not the plugin's war.

          Show
          Malte Huebner added a comment - Just to clarify: "But wen building the war, these files are not excluded." means building the project's war not the plugin's war.
          Hide
          Malte Huebner added a comment -

          The duplicates are even not excluded when I declare them in the pluginExludes-array within XyGrailsPlugin.groovy

          Show
          Malte Huebner added a comment - The duplicates are even not excluded when I declare them in the pluginExludes-array within XyGrailsPlugin.groovy
          Hide
          Wolfgang Schell added a comment -

          I see the same behavior with in-place plugins.

          The problem with in-place plugins is, that everything (i.e. the app and all plugins) is compiled together in a single step. As all files are visible to the compiler, it has to decide, which of the duplicates to use. When plugins are installed using grails install-plugin, the conflicting files are not part of the plugin's distribution zip (grails package-plugins filters them out) and hence not visible to the compiler.

          If you never execute your plugins by themselves without the hosting application, you can simply delete Bootstrap.groovy, DataSource.groovy, UrlMappings.groovy and Config.groovy, as they are not needed in this case. BuildConfig.groovy is another story, but it is ignored by the runtime, as it is only used during build time and should not end up in the war and plugin zip anyway.

          Show
          Wolfgang Schell added a comment - I see the same behavior with in-place plugins. The problem with in-place plugins is, that everything (i.e. the app and all plugins) is compiled together in a single step. As all files are visible to the compiler, it has to decide, which of the duplicates to use. When plugins are installed using grails install-plugin, the conflicting files are not part of the plugin's distribution zip (grails package-plugins filters them out) and hence not visible to the compiler. If you never execute your plugins by themselves without the hosting application, you can simply delete Bootstrap.groovy, DataSource.groovy, UrlMappings.groovy and Config.groovy, as they are not needed in this case. BuildConfig.groovy is another story, but it is ignored by the runtime, as it is only used during build time and should not end up in the war and plugin zip anyway.
          Hide
          Malte Huebner added a comment -

          I think that it's important that a plugin behaves like a normal application. We mainly develop plugins separate from the hosting app. So everything needs to stay in the plugin (DataSource, Bootstrap...). When everything is bundled in the build process (in the hosting app, means project) these plugin specific files must be excluded in my opinion.

          Show
          Malte Huebner added a comment - I think that it's important that a plugin behaves like a normal application. We mainly develop plugins separate from the hosting app. So everything needs to stay in the plugin (DataSource, Bootstrap...). When everything is bundled in the build process (in the hosting app, means project) these plugin specific files must be excluded in my opinion.
          Show
          Graeme Rocher added a comment - Fixed 1.3.x: http://github.com/grails/grails-core/commit/5ff3bed925b53bb2b2caf2af2cb34803ecd8583e Fixed 1.2.x http://github.com/grails/grails-core/commit/ba0a09119b5d6f3adf3ac93e18ef87a0c654831d:
          Hide
          Malte Huebner added a comment -

          Thanks for fixing!

          Show
          Malte Huebner added a comment - Thanks for fixing!

            People

            • Assignee:
              Graeme Rocher
              Reporter:
              Malte Huebner
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development