Uploaded image for project: 'Torque'
  1. Torque
  2. TORQUE-118

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.3
    • 4.0-beta1
    • Maven 2 Plugin
    • None
    • 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; }

      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            mhanania@cornerturn.com Mitri Hanania
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: