Avro
  1. Avro
  2. AVRO-971

IDL Import from project classpath

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6.1
    • Fix Version/s: 1.6.2
    • Component/s: java
    • Labels:
    • Environment:

      Maven java projects

      Description

      Currently, it looks like the only option to importing another schema in IDL is to place the file being imported in the same directory as that of the importing avdl. In a setup where there are avdl's that are spread among several maven projects that are owned by different teams, this is logistically difficult to manage.

      When using the avro-maven-plugin, I would like to be able to just create a dependency from my project on another jar that contains the avdl I am want to import and have Avro be smart enough to look for it in the classpath of the project containing the avdl when compiling my avdl.

      Attached is a working patch that will:
      1. Change the IDLProtocolMojo class to lookup the current project's classpath and create a new ClassLoader.
      2. Give the Idl compiler class the ClassLoader before parsing the avdl.
      3. If the Idl class encounters an import that it cannot resolve to the local directory while parsing, it will try to use the ClassLoader to load up the file being imported.

      The patch spans the Avro 1.6.1 tag of the Java avro, avro-compiler, and avro-maven-plugin projects.

      1. ImportFromClassPath.patch
        6 kB
        Victor Chau
      2. ImportFromClassPath_v2.patch
        7 kB
        Victor Chau
      3. ImportFromClassPath_v3.patch
        12 kB
        Victor Chau
      4. AVRO-971.patch
        10 kB
        Doug Cutting
      5. AVRO-971.patch
        12 kB
        Doug Cutting

        Issue Links

          Activity

          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Patch Available Patch Available
          61d 22h 59m 1 Doug Cutting 07/Feb/12 23:31
          Patch Available Patch Available Resolved Resolved
          22h 42m 1 Doug Cutting 08/Feb/12 22:14
          Resolved Resolved Closed Closed
          6d 2h 32m 1 Doug Cutting 15/Feb/12 00:46
          Victor Chau made changes -
          Link This issue relates to AVRO-1036 [ AVRO-1036 ]
          Doug Cutting made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Doug Cutting made changes -
          Status Patch Available [ 10002 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Hide
          Doug Cutting added a comment -

          I committed this. Thanks, Victor!

          Show
          Doug Cutting added a comment - I committed this. Thanks, Victor!
          Hide
          Victor Chau added a comment -

          Thanks, Doug.

          Show
          Victor Chau added a comment - Thanks, Doug.
          Doug Cutting made changes -
          Attachment AVRO-971.patch [ 12513719 ]
          Hide
          Doug Cutting added a comment -

          Version of patch that includes new test files.

          Show
          Doug Cutting added a comment - Version of patch that includes new test files.
          Doug Cutting made changes -
          Status Open [ 1 ] Patch Available [ 10002 ]
          Assignee Victor Chau [ vchau ]
          Fix Version/s 1.6.2 [ 12319074 ]
          Hide
          Doug Cutting added a comment -

          Unless there are objections I'll commit this soon.

          Show
          Doug Cutting added a comment - Unless there are objections I'll commit this soon.
          Doug Cutting made changes -
          Attachment AVRO-971.patch [ 12513713 ]
          Hide
          Doug Cutting added a comment -

          Here's an updated patch that applies cleanly to the current trunk. I also changed it to close input streams in a finally clause.

          Show
          Doug Cutting added a comment - Here's an updated patch that applies cleanly to the current trunk. I also changed it to close input streams in a finally clause.
          Victor Chau made changes -
          Attachment ImportFromClassPath_v3.patch [ 12508294 ]
          Hide
          Victor Chau added a comment -

          This version include new unit test cases for the compiler

          Show
          Victor Chau added a comment - This version include new unit test cases for the compiler
          Victor Chau made changes -
          Attachment ImportFromClassPath_v3.patch [ 12508293 ]
          Victor Chau made changes -
          Attachment ImportFromClassPath_v3.patch [ 12508293 ]
          Hide
          Victor Chau added a comment -

          This version includes new unit test cases.

          Show
          Victor Chau added a comment - This version includes new unit test cases.
          Hide
          Victor Chau added a comment -

          Sorry, don't know how I could've missed it but forgot about ImportShema(). Attached an updated patch. I'll work on creating a test for this.

          Show
          Victor Chau added a comment - Sorry, don't know how I could've missed it but forgot about ImportShema(). Attached an updated patch. I'll work on creating a test for this.
          Victor Chau made changes -
          Attachment ImportFromClassPath_v2.patch [ 12506677 ]
          Hide
          Doug Cutting added a comment -

          In idl.jj, shouldn't we update ImportSchema() too?

          Also, it'd be good to add a test for this.

          Show
          Doug Cutting added a comment - In idl.jj, shouldn't we update ImportSchema() too? Also, it'd be good to add a test for this.
          Victor Chau made changes -
          Description Currently, it looks like the only option to importing another schema in IDL is to place the file being imported in the same directory as that of the importing avdl. In a setup where there are avdl's that are spread among several maven projects that are owned by different teams, this is logistically difficult to manage.

          When using the avro-maven-plugin, I would like to be able to just create a dependency from my project on another jar that contains the avdl I am want to import and have Avro be smart enough to look for it in the classpath of the project containing the avdl when compiling my avdl.

          Attached is a working patch that will:
            1. Change the IDLProtocolMojo class to lookup the current project's classpath and create a new ClassLoader.
            2. Give the Idl compiler class the ClassLoader before parsing the avdl.
            3. If the Idl class encounters an import that it cannot resolve to the local directory while parsing, it will try to use the ClassLoader to load up the file being imported.

          The patch spans the Java avro, avro-compiler, and avro-maven-plugin projects.
          Currently, it looks like the only option to importing another schema in IDL is to place the file being imported in the same directory as that of the importing avdl. In a setup where there are avdl's that are spread among several maven projects that are owned by different teams, this is logistically difficult to manage.

          When using the avro-maven-plugin, I would like to be able to just create a dependency from my project on another jar that contains the avdl I am want to import and have Avro be smart enough to look for it in the classpath of the project containing the avdl when compiling my avdl.

          Attached is a working patch that will:
            1. Change the IDLProtocolMojo class to lookup the current project's classpath and create a new ClassLoader.
            2. Give the Idl compiler class the ClassLoader before parsing the avdl.
            3. If the Idl class encounters an import that it cannot resolve to the local directory while parsing, it will try to use the ClassLoader to load up the file being imported.

          The patch spans the Avro 1.6.1 tag of the Java avro, avro-compiler, and avro-maven-plugin projects.
          Victor Chau made changes -
          Field Original Value New Value
          Attachment ImportFromClassPath.patch [ 12506545 ]
          Victor Chau created issue -

            People

            • Assignee:
              Victor Chau
              Reporter:
              Victor Chau
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development