I need to add package level annotation (XmlJavaTypeAdapters type adapter). The problem is that when I run wsdl2java it generates package-info.java file for that package.
When I try to add my own package-info.java I get error: "the type package-ingo is already defined".
Is there a way to inject my annotation to package-info.java?? Maybe any other ideas?
thanks
I needed to add an annotation to generated code as well. I used the maven-replacer-plugin to do this just after the java classes were generated. You could use this solution to modify any file that comes out.
Here's the relevant pom.xml bit:
Hope this helps!
I've never tried this, but you could try adding an -xjc-npa flag to the wsdl2java command. In theory, that tells XJC to not generate a package-info.java and instead stick all the namespaces and such on all the other elements where it's needed.
You can supply JAXB "bindings", either inline in the WSDL or as a separate external binding file, and JAXB will generate the appropriate adapters and the required package-level annotations. See this question for an example.
After some research I used external mapping file. For all that have similar problem to mine I have described below what I have found.
If you are using "cxf-codegen-plugin" for generating source code from WSDL you can't use solution with package-info.java. This is because generated code propably will already contain this file. You cannot also add annotation to your class because it is generated. The only solution is to provide your own mapper.
First of all you have to write custom mapper. After that you should define xjb mapping file and finally add additional configuration to your pom.xml. You can read about first two steps here.
To add external mapping file to cxf-codegen-plugin you have to add something like this to configuration node in plugin definition:
Note that you should not pass extra parameters to xjc as described here because it will not work.
Hope this will help anybody :)