Uploaded image for project: 'XWiki Commons'
  1. XWiki Commons
  2. XCOMMONS-155

XAR Plugin doesn't always preserve old files in the resources when adding pages from dependencies

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • None
    • 3.5
    • None

    Description

      it's caused by the fact that, when unarchiving, the org.codehaus.plexus.archiver.zip.ZipUnArchiver is checking, besides the fact that the file exists and the fact that it should not overwrite, the dates of the files (the one to overwrite and the one from the archive).

      if ( !isOverwrite() && f.exists() && ( f.lastModified() >= entryDate.getTime() ) )
      

      To reproduce, I did this kind of thing in a module with xar packaging:

      • in the dependencies
            <dependency>
              <groupId>org.xwiki.manager</groupId>
              <artifactId>xwiki-manager-ui-all</artifactId>
              <version>3.5-SNAPSHOT</version>
              <type>xar</type>
            </dependency>
            <dependency>
              <groupId>org.xwiki.platform</groupId>
              <artifactId>xwiki-platform-dashboard-ui</artifactId>
              <version>3.5-SNAPSHOT</version>
              <type>xar</type>
            </dependency>
        

      and then in the plugins section:

            <plugin>
              <groupId>org.xwiki.commons</groupId>
              <artifactId>xwiki-commons-tool-xar-plugin</artifactId>
              <version>${platform.version}</version>
              <executions>
                <execution>
                  <id>default-xar</id>
                  <configuration>
                    <includeDependencies>true</includeDependencies>
                  </configuration>
                </execution>
                <!-- We add this execution here to have enterprise default Dashboard.WebHome in the resources so that the 
                     Dashboard.WebHome of the manager-ui is not overwriting this one, since the manager-ui one is workspaces 
                     specific and we don't want it.-->
                <execution>
                  <id>unxar-xwiki-enterprise-dashboard-ui</id>
                  <phase>generate-resources</phase>
                  <goals>
                    <goal>unxar</goal>
                  </goals>
                  <configuration>
                    <groupId>org.xwiki.platform</groupId>
                    <artifactId>xwiki-platform-dashboard-ui</artifactId>
                    <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                    <includes>
                      <include>Dashboard/WebHome.xml</include>
                    </includes>
                  </configuration>
                </execution>
              </executions>
            </plugin>
      

      The intention of this is to force the Dashboard.WebHome that ends up in the final xar to be the one from the dashboard-ui instead of the one from manager-ui-all. The unxar would add it in the target/classes folder at generate-resources time, before the packaging phase, when the xar plugin would find it as 'existing' and would not overwrite it with the one from the xar dependency, as per the rule of the xar plugin. However this doesn't happen because of the extra dates check.
      Note that the xwiki-manager-ui-all.xar must be newer than the xwiki-platform-dashboard-ui.xar for the bug to reproduce (rebuild xwiki-manager-ui-all in case it doesn't happen or force a refetch or something).

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              lucaa Anca Luca
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: