cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remijan, Michael J" <>
Subject RE: Force cxf-codegen-plugin to generate 1.6 class files
Date Tue, 03 Feb 2015 15:22:44 GMT
My particular problem was complicated by the requirement to first use the cxf-java2ws-plugin
to generate a WSDL off a class file in the project and then I had to use the cxf-codegen-plugin
plugin to generate the clients for that WSDL.  Because cxf-java2ws-plugin needs the .class
files to generate a WSDL, most examples using this plugin bind it to <phase>process-classes</phase>
which then necessitates cxf-codegen-plugin to be bound to <phase>process-classes</phase>.
 At this point we were past the normal Maven compile lifecycle so we used the -compile option
of cxf-codegen-plugin to compile the code.  When cxf-codegen-plugin compiles the code it doesn't
use the configuration options of the maven-compiler-plugin which manifested my problem. 

To get around all this, I bound the maven-compiler-plugin to <phase>generate-sources</phase>
so that the project code can basically be pre-compiled before the normal maven compile lifecycle
phase. Then I bound cxf-java2ws-plugin and cxf-codegen-plugin to <phase>process-sources</phase>
which generates the WSDL and the source files from the WSDL before the normal maven lifecycle
comple phase as well.  So by the time I get to the normal maven lifecycle phase, everything
has been pre-compile, the WSDL has been generated, and the source files from the WSDL have
been generated.  The generated source files then get picked up the the normal maven lifecycle
compile phase and this resolved my problem.

So this is a work-around to the problem.  The better solution is to allow JVM arguments to
be set when  cxf-codegen-plugin using the -compile option to compile the generated code. 

-----Original Message-----
From: Aki Yoshida []
Sent: Monday, February 02, 2015 4:55 PM
Subject: Re: Force cxf-codegen-plugin to generate 1.6 class files

Ahh. Okay.
Is there something preventing you from letting maven-compilar-plugin compile your generated
source files along with the other sources all together to the specified target version?
regards, aki

2015-01-30 14:36 GMT+01:00 Remijan, Michael J <>:
> Below are the details of the plugin.  The cxf-codegen-plugin has the -compile option
which will compile the code.  It's this compiled code which is being generated as jdk 1.7
class files, not jdk 1.6 class files.
> <plugin>
>   <groupId>org.apache.cxf</groupId>
>   <artifactId>cxf-codegen-plugin</artifactId>
>   <version>2.7.0</version>
>   <executions>
>     <execution>
>       <id>wsdl2java-process</id>
>       <phase>process-classes</phase>
>       <configuration>
>         <fork>always</fork>
>         <wsdlOptions>
>           <wsdlOption>
>             <wsdl>${ws.wsdl.location}</wsdl>
>             <extraargs>
>               <extraarg>-p</extraarg>
>               <extraarg>gov.the.proj.packge</extraarg>
>               <extraarg>-compile</extraarg>
>               <extraarg>-classdir</extraarg>
>               <extraarg>${basedir}/target/classes</extraarg>
>             </extraargs>
>           </wsdlOption>
>         </wsdlOptions>
>       </configuration>
>       <goals>
>         <goal>wsdl2java</goal>
>       </goals>
>     </execution>
>   </executions>
> </plugin>
> -----Original Message-----
> From: Aki Yoshida []
> Sent: Friday, January 30, 2015 4:27 AM
> To:
> Subject: Re: Force cxf-codegen-plugin to generate 1.6 class files
> I don't know if I understand your setup correctly. The codegen plugin generates source
files and they have nothing to do with those cafe babe numbers. These numbers go into the
class files. So, if you are compiling the generated source files in the same build unit as
the main source files, you should be getting the same number in all those generated classes.
> 2015-01-29 21:44 GMT+01:00 Remijan, Michael J <>:
>> Greetings,
>> I have a question about the class files generated by the cxf-codegen-plugin.  I would
like to configure the plugin and force it to generate JDK 1.6 class files but haven't been
able to figure out a way to do this.  The JDK I'm using is 1.7 and my Maven build has configured
the maven-compiler-plugin with <source>1.6</source> and <target>1.6</target>.
This works great on the project source files; the resulting class files have a major version
number to 50, which is the Java 1.6 major version.  However it does NOT work when the cxf-codegen-plugin
runs.  The class files generated by cxf-codegen-plugin have a major version number of 51,
which is Java 1.7.  This make sense since that's the version of Java I'm running, but I need
the cxf-codegen-plugin to generate java 1.6 class files regardless of the Java version running
Maven.  Now keeping an eye on the machine processes during the build process, it looks like
the cxf-codegen-plugin is creating a file c:\users\[username]\AppData\Local\Temp\org.codehaus.plexus.compiler.javac.JavacCompiler440340304580348034arguments.
 This file as inside it "-target" "1.6" "-source" "1.6".  So it looks like the plugin is correctly
getting the source and target values from the maven-compiler-plugin, but at some point they
are being ignored.
>> So thoughts on this?  How can I configure cxf-codegen-plugin to always generate Java
1.6 class files (major version 50) regardless of the version of Java used to run Maven?
>> Thanks!
View raw message