If this is the wrong group, please let me know who to contact.

I love Maven. I also love that you offer the option of creating Java Beans via 
the Execution code.

Please remove from the below "<clearOutputDir>".

Example from my pom.xml file:
              <build>
                             <plugins>
                                           <plugin>
                                                         
<groupId>org.apache.maven.plugins</groupId>
                                                          
<artifactId>maven-compiler-plugin</artifactId>
                                                          
<version>3.8.0</version>
                                                          <configuration>
                                                                        
<release>11</release>
                                                          </configuration>
                                           </plugin>
                                           <plugin>
                                                         
<groupId>org.apache.maven.plugins</groupId>
                                                          
<artifactId>maven-surefire-plugin</artifactId>
                                                          
<version>2.22.0</version>
                                                          <configuration>
                                                                        
<argLine>--illegal-access=permit</argLine>
                                                          </configuration>
                                           </plugin>
                                           <plugin>
                                                          
<groupId>org.codehaus.mojo</groupId>
                                                          
<artifactId>jaxb2-maven-plugin</artifactId>
                                                          
<version>3.1.0</version>
                                                          <executions>
                                                                        
<execution>
                                                                                
      <id>xjc</id>
                                                                                
      <goals>
                                                                                
                     <goal>xjc</goal>
                                                                                
      </goals>
                                                                        
</execution>
                                                          </executions>
                                                          <configuration>
                                                                        
<sources>
                                                                                
      <source>src/main/xsd/test.xsd</source>
                                                                        
</sources>
                                                                        
<outputDirectory>${basedir}/src/main/java</outputDirectory>
                                                                        
<clearOutputDir>false</clearOutputDir>
                                                          </configuration>
                                           </plugin>
                             </plugins>
              </build>

Why?
Every example that explains how to generate beans via XJC says not to use it. 
The process is clearly not working in a reasonable way.

Instead, please replace "<clearOutputDir>" with the below example:

<clearPackagesBeforeExecution>
    <package>edu.illinois.webservices.xyz.bean</package>
    <package>edu.illinois.webservices.abc.bean</package>
</clearPackagesBeforeExecution>
<clearPackagesAfterExecution>
    <package>edu.illinois.webservices.shared.xyz.bean</package>
    <package>edu.illinois.webservices.shared.abc.bean</package>
</clearPackagesAfterExecution>

The <clearPackagesBeforeExecution> will remove the package and code prior to 
execution. The <clearPackagesAfterExecution> will remove packages after 
execution.

Why do you need the clearPackagesAfterExecution?

Use Case:
I have a Java project that contains over 20+ XSDs and business logic. This 
shared Java Project is a Maven project that generates a jar file.

I also have 13+ Java Web Applications. Each one of these references to the 
shared Java project via Maven.

Each of the 13+ Java Web Applications has their own unique XSD that 
<xsd:imports> the XSDs from the shared Java Project. When the Java Web 
Application's are executed to build their beans, they create the same classes 
and packages as those found in the Shared Java library. This causes a problem. 
The beans from the shared Java program are also in the Java Web Applications.

By have the <clearPackagesAfterExecution> I can then remove the beans that are 
shared from the Java Web Applications after the creation of their beans. They 
don't need the beans because they are already pulled in via the share Java jar 
file.

I hope this made sense.

Thanks for considering this change.

If this is not an option to modify this XJC execution process, is there some 
way I could write my own code that could get executed after Maven executes the 
XJC process when building beans? Is there a way for me to include a link to 
code to execute that could remove the beans after they are created? I think I 
might be able to add a "plugin" that always executes that would remove packages 
from the Jave Web applications. But it seems like this is a problem for other 
people as well.

Lance

Reply via email to