Torque
  1. Torque
  2. TORQUE-118

Maven2 plugin fails to detect that schema was changed when generating om, etc

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 3.3
    • Fix Version/s: 4.0-beta1
    • Component/s: Maven 2 Plugin
    • Labels:
      None
    • Environment:
      OS: Linux 2.6.24.4-64.fc8
      JDK: jdk1.6.0_07
      Maven: apache-maven-2.0.9

      Description

      Using the Maven2 plugin, generate the OM classes from a schema file. Then make a change to the schema file and try to re-generate the OM classes. The Maven2 plugin will state that the schema has not changed with respect to the report file.

      After debugging, it seems that the method schemaChanged() in class org.apache.torque.mojo.DataModelTaskMojo attempts to compare the last modified dates between the schema file and the report file. It uses the classes FileSet and DirectoryScanner to obtain a list of schema files to compare against the report file. The method DirectoryScanner.getIncludedFiles() is called to return a list of schema files in the directory specified by the "schemaDir" property. According to the javadocs, DirectoryScanner.getIncludedFiles() returns a list of file names relative to the "base" directory. However, the file names are being used as if they are absolute file names when trying to retrieve the last modified time. Hence, always resulting in a last modified time of 0, which causes the schema file to alway fail when comparing to see if the schema file has a last modified time greater than the report file.

      A work around that I have been using is to always delete the report files when a change is made to the schema file.

      A proposed fix is to create the schema java.io.File object using the "schemaDir" property and the relative file name:

      for (int i = 0; i < fileNames.length; ++i)
      {
      File file = new File(schemaDir, fileNames[i]);
      if (file.lastModified() > report.lastModified())

      { schemaChanged = true; break; }

      }

        Activity

        Hide
        Thomas Fox added a comment -

        The problem will not occur any more because the 4.0 generation plugin does not check for an unchanged schema any more automatically

        Show
        Thomas Fox added a comment - The problem will not occur any more because the 4.0 generation plugin does not check for an unchanged schema any more automatically

          People

          • Assignee:
            Unassigned
            Reporter:
            Mitri Hanania
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development