3

I have a multi module project, in which one of the module ( say MODULE-A) generates sources and classes using xmlbeans plugin. So everytime when I do a clean install of parent project, eclipse recognizes all of the generated sources as new classes, and I don't want to commit the same files again and again when there is no schema change. To overcome this problem, I wrapped xmlbeans build under a profile so that I can build it with profile whenever there is a schema change. But it didn't solve the problem completely.

Whenever I try to do clean build of parent, MODULE-A is not creating 'schemaorg_apache_xmlbeans' under build directory ( which is something only generated by xmlbean plugin when I run with profile ). I can tell maven to exclude 'schemaorg_apache_xmlbeans' from the clean task. But I want to know if this is the right way to handle.

Appreciate your responses.

Thanks in advance

Lavanya
  • 319
  • 1
  • 6

1 Answers1

0

One alternative to this approach is to add this plugin:

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
               <execution>
                  <id>add-source</id>
                  <phase>generate-sources</phase>
                  <goals>
                     <goal>add-source</goal>
                  </goals>
                  <configuration>
                     <sources>
                        <source>${project.build.directory}/generated-sources/</source>
                     </sources>
                  </configuration>
               </execution>
            </executions>
         </plugin>

This will allow the generated-sources to be added as a source folder so every time it generates you will have them built and available. You wouldn't commit these but when the actual jar gets built/released they will be in there and work all the same. This allows you to always be using code most up to date with your schema. This may not be the best solution for you but I found it to be a good idea when I ran into a similar situation.

AHungerArtist
  • 9,332
  • 17
  • 73
  • 109
  • Thanks, I tried it, but it is just moving generated-classes to classes, not actually adding them to the source folder of the project – Lavanya Jul 16 '13 at 19:21
  • No, it makes it a source folder. It doesn't move anything, not to src/main/java or to /target/classes. This works for me without fail. Do you update in Eclipse/update Maven Project configuration? In case it's not clear, you'd have to change the "generated-sources" part in the element to "generated-classes" if that's where your generated java files are actually at. And you'd obviously have to remove your old ones in src/main/java the first one. After that, though, you'd never have to worry about manually doing anything. – AHungerArtist Jul 17 '13 at 01:35
  • Sorry for the confusion, I edited my question, I am having problem with 'schemaorg_apache_xmlbeans – Lavanya Jul 17 '13 at 13:59
  • Please clarify for me: Are the .java files being created when you run the plugin? If so, you can use this plugin. Perhaps a reason why it didn't work is that both this plugin and your xmlbeans plugin work on the generate-sources goal -- I'm not sure how to order those. – AHungerArtist Jul 17 '13 at 15:37
  • yes, you are right, this plugin works for java files,but in my case it is the runtime folder 'schemaorg_apache_xmlbeans' which contains .xsb files. – Lavanya Jul 17 '13 at 16:15
  • All right, I thought you meant java files when you were talking about sources. In that case, I don't have another solution for you. Good luck. – AHungerArtist Jul 17 '13 at 16:46