Does -nexclude work when using JiBX as the CXF databining? - wsdl

I am trying to get CXF (2.7.7) to use JiBX (1.2.5) for databinding. The documentation is a bit sketchy, but there have been reports of success with it. One problem is that CXF does not pass configuration to the JiBX code generator, so if you need to do something that requires customization, such as mapping Joda DateTime to XML Schema date, you need to be able to tell CXF to ignore specific namespaces and then handle those with a separate call to JiBX.
The examples I have seen use the CXF -nexclude flag for this purpose, as in
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generateSources</id>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2java</goal>
</goals>
<configuration>
<sourceRoot>${generated-sources.dir}/cxf</sourceRoot>
<wsdlRoot>${wsdl.dir}</wsdlRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${wsdl.dir}/GetCounters.wsdl</wsdl>
<dataBinding>jibx</dataBinding>
<extraargs>
<extraarg>-nexclude</extraarg>
<extraarg>http://www.example.com/counters/</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
</execution>
</executions>
</plugin>
I have tried both inline and imported versions of the namespace but the -nexclude flag does not appear to work with JiBX. One option might be to let JiBX do the whole WSDL without invoking the CXF plugin, but apparently this creates problems in the generated service code. An ugly workaround might be to let JiBX regenerate the code for just the classes in this namespace, overwriting the code created by CXF.
Can the -nexclude flag be made to work?

I was having a similar problem while using jaxb. This worked for me:
move the extraargs out of the wsdlOption section and into the defaultOptions section.
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cfx.codegen.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<defaultOptions>
<extraargs>
<extraarg>-nexclude</extraarg>
<extraarg>http://domain.company.org/v1/schema1</extraarg>
<extraarg>-nexclude</extraarg>
<extraarg>http://domain.company.org/v1/schema2</extraarg>
</extraargs>
</defaultOptions>
<wsdlOptions>
<wsdlOption>
<wsdlArtifact>
<groupId>org.company</groupId>
<artifactId>application-contract</artifactId>
<version>${contract.version}</version>
<type>wsdl</type>
</wsdlArtifact>
</wsdlOption>
</wsdlOptions>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>

Related

openapi-generator-maven-plugin code gen from http

Can we pass input yml specification HTTP URL in openapi-generator-maven-plugin?
I wanted to keep the input specification and generated code in sync.
Yes, with openapi-generator-maven-plugin that is possible by simply giving URL including protocol as inputSpec:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.4.0</version>
<executions>
<execution>
...
<configuration>
<inputSpec>https://petstore3.swagger.io/api/v3/openapi.yaml</inputSpec>
...
</configuration>
</execution>
</executions>
</plugin>
Updating plugin version might be necessary.

Maven - Shade Plugin doesn't work when creating Manifests

I have tried shading my jar using a custom manifest file and also manifest entries. In both cases, it's not even accepting any manifest file.
I have looked into Apache Maven docs for Shade plugin and it's not working as per the docs.
Here is my Shade Config:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>kafkapub.main.app.MainApp</mainClass>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</transformer>
</transformers>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>launcher</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Has anyone seen similar issues ?
I think I sorted the issue.
Basically it created the -shaded artifacts. And since there were three jars:
original-*.jar
*.jar
*-shaded.jar
It was quite confusing. But I can see everything in the Shaded jar now thanks.

CXF wsdl2java set wsdlLocation of multiple wsdl

I trying to generate classes through CXF wsdl2java of multiple wsdl files. But I can't set the wsdl location of these wsdl files in a relative path into project. I have seen a solution setting options of each wsdl like this:
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${project.basedir}/src/main/resources/wsdl/FooService.wsdl</wsdl>
<wsdlLocation>classpath:wsdl/FooService.wsdl</wsdlLocation>
</wsdlOption>
</wsdlOptions>
</configuration>
But I don't want to do this of each case. I have this in my code:
<configuration>
<sourceRoot>${generated.dir}</sourceRoot>
<defaultOptions>
<noAddressBinding>true</noAddressBinding>
<bindingFiles>
<bindingFile>${basedir}/src/main/resources/META-INF/cxf/date-binding.xml
</bindingFile>
</bindingFiles>
</defaultOptions>
<wsdlOption>
<extraargs>
<extraarg>-fe</extraarg>
<extraarg>jaxws21</extraarg>
</extraargs>
</wsdlOption>
<wsdlRoot>${basedir}/src/main/resources/META-INF/cxf/wsdl</wsdlRoot>
<includes>
<include>*.wsdl</include>
</includes>
</configuration>
How can I set wsdlLocation in all wsdl's without set each one?
I got it.
You must add a wsdlRoot section in your configuration. Furthermore you must add a include section with wildcards.
This is my plugin section
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlRoot>${basedir}/src/main/resources/wsdl/</wsdlRoot>
<includes>
<include>**/*.wsdl</include>
</includes>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>

Maven not honoring excludes

We have this in our pom
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<excludes>
<exclude>app/**</exclude>
<exclude>WEB-INF/**</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>assembly-web</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>web</classifier>
<includes>
<include>app/**</include>
<include>WEB-INF/**</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
When I open the xxx-web.jar it looks as expected, but when I look at xxx.jar it includes everything/didn't exclude anything. If I were to add a classified to the 1st plugin (the one with the excludes) then it works properly???
I want this to work in such a way that the xxx.jar has all the class and property files and the xxx-web only has the jsp/css files.
Take a look at 7.1.6 in this maven document. Basically you need to bind to the default goal of "default-jar".
HTH
Take a look at this: Maven and working with legacy app there you will find the complete solution for your problem.
You're telling maven to execute twice with each <execution> command. Try putting the includes and excludes under the same execution.

Installing a wsdl file into a Maven repository

I'm trying to install a wsdl file into a remote Maven repository so I can reference it in a CXF project as per this blog post.
I'm sure it could be done manually, but I want an actual maven project so I can make use of the release plugin for tagging etc.
Has anybody got experience with this?
You can use the build helper maven plugin to do this. Here is an indicative code snippet
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${wsdlLocation}/project.wsdl</file>
<type>wsdl</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build.

Resources