Trying to generate class from xsd located in dependencies - maven-jaxb2-plugin

For my project, I need to get xsd schemas that are kept in another project and generate my classes using maven-jaxb2-plugin. I am trying to get these Shema through my dependency (integration-pubsub-global-config), but I keep getting errors : [ERROR] Error while parsing schema(s).Location []. Here is my configuration for the plugin :
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.2</version>
<executions>
<execution>
<id>generate-sources-message</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<extension>true</extension>
<args>
<arg>-XtoString</arg>
<arg>-Xequals</arg>
<arg>-XhashCode</arg>
</args>
<bindingDirectory>${basedir}/src/main/jaxws</bindingDirectory>
<bindingIncludes>
<include>bindings.xml</include>
</bindingIncludes>
<schemas>
<schema>
<dependencyResource>
<groupId>com.XXXXX.YYYYYY-YYYY.integration</groupId>
<artifactId>integration-pubsub-global-config</artifactId>
<resource>src/export/pubsub-xsd-contracts/SM840-IntegrationEvenements/Donnees/Event/EventV3.xsd</resource>
</dependencyResource>
</schema>
</schemas>
<generateDirectory>${cxf.generated.sources.folder}</generateDirectory>
<enableIntrospection>true</enableIntrospection>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.5.3</version>
</plugin>
</plugins>
</configuration>
</execution>
</executions>
</plugin>

Related

The generated IntegrationContent client code miss several methods

I generated the client code of IntegrationContent following the guidance(https://api.sap.com/api/IntegrationContent/cloud-sdk/Java) https://api.sap.com/api/IntegrationContent/cloud-sdk/Java.
According to the guidance, I downloaded the edmx,and config my maven plugin as below.
Acctually, I generated the code; but comparing to the apihub(https://api.sap.com/api/IntegrationContent/resource), some methods are lost.
Can anyone help on this?
<plugin>
<groupId>com.sap.cloud.sdk.datamodel</groupId>
<artifactId>odata-generator-maven-plugin</artifactId>
<!-- Please use always the latest version. You can find it on this page.-->
<version>3.64.0</version>
<executions>
<execution>
<id>generate-consumption</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputDirectory>${project.basedir}/edmx</inputDirectory>
<outputDirectory>${project.build.directory}/vdm</outputDirectory>
<deleteOutputDirectory>true</deleteOutputDirectory>
<packageName>com.sample</packageName>
<defaultBasePath>odata/v4/</defaultBasePath>
<compileScope>COMPILE</compileScope>
<serviceMethodsPerEntitySet>true</serviceMethodsPerEntitySet>
</configuration>
</execution>
</executions>
</plugin>

How to configure suppress ParameterNumber on checkstyle?

How to configure to suppress the number of parameter (ParameterNumber) on checkstyle:
Checkstyle configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>9.1</version>
</dependency>
</dependencies>
<configuration>
<configLocation>/config/checkstyle.xml</configLocation>
<suppressionsLocation>/config/checkstyle-suppressions.xml</suppressionsLocation>
<suppressionsFileExpression>checkstyle.suppressions.file</suppressionsFileExpression>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
checkstyle-suppressions.xml file:
<suppressions>
<suppress checks="ParameterNumber" files="src/main/java/org/acme/Signal.java" />
</suppressions>
I still got the message:
Signal.java:[247,26] (sizes) ParameterNumber: More than 7 parameters (found 15).
https://checkstyle.sourceforge.io/config_filters.html#SuppressionFilter
Location of the file defined in file property is checked in the
following order:
as a filesystem location
if no file found, and the location starts with either http:// or https://, then it is interpreted as a URL
if no file found, then passed to the ClassLoader.getResource() method.
Use the package exactly is in java:
<suppress
checks="ParameterNumber"
files="org.acme.Signal.java" />

Generate code for multiple swaggers in the same project

How do i generate code for multiple swagger files from within the same module/project in one pom.xml.
In my application client had provided a swagger and we have one of the backend API to be called for which they provided swagger. I want to generate code for both of these in the same project. One way i was thinking is create separate module and execute the plugin separately and have those dependencies called out in main module.
How do i generate code from one build plugin? Please point me to existing one if it is a repost. I couldn't find any.
Here is the plugin i configured in pom.xml
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/ resources/Service.json</inputSpec><inputSpec>${project.basedir}/src /main/resources/Client.json</inputSpec>
<language>java</language>
<configOptions>
<dateLibrary>java8</dateLibrary>
</configOptions>
<modelPackage>com.service.model</modelPackage>
<environmentVariables>
<models/>
<supportingFiles>false</supportingFiles>
</environmentVariables>
</configuration>
</execution>
</executions>
</plugin>
Also tried *.json. At anytime it is taking only one json file and generating the code.
In order to do this you could declare a different execution for each json file, each one should have a unique id.
Here is an example with two executions, execution-first-json for the file first.json and execution-second-json for the file second.json
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>execution-first-json</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/first.json</inputSpec>
<language>java</language>
<configOptions>
<dateLibrary>java8</dateLibrary>
</configOptions>
<modelPackage>com.service.model</modelPackage>
<environmentVariables>
<models/>
<supportingFiles>false</supportingFiles>
</environmentVariables>
</configuration>
</execution>
<execution>
<id>execution-second-json</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/second.json</inputSpec>
<language>java</language>
<configOptions>
<dateLibrary>java8</dateLibrary>
</configOptions>
<modelPackage>com.service.model</modelPackage>
<environmentVariables>
<models/>
<supportingFiles>false</supportingFiles>
</environmentVariables>
</configuration>
</execution>
</executions>
</plugin>

maven-jaxb2-plugin ignoring configuration

I'm using maven 3.3.9 and the maven-jaxb2-plugin 0.13.1. But when I try to generate the Java classes, the plugin is not finding my XSD-file.
My pom looks like this:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/schemas</schemaDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Everytime I'm executing the goal, I get this message:
[WARNING] No schemas to compile. Skipping XJC execution.
The directory exists under the resources folder, and the XSD is placed there. I have no other pom-files in play.
Any help would be very much appreciated
In case anyone else will hit this. I had a similar issue: the configuration was not picked up by the plugin. I made it work by moving configuration section under plugin declaration instead of execution.
Here's how the working configuration looked like for me (I removed the upper-level elements since they do not matter):
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.15.1</version>
<configuration>
<schemaDirectory>src/main/resources/custom-schemas</schemaDirectory>
</configuration>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
/executions>
</plugin>
Author of maven-jaxb2-plugin here.
Somehow I have a feeling that you're omitting important details. This does not not add up. This is a very basic configuration setting, I'm curious how it can't work.
You only post the pluginManagement part of your pom.xml. If you have just this, it should not work at all as it is just and only a declaration of configuration, not actual usage of the plugin. You need plugins/plugin to actually apply the plugin:
<project ...>
...
<build>
<plugins>
...
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>...</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
...
</project>
To analyze the problem, run mvn -X clean generate-sources or mvn -X clean install and check the applied configuration (it will be logged). Post the log here.
If this does not help, send me a PR of a minimal reproducing project under https://github.com/highsource/maven-jaxb2-plugin-support/s/schemaDirectory, I'll take a look.

Scalatest html reports

I'm trying to get an html report of the scalatest and I've found a lot of configurations like this:
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0-M2</version>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<testFailureIgnore>true</testFailureIgnore>
<filereports>NCXEHLOWFD file/constrained.txt,file/full.txt</filereports>
<xmlreports>xml</xmlreports>
<htmlreports>html/report.html</htmlreports>
</configuration>
<executions>
<execution>
<id>test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
But IntelliJ tells me that xmlreports and htmlreports are not allowed, and no xml or html reports are generated.
Can anyone suggest anything?
I'll be very thankful
You need to use the latest plugin version currently available 1.0-M4-SNAP1 instead of 1.0-M2 which doesn't have htmlreports property. Here are important part from my pom.xml:
<project>
<properties>
<scala.version>2.9.3</scala.version>
<scalatest.version>2.0.M5b</scalatest.version>
<scalatest.plugin.version>1.0-M4-SNAP1</scalatest.plugin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>${scalatest.plugin.version}</version>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>WDF TestSuite.txt</filereports>
<htmlreporters>${project.build.directory}/html/scalatest</htmlreporters>
<testFailureIgnore>false</testFailureIgnore>
</configuration>
<executions>
<execution>
<id>test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.version}</artifactId>
<version>${scalatest.version}</version>
<scope>test</scope>
</dependency>
<!-- required by scalatest-maven-plugin to generate HTML report -->
<dependency>
<groupId>org.pegdown</groupId>
<artifactId>pegdown</artifactId>
<version>1.2.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
With this setting I can run mvn clean install and it will produce nice HTML report under ${project.build.directory}/html/scalatest
#rozky's solution works for me but the css is awkward. It doesn't display the table correctly. It doesn't show me the suite name column in the table no matter what version of pegdown and scalatest-maven-plugin I use :/