JiBX
  1. JiBX
  2. JIBX-407

multi-modules not being detected with maven-jibx-plugin in Eclipse

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JiBX 1.2.2
    • Fix Version/s: None
    • Component/s: eclipse-plugin
    • Labels:
      None
    • Environment:
      Linux
      Eclipse Helios
    • Testcase included:
      yes
    • Number of attachments :
      1

      Description

      The project structure is:

      projectA:

      module1
      module2
      module1 - database classes
      module2 - services (depends on projectA, maven speaking).

      Test case:

      • jibx plugin configured in Module2
      • person-binding.xml in src/main/resources/jibx of Module1
      • Class Person in Module1
      • Plugin configured like:
        <modules>
        <module>org.projects:module1</module>
        </modules>
        <directory>src/main/resources/jibx</directory>
        <includes>
        <include>*-binding.xml</include>
      • Run the jibx-bind goal in Module2

      Expected result:

      Jibx would pick the -binding file in Module1, because the configuration has a reference to it

      Actual result:
      [INFO] Not running JiBX binding compiler (restricted multi-module mode) - no binding files

      I attach a sample case. It consists of the Eclipse projects referenced here.
      To check the behavior:

      • Put the projects in a workspace
      • Run the jibx:bind goal in Eclipse on Module2.

        Activity

        Hide
        Don Corley added a comment -

        Miguel,

        Yes, you are correct. Running the jibx:bind goal on Module2 will give you an error.

        Here is why:

        module2 needs access to the module1 PROJECT (not the module1 DISTRIBUTION) to access the binding file. If you build the module2 project by itself, it only knows where the module1.jar DISTRIBUTION file is in the maven repository. Remember that the binding.xml file does not even have to be in the distribution (.jar) file for jibx to work, and in fact you put it in a different location in your jar.

        A multi-module build needs access to the actual PROJECT.

        This should not be a problem for tightly integrated sub-projects such as yours. Just build from the main project:

        cd projectA
        mvn install

        (module2 builds fine, since projectA contains module1 and module2)

        If you MUST build module2 by itself, you will have to create a direct reference to the binding file in the other project:
        $

        {basedir}

        /../module1/target/classes/jibx/person-binding.xml

        I hope this answers your question. This is one of those confusing maven cases.

        Don

        Show
        Don Corley added a comment - Miguel, Yes, you are correct. Running the jibx:bind goal on Module2 will give you an error. Here is why: module2 needs access to the module1 PROJECT (not the module1 DISTRIBUTION) to access the binding file. If you build the module2 project by itself, it only knows where the module1.jar DISTRIBUTION file is in the maven repository. Remember that the binding.xml file does not even have to be in the distribution (.jar) file for jibx to work, and in fact you put it in a different location in your jar. A multi-module build needs access to the actual PROJECT. This should not be a problem for tightly integrated sub-projects such as yours. Just build from the main project: cd projectA mvn install (module2 builds fine, since projectA contains module1 and module2) If you MUST build module2 by itself, you will have to create a direct reference to the binding file in the other project: $ {basedir} /../module1/target/classes/jibx/person-binding.xml I hope this answers your question. This is one of those confusing maven cases. Don
        Hide
        Miguel Almeida added a comment -

        Thank you for the explanation Don.

        I was able to make it work by running the goal in the parent project, like you said.

        The only thing that is not clear for me is the meaning of PROJECT and DISTRIBUTION in your explanation.

        Is PROJECT the eclipse project, ie, the file structure with src/main/resources+java, and DISTRIBUTION the compiled version - the .jar file or, in case you're working in Eclipse, the /target folder of the project?

        Also, is there a way to improve the modes.html page of the documentation to explain this part a bit better, perhaps with more detailed examples (such as this one)?
        I suggest this because I read the documentation several times and couldn't figure out how to fit the explanation in my use case.

        If you agree, this ticket can be changed into a feature request for documentation enhancement.

        Regards,
        Miguel

        Show
        Miguel Almeida added a comment - Thank you for the explanation Don. I was able to make it work by running the goal in the parent project, like you said. The only thing that is not clear for me is the meaning of PROJECT and DISTRIBUTION in your explanation. Is PROJECT the eclipse project, ie, the file structure with src/main/resources+java, and DISTRIBUTION the compiled version - the .jar file or, in case you're working in Eclipse, the /target folder of the project? Also, is there a way to improve the modes.html page of the documentation to explain this part a bit better, perhaps with more detailed examples (such as this one)? I suggest this because I read the documentation several times and couldn't figure out how to fit the explanation in my use case. If you agree, this ticket can be changed into a feature request for documentation enhancement. Regards, Miguel
        Hide
        Don Corley added a comment -

        Miguel,

        Yes, you are correct.

        The 'project' is the maven project including the POM and all the files such as src/main/resources+java. The 'distribution' is the the jar file (in /target) that ends up in the maven repository. The distribution should contain only what is needed for runtime.

        I have updated the documentation to include this explanation. Please review it and give me your comments and suggestions:

        http://jibx.cvs.sourceforge.net/viewvc/jibx/maven-jibx-plugin/src/site/apt/modes.apt.vm?view=markup

        I am curious about your use case. Multi-module mode is typically used to create a JiBX binding that includes base JiBX bindings, such as a Hotel interface that builds upon a Base and Customer binding. I realize your project was just an example, but I can't think of a case where the binding file would not be in the same project as it's source code.

        I must thank you for including this example. It makes all the difference in the world in understanding a problem such as this.

        Don

        Show
        Don Corley added a comment - Miguel, Yes, you are correct. The 'project' is the maven project including the POM and all the files such as src/main/resources+java. The 'distribution' is the the jar file (in /target) that ends up in the maven repository. The distribution should contain only what is needed for runtime. I have updated the documentation to include this explanation. Please review it and give me your comments and suggestions: http://jibx.cvs.sourceforge.net/viewvc/jibx/maven-jibx-plugin/src/site/apt/modes.apt.vm?view=markup I am curious about your use case. Multi-module mode is typically used to create a JiBX binding that includes base JiBX bindings, such as a Hotel interface that builds upon a Base and Customer binding. I realize your project was just an example, but I can't think of a case where the binding file would not be in the same project as it's source code. I must thank you for including this example. It makes all the difference in the world in understanding a problem such as this. Don
        Hide
        Don Corley added a comment -

        Fixed the documentation to clarify the use of multi-module builds.

        Show
        Don Corley added a comment - Fixed the documentation to clarify the use of multi-module builds.

          People

          • Assignee:
            Don Corley
            Reporter:
            Miguel Almeida
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: