-
Hi! I am trying to generate java-classes from a set of wsdl's that I have. I am trying to convert the following maven profile to use your plugin with gradle: <profiles>
<profile>
<id>wsdl</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${apache.cxf.version}</version>
<executions>
<!-- Generate elhub classes from the WSDLs and modify them to have common inheritance where applicable. -->
<execution>
<id>elhub</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/src/main/java</sourceRoot>
<defaultOptions>
<extraargs>
<extraarg>-impl</extraarg>
<extraarg>-xjc-Xts</extraarg>
<extraarg>-xjc-Xequals</extraarg>
<extraarg>-xjc-XhashCode</extraarg>
<extraarg>-xjc-Xinheritance</extraarg>
</extraargs>
<bindingFiles>
<!-- Global bindings -->
<bindingFile>${basedir}/src/main/resources/bindings/global.xml</bindingFile>
<!-- Bindings -->
<bindingFile>${basedir}/src/main/resources/bindings/bim/Acknowledgement.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/PollForData.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/common/Elhub_AggregatedBusinessInformationEntities.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/common/Elhub_BusinessDataType.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/market/ConfirmEndOfSupply.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/market/ConfirmStartOfSupply.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/market/NotifyEndOfSupply.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/market/NotifyStartOfSupply.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/market/RejectEndOfSupply.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/market/RejectStartOfSupply.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/market/RequestEndOfSupply.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/market/RequestStartOfSupply.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/masterdata/NotifyCustomerInformation.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/masterdata/NotifyMeteringPointCharacteristics.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/masterdata/RequestUpdateCustomerInformation.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/masterdata/RequestUpdateMasterDataMeteringPoint.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/metering/CollectedData.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/metering/NotifyValidatedDataForBillingEnergy.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/metering/PriceVolumeCombinationForReconciliation.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/metering/RequestCollectedData.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/query/RequestDataFromElhub.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/query/RequestToElhub.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/query/RequestToGridAccessProvider.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/query/RequestUpfrontMeteringPointCharacteristics.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/query/ResponseFromElhub.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/query/ResponseFromGridAccessProvider.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/query/ResponseUpfrontMeteringPointCharacteristics.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/bim/thirdpartyaccess/UpdateThirdPartyAccess.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/MarketProcesses.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/MeteringValues.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/PollMarketProcesses.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/PollMeteringValues.xml</bindingFile>
<bindingFile>${basedir}/src/main/resources/bindings/Query.xml</bindingFile>
<!-- XSD -->
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/Acknowledgement.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/PollForData.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/common/Elhub_AggregatedBusinessInformationEntities.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/common/Elhub_BusinessDataType.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/market/ConfirmEndOfSupply.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/market/ConfirmStartOfSupply.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/market/NotifyEndOfSupply.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/market/NotifyStartOfSupply.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/market/RejectEndOfSupply.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/market/RejectStartOfSupply.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/market/RequestEndOfSupply.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/market/RequestStartOfSupply.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/masterdata/NotifyCustomerInformation.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/masterdata/NotifyMeteringPointCharacteristics.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/masterdata/RequestUpdateCustomerInformation.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/masterdata/RequestUpdateMasterDataMeteringPoint.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/metering/CollectedData.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/metering/NotifyValidatedDataForBillingEnergy.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/metering/PriceVolumeCombinationForReconciliation.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/metering/RequestCollectedData.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/query/RequestDataFromElhub.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/query/RequestToElhub.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/query/RequestToGridAccessProvider.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/query/RequestUpfrontMeteringPointCharacteristics.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/query/ResponseFromElhub.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/query/ResponseFromGridAccessProvider.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/query/ResponseUpfrontMeteringPointCharacteristics.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/bim/thirdpartyaccess/UpdateThirdPartyAccess.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/wsdl/xsd/common.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/wsdl/xsd/MarketProcesses.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/wsdl/xsd/MeteringValues.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/wsdl/xsd/PollMarketProcesses.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/wsdl/xsd/PollMeteringValues.xsd</bindingFile>
<bindingFile>${basedir}/src/main/resources/no/elhub/wsdl/xsd/Query.xsd</bindingFile>
</bindingFiles>
</defaultOptions>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/no/elhub/wsdl/MarketProcesses.wsdl</wsdl>
<extraargs>
<extraarg>-wsdlLocation</extraarg>
<extraarg>classpath:no/elhub/wsdl/MarketProcesses.wsdl</extraarg>
</extraargs>
</wsdlOption>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/no/elhub/wsdl/PollMarketProcesses.wsdl</wsdl>
<extraargs>
<extraarg>-wsdlLocation</extraarg>
<extraarg>classpath:no/elhub/wsdl/PollMarketProcesses.wsdl</extraarg>
</extraargs>
</wsdlOption>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/no/elhub/wsdl/Query.wsdl</wsdl>
<extraargs>
<extraarg>-wsdlLocation</extraarg>
<extraarg>classpath:no/elhub/wsdl/Query.wsdl</extraarg>
</extraargs>
</wsdlOption>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/no/elhub/wsdl/MeteringValues.wsdl</wsdl>
<extraargs>
<extraarg>-wsdlLocation</extraarg>
<extraarg>classpath:no/elhub/wsdl/MeteringValues.wsdl</extraarg>
</extraargs>
</wsdlOption>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/no/elhub/wsdl/PollMeteringValues.wsdl</wsdl>
<extraargs>
<extraarg>-wsdlLocation</extraarg>
<extraarg>classpath:no/elhub/wsdl/PollMeteringValues.wsdl</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.cxf.xjcplugins</groupId>
<artifactId>cxf-xjc-ts</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.12.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles> My current implementation looks like this in build.gradle,kts configurations.cxfCodegen {
resolutionStrategy.eachDependency {
if (requested.group == "org.apache.cxf") {
useVersion("3.2.6")
}
}
}
/**
* Generating java class(es) from WSDL.
*/
tasks {
register("MarketProcessesService", io.mateo.cxf.codegen.wsdl2java.Wsdl2Java::class) {
toolOptions {
wsdl.set(file("${projectDir}/src/main/resources/elhub/wsdl/MarketProcesses.wsdl"))
extraArgs.add("-wsdlLocation")
extraArgs.add("classpath:no/elhub/wsdl/MarketProcesses.wsdl")
}
}
register("MeteringValuesService", io.mateo.cxf.codegen.wsdl2java.Wsdl2Java::class) {
toolOptions {
wsdl.set(file("${projectDir}/src/main/resources/elhub/wsdl/MeteringValues.wsdl"))
extraArgs.add("-wsdlLocation")
extraArgs.add("classpath:no/elhub/wsdl/MeteringValues.wsdl")
}
}
register("PollMarketProcessesService", io.mateo.cxf.codegen.wsdl2java.Wsdl2Java::class) {
toolOptions {
wsdl.set(file("${projectDir}/src/main/resources/elhub/wsdl/PollMarketProcesses.wsdl"))
extraArgs.add("-wsdlLocation")
extraArgs.add("classpath:no/elhub/wsdl/PollMarketProcesses.wsdl")
}
}
register("PollMeteringValuesService", io.mateo.cxf.codegen.wsdl2java.Wsdl2Java::class) {
toolOptions {
wsdl.set(file("${projectDir}/src/main/resources/elhub/wsdl/PollMeteringValues.wsdl"))
extraArgs.add("-wsdlLocation")
extraArgs.add("classpath:no/elhub/wsdl/PollMeteringValues.wsdl")
}
}
register("QueryService", io.mateo.cxf.codegen.wsdl2java.Wsdl2Java::class) {
toolOptions {
wsdl.set(file("${projectDir}/src/main/resources/elhub/wsdl/Query.wsdl"))
extraArgs.add("-wsdlLocation")
extraArgs.add("classpath:no/elhub/wsdl/Query.wsdl")
}
}
}
tasks.withType(io.mateo.cxf.codegen.wsdl2java.Wsdl2Java::class).configureEach {
toolOptions {
markGenerated.set(false)
outputDir.set(file("$buildDir/generated-java"))
}
} The code above will generate the java-classes directly from wsdl, but we want to modify the wsdl some what. Hence the use of extraargs for -xjc options and the use of custom bindingsfile that we have created. Do you know how and if the plugin can be used to add this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Yes, you can use the Based on your Maven configuration, something like: dependencies {
cxfCodegen("org.apache.cxf.xjcplugins:cxf-xjc-ts:3.3.1")
cxfCodegen("org.jvnet.jaxb2_commons:jaxb2-basics:0.12.0")
}
tasks.withType(Wsdl2Java::class).configureEach {
toolOptions {
extraArgs.add("-impl")
xjcArgs.add("-xjc-Xtsl")
xjcArgs.add("-xjc-Xequals")
bindingFiles.add(layout.projectDirectory.file("/src/main/resources/bindings/global.xml").asFile.absolutePath)
bindingFiles.add(layout.projectDirectory.file("/src/main/resources/bindings/bim/Acknowledgement.xml").asFile.absolutePath)
}
}
|
Beta Was this translation helpful? Give feedback.
-
Additionally, the usage of tasks.register("example", Wsdl2Java::class) {
toolOptions {
wsdlLocation.set("classpath:no/elhub/wsdl/Query.wsdl")
}
} |
Beta Was this translation helpful? Give feedback.
-
Hi @ciscoo that worked like a charm! Thx, closing this ticket :) |
Beta Was this translation helpful? Give feedback.
Yes, you can use the
xjcArgs
list property.https://ciscoo.github.io/cxf-codegen-gradle/docs/current/api/io/mateo/cxf/codegen/wsdl2java/Wsdl2JavaOptions.html#getXjcArgs()
Based on your Maven configuration, something like: