I need to include more than one WSDL in my Maven JAXWS configuration and I need to specify different output directories for them since some of the method names in wsdlA conflict with method names in wsdlB. I'm using org.jvnet.jax-ws-commons and I need bindings to apply only to wsdlA, not wsdlB.
This is what I have at the moment:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- Configure Output -->
<packageName>com.mycee.project.model</packageName>
<sourceDestDir>src/main/java</sourceDestDir>
<!-- Configure WSDL Location -->
<wsdlFiles>
<wsdlFile>
${basedir}/src/jaxws/wsdl/wsdla.wsdl
</wsdlFile>
<!--
<wsdlFile>
${basedir}/src/jaxws/wsdl/wsdlb.wsdl
</wsdlFile>
-->
</wsdlFiles>
<!-- Configure Binding Location -->
<bindingDirectory>
${basedir}/src/jaxws/binding
</bindingDirectory>
<!-- Make Output Verbose -->
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
UPDATED:
<build>
<pluginManagement>
<plugins>
<!-- WSDL GENERATOR PLUGIN -->
<!-- mvn jaxws:wsimport -->
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<!-- WSDL A -->
<execution>
<id>WSDLA</id>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<packageName>com.mycee.project.model.wsdla</packageName> <staleFile>${project.build.directory}/jaxws/stale/wsdl.a.done</staleFile>
<wsdlFiles>
<wsdlFile>${basedir}/src/jaxws/wsdl/wsdla.wsdl</wsdlFile>
</wsdlFiles>
<bindingDirectory>${basedir}/src/jaxws/binding</bindingDirectory>
</configuration>
</execution>
<!-- WSDL B -->
<execution>
<id>WSDLB</id>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<packageName>com.mycee.project.model.wsdlb</packageName>
<staleFile>${project.build.directory}/jaxws/stale/wsdl.b.done</staleFile>
<wsdlFiles>
<wsdlFile>${basedir}/src/jaxws/wsdl/wsdlb.wsdl</wsdlFile>
</wsdlFiles>
</configuration>
</execution>
</executions>
<!-- Common Config -->
<configuration>
<verbose>true</verbose>
<wsdlDirectory>
${basedir}/src/jaxws/wsdl
</wsdlDirectory>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
When running mvn clean jaxws:wsimport, I get the following notification with no java code being generated:
[INFO] --- jaxws-maven-plugin:2.2:wsimport (default-cli) #
[INFO] No WSDLs are found to process, Specify
atleast one of the following parameters: wsdlFiles, wsdlDirectory or wsdlUrls.
The first thing is not to configure the configuration within the pluginManagement block. In this case it's better to define the version of the plugin only in the pluginManagement block. Furthermore to fulfill your requirement you need to have two executions like this:
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<id>wsdla-exec</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<packageName>com.mycee.project.model</packageName>
<wsdlFiles>
<wsdlFile>${basedir}/src/jaxws/wsdl/wsdla.wsdl</wsdlFile>
</wsdlFiles>
<bindingDirectory>${basedir}/src/jaxws/binding</bindingDirectory>
<verbose>true</verbose>
</configuration>
</execution>
<execution>
<id>wsdlb-exec</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<packageName>com.mycee.project.model</packageName>
<wsdlFiles>
<wsdlFile>${basedir}/src/jaxws/wsdl/wsdlb.wsdl</wsdlFile>
</wsdlFiles>
<bindingDirectory>${basedir}/src/jaxws/binding</bindingDirectory>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
have an execution element for each wsdl and put the configuration within it. You can keep common configuration elements outside the execution element. e.g.:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>wsdla</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFile>
${basedir}/src/jaxws/wsdl/wsdla.wsdl
</wsdlFile>
<sourceDestDir>target/gen/wsdla</sourceDestDir>
</configuration>
</execution>
<execution>
<id>wsdlb</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFile>
${basedir}/src/jaxws/wsdl/wsdlb.wsdl
</wsdlFile>
<sourceDestDir>target/gen/wsdlb</sourceDestDir>
</configuration>
</execution>
</executions>
<configuration>
<!-- Configure Output -->
<packageName>com.mycee.project.model</packageName>
<!-- Configure Binding Location -->
<bindingDirectory>
${basedir}/src/jaxws/binding
</bindingDirectory>
<!-- Make Output Verbose -->
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Also, don't put generated code in /main/src/java as it won't get cleaned.
Related
Unit tests are getting executed twice.
When i am removing goal report and phase prepare-package from maven plugins in pom, test are getting executed once but then coverage are not getting generated in the console.
But when i am adding goal report and phase prepare-package from maven plugins in pom,i am getting coverage in the console but unit tests are getting executed twice.
I need to have goal report and phase prepare-package in my pom in order to get coverage but need to run test cases only once. What is the way to to get the test case executed only once with coverage as well.
<plugins>
<!-- Configure maven-compiler-plugin to use the desired Java version -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<!-- Use build-helper-maven-plugin to add Scala source and test source
directories -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/scala</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/scala</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- Use scala-maven-plugin for Scala support -->
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<goals>
<!-- Need to specify this explicitly, otherwise plugin won't be called
when doing e.g. mvn compile -->
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- disable surefire -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<aggregate>true</aggregate>
<highlighting>true</highlighting>
<scalacPluginVersion>1.3.0</scalacPluginVersion>
<minimumCoverage>30</minimumCoverage>
<failOnMinimumCoverage>false</failOnMinimumCoverage>
</configuration>
<executions>
<execution>
<goals>
<goal>report</goal> <!-- or integration-check -->
</goals>
<phase>prepare-package</phase> <!-- or any other phase -->
</execution>
</executions>
</plugin>
<!-- enable scalatest -->
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<argLine>
-javaagent:"${settings.localRepository}"/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
</argLine>
<forkMode>once</forkMode>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>WDF TestSuite.txt</filereports>
<!-- The scalatest-maven-plugin seems broken for the spanScaleFactor,
so pass it via system property, instead -->
<!-- <spanScaleFactor>${scalatest.span.scale.factor}</spanScaleFactor> -->
<systemProperties>
<spanScaleFactor>${scalatest.span.scale.factor}</spanScaleFactor>
</systemProperties>
</configuration>
<executions>
<execution>
<id>test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>enter code here
You need to do 2 things:
Add following line in 'scoverage-maven-plugin' plugin's 'configuration' section.
<additionalForkedProjectProperties>skipTests=false</additionalForkedProjectProperties>
Set following property in your root pom.xml
<properties>
<!-- Add other properties here... -->
<!-- skipTests is set to 'true' here to avoid duplicate runs of all test cases. It's set to false in scoverage-maven-plugin below. -->
<skipTests>true</skipTests>
</properties>
I have a POM where I am using JAXB2 plugin to generate code from mulitple webservices (wsdl).
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- maven-jaxb2-plugin -->
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<id>Bus</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<schemas>
<schema>
<url>http://server/Service1?wsdl</url>
</schema>
</schemas>
<generatePackage>com.core.business</generatePackage>
</configuration>
</execution>
<execution>
<id>Ser</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<schemas>
<schema>
<url>http://server/Service2?wsdl</url>
</schema>
</schemas>
<generatePackage>com.core.search</generatePackage>
</configuration>
</execution>
<execution>
<id>Tab</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<schemas>
<schema>
<url>http://server/Service3?wsdl</url>
</schema>
</schemas>
<generatePackage>com.core.table</generatePackage>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
The generated class files are all included in all the Packages. Therefore
com.core.business
com.core.search
com.core.table
It appears that namespaces are not handled correctly as the classes for wsdl1,2,3 are combined in all the 3 packages.
How to ensure that these packages include the specific classes specified in the wsdl?
Those asterisk on each side of your <url> and <generatePackage> attributes are wild card characters.
See this example from http://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.2/example_xjc_basic.html
<project>
...
<dependencies>
<!--
You need the JAXB API to be able to annotate your classes.
However, starting with Java 6 that API is included in the
Java SE platform so there is no need to declare a dependency.
-->
...
</dependencies>
...
<build>
<pluginManagement>
<plugins>
<!--
If we e.g. execute on JDK 1.7, we should compile for Java 7 to get
the same (or higher) JAXB API version as used during the xjc execution.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- The package of your generated sources -->
<packageName>com.example.myschema</packageName>
</configuration>
</plugin>
...
</plugins>
<build>
...
</project>
I would definitely take the * and ** of the beginning of those lines. I found the answer to your question pretty quickly by going to https://github.com/highsource/maven-jaxb2-plugin/wiki/Configuration-Cheat-Sheet
Reports are generating successfully when the build is successful but when there are any failed cases which cause build failure, reports are not generated.
checkBuildResult is already set to false
pom file plugin
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>3.13.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>Simplify360 Automation Test Report</projectName>
<outputDirectory>${project.build.directory}/site/cucumber-reports</outputDirectory>
<cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
<!-- <jsonFiles>
<param>${project.build.directory}/cucumber.json</param>
</jsonFiles> -->
<!-- <parallelTesting>false</parallelTesting> -->
<buildNumber>8.4.1.2</buildNumber>
<checkBuildResult>false</checkBuildResult>
</configuration>
</execution>
</executions>
</plugin>
And the runner class is as below,
#RunWith(Cucumber.class)
#CucumberOptions(
features = {"classpath:features"},
plugin = {"pretty","json:target/cucumber.json"},
tags = {"#currentTest"},
glue={"helpers","stepDefinitions"},
monochrome = true
)
public class RunCukesTest{
}
Add the following configuration to the sure fire plugin. It will not stop the maven execution after the failure. Then it will generate the report.
<testFailureIgnore>true</testFailureIgnore>
as given below with your existing configuration.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
There is flag present for same which is as below:
<checkBuildResult>true</checkBuildResult>
<!-- Set true to fail build on test failures -->
<!-- Set false to pass build on test failures -->
You need to set in the configuration tag as below:
<configuration>
<projectName>oasys-confirmations</projectName>
<outputDirectory>${project.build.directory}</outputDirectory>
<cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
<checkBuildResult>true</checkBuildResult>
</configuration>
New config:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>3.20.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>cucumber-jvm-example</projectName>
<!-- output directory for the generated report -->
<outputDirectory>${project.build.directory}</outputDirectory>
<!-- optional, defaults to outputDirectory if not specified -->
<inputDirectory>${project.build.directory}/</inputDirectory>
<jsonFiles>
<!-- supports wildcard or name pattern -->
<param>**/*.json</param>
</jsonFiles>
<!-- optional, defaults to outputDirectory if not specified -->
<classificationDirectory>${project.build.directory}/</classificationDirectory>
<classificationFiles>
<!-- supports wildcard or name pattern -->
<param>sample.properties</param>
<param>other.properties</param>
</classificationFiles>
<parallelTesting>false</parallelTesting>
<checkBuildResult>true</checkBuildResult>
</configuration>
</execution>
</executions>
</plugin>
Old Config working till 3.16.0 version:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>3.16.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>>cucumber-jvm-example</projectName>
<outputDirectory>${project.build.directory}</outputDirectory>
<cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
<checkBuildResult>true</checkBuildResult>
</configuration>
</execution>
</executions>
</plugin>
NOTE If you get same problem After this configuration then
1. Run RunnerFile Normally TestNG
2. Run Pom.xml as Maven install.
3. Check target folder there is a TagName.html file open it and view the result.
I am trying to replace string %APP_NAME% with enviroment variable in jdbc.properties using maven. I have following configuration:
<pluginManagement>
<plugins>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<basedir>${project.build.directory}/classes</basedir>
<includes>
<include>jdbc.properties</include>
</includes>
<replacements>
<replacement>
<token>%APP_NAME%</token>
<value>${env.BRANCH_NAME}</value>
</replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
<executions>
<execution>
<!-- First step is to disable the default-war build step. -->
<id>default-war</id>
<phase>none</phase>
</execution>
<execution>
<!-- Second step is to create an exploded war. Done in prepare-package -->
<id>war-exploded</id>
<phase>prepare-package</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
<execution>
<!-- Last step is to make sure that the war is built in the package
phase -->
<id>custom-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<additionalProjectnatures>
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
</additionalProjectnatures>
<additionalBuildcommands>
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
</additionalBuildcommands>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<!-- <compilerArgument>-Xlint:all</compilerArgument> -->
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<compilerArguments>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</compilerArguments>
</configuration>
</plugin>
</plugins>
</pluginManagement>
When i invoke:
mvn clean package
or
mvn clean install
the replacer plugin is not called. Can anyone can please explain why and what can I do to let it work? Or if replacer is not compatible with future war plugin can anyone explain me any other way to replace some string in jdbc.properties before building war? I saw also ant plugin but with same config it is not called too.. Example below..
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>deploy-ui</id>
<phase>package</phase>
<inherited>false</inherited>
<configuration>
<tasks>
<replace dir="${basedir}/src/main/resources">
<include name="**/jdbc.properties" />
<replacefilter token="%APP_NAME%" value="${env.BRANCH_NAME}"/>
</replace>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
The plugin is defined in a <pluginManagement> block:
<pluginManagement>
<plugins>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
...
Find the <build><plugins> block for the POM where replacer needs to run, and add the following:
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
</plugin>
Plugin Management is rather like a template for what should happen when the plugin is invoked. If the plugin is not referenced in the <build><plugins> block, nothing will happen.
The following snippet creates 2 JARS:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>build-dependency</id>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>dependency</classifier>
<classesDirectory>${project.build.directory}\dependency</classesDirectory>
<includes>
<include>${dependancyInclude}</include>
</includes>
</configuration>
</execution>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>module</classifier>
<classesDirectory>${project.build.directory}\classes</classesDirectory>
</configuration>
</execution>
</executions>
</plugin>
I would like to combine these two JARs into one using the assembly plugin, currently I have the following:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<executions>
<!-- Combine all the JARs in the /target folder into one JAR -->
<execution>
<id>make-assembly</id>
<phase>compile</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<attach>true</attach>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>${project.artifactId}-${project.version}</finalName>
<appendAssemblyId>true</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
Currently only one of the two JARS in included in the final JAR that is created by the assembly plugin.
If I understand you correctly, you actually want to merge the jar files into one big jar file. This can be achieved using the maven-shade-plugin (instead of the maven-assembly-plugin).
For example:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.0</version>
<configuration>
<!-- Put your configuration here, if you need any extra settings.
(You should be okay with the defaults). -->
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>