Maven jaxws plugin - skip execution - java

I'm using the JAX-WS maven plugin (org.jvnet.jax-ws-commons:jaxws-maven-plugin version 2.2) to generate classes from a bunch of WSDL files in my project, and as the WSDLs never really change I would like to disable this code generation by default, and only enable it for a particular maven profile I've created. The element of this plugin supports a element, but setting this to true seems to do nothing. Am I doing something wrong here? Or is this a known bug, and is there something else I could do to avoid this code generation?
My plugin configuration looks like this:
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>import-wsdld</id>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFiles>
<wsdlFile>MyWSDL.wsdl</wsdlFile>
</wsdlFiles>
</configuration>
</execution>
</executions>
<configuration>
<skip>true</skip>
<packageName>com.my.package</packageName>
<wsdlDirectory>src/main/resources/wsdl</wsdlDirectory>
<keep>true</keep>
<xnocompile>true</xnocompile>
<sourceDestDir>src/main/java</sourceDestDir>
<verbose>false</verbose>
</configuration>
<!-- Necessary to revert back to 2.1.7 -->
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.1.7</version>
<exclusions>
<exclusion>
<groupId>org.jvnet.staxex</groupId>
<artifactId>stax-ex</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jvnet.staxex</groupId>
<artifactId>stax-ex</artifactId>
<version>1.2</version>
<exclusions>
<exclusion>
<groupId>javax.xml.stream</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
Many thanks,
Joseph.

Well, just do it (I mean plugin declaration with all its stuff) in <profile> block. I wouldn't rely on some magic plugin-specific solutions. Just use what Maven offers out-of-the-box and create <profile> with your <plugin> stuff.

Based on the documentation of the plugin it has not "skip" parameter which of course means it will not support. The best solution is to put that into a profile as mentioned before.

Related

Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.5.4:wsdl2java

I'm trying to generate the code from WSDL file with CXF in Maven. Currently using Java 19 which I'd like to keep.
My plugin is configured with:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.5.4</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/wsdl/sample.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>4.0.1</version>
</dependency>
<!--dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>4.0.1</version>
</dependency-->
</dependencies>
</plugin>
And always get error:
[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.5.4:wsdl2java (default) on project customsx: Execution default of goal org.apache.cxf:cxf-codegen-plugin:3.5.4:wsdl2java failed: A required class was missing while executing org.apache.cxf:cxf-codegen-plugin:3.5.4:wsdl2java: javax/xml/bind/annotation/adapters/HexBinaryAdapter
I'm familiar with the bind-api removal in Java 11, and always was able to solve usual JAXB troubles using jakarta libs.
In this particular case the error seems to come from wsdl2java itself. If I do not set the jakarta dependencies the error is exclusively on javax.xml.bind.annotation as expected. If I add the dependency the error is now on HexBinaryAdapter, which I can't seem able to solve.
Any ideas ?

Exclude slf4j from glassfish

I referred so many links. I finally got this And I don't prefer this way
I want to exclude slf4j from this jar. It is glassfish embedded all.
Why do I want to Exclude?
It is a different story. If I include this slf4j, then AKKA event logging is not working due to multiple slf4j. If I exclude embedded jar completely logging works. But I need embedded jar but not glassfish slf4j.
Any Solution?
Glassfish' Pom. It seems slf4j is a transitive dependancy
Have you try something like:
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>4.0-b72</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
UPDATE
The slf4j classes are embedded. If you still want to work with an uber jar, an option is to shade glassfish-embedded-all, i.e. to create a maven project or a module with:
<dependencies>
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>4.0-b72</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>**/org/slf4j/**/*</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
and then to use the generated jar in place of glassfish-embedded-all.

How to exclude dependencies in Maven <reporting> plugins?

How do I exclude dependencies from a reporting Maven plugin? The cobertura-maven-plugin annoyingly pulls in ch.qos.logback:logback-classic which causes mulitple SLF4J bindings warning during build and run. I tried inserting <dependencies> with <exclusions> to the plugin but maven for some reason does not allow that in the <reporting> section. Any help is appreciated. The relevant POM is below.
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.8</version>
<configuration>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
</plugin>
</plugins>
</reporting>
This is old but I'll give my solution in case someone else has this exact issue. In my poms I inserted the following
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.7</version>
</dependency>
</dependencies>
Inside the definition for my Cobertura plugin.
Cobertura is using 1.1.7 anyway (in my case) check your artifacts to confirm, you just need to explicitly tell maven to pull that version when creating the plugin otherwise it will still pull the conflicting version and display the error
I have solved this issue including the "scope" tag inside logback dependencies.
This is my POM section:
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback-classic-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback-core-version}</version>
<scope>runtime</scope>
</dependency>

Dependency on dependency leading to SNAPSHOT dependency in Maven

I am trying to use Maven for a Java Application I am writing and am trying to use Java2WSDL with
<plugin>
<groupId>org.apache.axis2.maven2</groupId>
<artifactId>axis2-java2wsdl-maven-plugin</artifactId>
<version>${java2wsdl.version}</version>
<configuration>
<className>com.barclays.hypercube.marketdata.Model.PointSeriesClient</className>
</configuration>
<executions>
<execution>
<goals>
<goal>java2wsdl</goal>
</goals>
</execution>
</executions>
</plugin>
It seems that there is a dependency on
org.apache.ws.commons.axiom:axiom-api:jar:SNAPSHOT
Unsurprisingly this is not available from my Maven repository.
Is there any way to override this? Perhapos with a value in my settings.xml file.
You can exclude that unwanted jar from this maven. But first make sure you do not need this jar. Like here
<project>
...
<dependencies>
<dependency>
<groupId>sample.ProjectA</groupId>
<artifactId>Project-A</artifactId>
<version>1.0</version>
<scope>compile</scope>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>sample.ProjectB</groupId>
<artifactId>Project-B</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

Eclipse, QueryDSL and Spring Roo working together?

I'm trying to set up a maven-based SpringRoo project with QueryDSL in Eclipse and cannot seem to get the generator working when I have Roo enabled. If I create a plain project, and populate my pom.xml with the necessary querydsl plugins/dependencies, my metamodel classes are automatically generated.
However, if I switch to a basic ROO project, and add the necessary querydsl plugins/dependencies, then no metamodel classes are generated.
These are the additions I've put in my pom.xml:
<!-- Querydsl -->
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-core</artifactId>
<version>${querydsl.version}</version>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>${querydsl.version}</version>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>${querydsl.version}</version>
</dependency>
<plugin>
<!-- Requires mysema m2e plugin (http://ilx.github.com/m2e-querydsl/repository/0.0.5/) -->
<groupId>com.mysema.maven</groupId>
<artifactId>maven-apt-plugin</artifactId>
<version>1.0.4</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<logOnlyOnError>true</logOnlyOnError>
<outputDirectory>target/generated-sources/apt</outputDirectory>
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>${querydsl.version}</version>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<classifier>apt</classifier>
<version>${querydsl.version}</version>
</dependency>
</dependencies>
</plugin>
<!-- right now this seems needed -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/apt</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
I am using Eclipse 3.7, m2e 1.2, Java 6. I also have the mysema m2e plugin installed from http://ilx.github.com/m2e-querydsl/repository/0.0.5/.
Does anyone have a working configuration with Roo and QueryDSL that works? If so, can you share your pom.xml please?
Thanks,
Eric
com.mysema.query.apt.jpa.JPAAnnotationProcessor needs javax.persistence.Entity annotated Java files. If you use other annotations or add the Entity annotation at runtime, no classes will be generated.
See this chapter of the Querydsl reference docs for classloader based code generation as an alternative to APT http://www.querydsl.com/static/querydsl/2.8.2/reference/html/ch03s02.html
For some reason that I do not understand, I needed to add a spring-tx dependency to my pom.xml. Once that was in place, the metamodel classes were automatically generated. There was a caveat however, I needed to manually annotate my entities with #Entity and not rely on Roo to annotate it via aspects. Finally, updating my plugin to 1.0.7 removed the need to use maven-build-helper.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- QueryDSL plugin -->
<plugin>
<!-- Requires mysema m2e plugin (http://ilx.github.com/m2e-querydsl/repository/0.0.5/) -->
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.0.7</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/apt</outputDirectory>
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>${querydsl.version}</version>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<classifier>apt</classifier>
<version>${querydsl.version}</version>
</dependency>
</dependencies>
</plugin>
Sample Java Bean:
#RooJavaBean
#RooToString
#RooJpaEntity
#Entity
public class Client {
#Temporal(TemporalType.TIMESTAMP)
#DateTimeFormat(style = "M-")
private Date created_on;
private String name;
}
There's old discussion about this topic, where Ken Rimple states that " I had trouble getting anything to work on the QueryDSL generators with the pre-built ITDs. Since the actual class doesn't have an #Entity on it (until the AspectJ compiler comes in and adds it) when the QueryDSL is generating code, it doesn't see them as entities."
http://www.manning-sandbox.com/thread.jspa?threadID=51012&tstart=15
To me this seems to be something one could try to tweak by changing order in which maven is using plugins (lifecycle phases).

Categories