Soapui maven plugin ssl host parameter - maven

We have a set of soapui tests that are being run via a maven project using the soapui maven plugin which is run by a Jenkins job as well.
As we have various environments we pass a "host" parameter via the environment, from Jenkins to the Maven build.
There is a <host>${HOST}</host> element that allows us to configure the host. The problem is that the maven plugin seems to dislike when adding the protocol prefix inside the parameter value:
<host>example.com</host> Will work
<host>https://example.com</host> Won't work (java.net.UnknownHostException: https)
So if I am not allowed to provide the protocol prefix, then I don't know how to tell the maven soapui plugin that the host is using ssl.
Here is the configuration in the pom.xml that we are using:
<build>
<plugins>
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-pro-maven-plugin</artifactId>
<version>5.0.0</version>
<dependencies>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
</dependencies>
<configuration>
<projectFile>${project.build.directory}/test-classes/my-soapui-project.xml</projectFile>
<host>${HOST}</host>
<junitReport>true</junitReport>
<soapuiProperties>
<property>
<name>soapui.logroot</name>
<value>${project.build.directory}/soapui-logs/</value>
</property>
</soapuiProperties>
<outputFolder>${project.build.directory}/soapui-output</outputFolder>
</configuration>
<executions>
<execution>
<id>first-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<testSuite>first-TestSuite</testSuite>
</configuration>
</execution>
<execution>
<id>second-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<testSuite>second-TestSuite</testSuite>
</configuration>
</execution>
</executions>
</plugin>
...
Edited: Based in the answer by Bistro:
Instead of using <host>${HOST}</host> I now use <endpoint>${HOST}</endpoint> it does the trick.

Can you try adding an <endpoint> parameter. Someone in the SoapUI forum had a similar issue, but was able to resolve the connection issue by adding this parameter. He does mention that it causes another issue. But it's worth a shot. Here is the post link

Related

gmaven plugin: how to set property in pom.xml for external groovy script

I'm running an external groovy script via gmaven plugin in pom.xml.
The external script is say 'myscript.groovy'.
I want to provide some parameters/arguments to myscript.groovy via the maven pom.xml [i.e. inside the plugin 'gmaven-plugin' execution]; but unable to do so..
I've tried using in ; but not sure how to retrieve its values in the groovy script. Simply calling properties.get is not giving the property value.
Snap of pom file:
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<id>generate-resources-execute-groovyscript</id>
<phase>generate-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<properties>
<property>
<name>installation.dir</name>
<value>${installation.dir}</value>
</property>
</properties>
<source>${pom.basedir}/src/main/groovy/configure.groovy</source>
</configuration>
</execution>
</executions>
</plugin>
Not sure how to retrieve the value of 'installation.dir' property in 'configure.groovy' script.
Any hint in this regard will be useful.. thanks
There are two ways you can bind and retrieve properties. One would be through plugin-specific properties.
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<id>generate-resources-execute-groovyscript</id>
<phase>generate-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<properties>
<installation.dir>${installation.dir}</installation.dir>
</properties>
<source>${pom.basedir}/src/main/groovy/configure.groovy</source>
</configuration>
</execution>
</executions>
</plugin>
These would be retrieved in the script like project.properties['installation.dir'].
GMaven isn't maintained anymore (I was the last maintainer). If you want to use versions of Groovy newer than 2.0.0, have a look at GMavenPlus. Here's the equivalent POM:
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>execute</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<bindPropertiesToSeparateVariables>false</bindPropertiesToSeparateVariables>
<properties>
<property>
<name>installation.dir</name>
<value>${installation.dir}</value>
</property>
</properties>
<scripts>
<script>file:///${pom.basedir}/src/main/groovy/configure.groovy</script>
</scripts>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.3</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
Retrieval in this case would be like properties['installation.dir']. I know the file:/// is annoying. I've removed the requirement for that in the next release.
For GMaven or GMavenPlus, if you choose the plugin properties approach, you will need to set the value elsewhere either with something like this in your project POM
<properties>
<installation.dir>C:\someDir</installation.dir>
</properties>
Or include it in your call like mvn -Dinstallation.dir=C:\someDir
The other option is to bind to project level properties directly. You would put it in your project level properties or in your call, like mentioned above, and don't include <properties> in the plugin <configuration>. If you go this route, you'd access in your script by project.properties['installation.dir'] for either GMaven or GMavenPlus (also take out <bindPropertiesToSeparateVariables> for GMavenPlus in this case).
If this doesn't work for you, try renaming installation.dir to something like installationDir. I can't remember offhand if periods were problematic.

Use dependency command line parameters with maven build

I am using findbugs-maven-plugin in the verify phase of the maven life cycle. i.e. it runs on mvn clean install. This is the code I have in my parent pom.xml (in a multi-module project).
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>findbugs</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<findbugsXmlOutputDirectory>target/findbugs</findbugsXmlOutputDirectory>
<failOnError>false</failOnError>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>transform</goal>
</goals>
</execution>
</executions>
<configuration>
<transformationSets>
<transformationSet>
<dir>target/findbugs</dir>
<outputDir>target/findbugs</outputDir>
<stylesheet>plain.xsl</stylesheet>
<fileMappers>
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
<targetExtension>.html</targetExtension>
</fileMapper>
</fileMappers>
</transformationSet>
</transformationSets>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>findbugs</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
</plugin>
This is working fine and html files are being generated in each module target. However I want to take this a step further by being able to use parameters allowed by findbugs during the maven build (for example onlyAnalyze). I do not want to add configuration in the pom.xml.
I want the build process to remain the same unless I specify by some command that I want to analyze only one class, for example by running:
mvn clean install -Dfindbugs:onlyAnalyze=MyClass
Do you know of a way I can do this?
This is how you can call a standalone goal:
plugin-prefix:goal or groupId:artifactId:version:goal to ensure the right version.
In your case: findbugs:findbugs
With -Dkey=value you can set plugin parameters if they are exposed. http://mojo.codehaus.org/findbugs-maven-plugin/findbugs-mojo.html doesn't show that option. Just to compare: http://mojo.codehaus.org/findbugs-maven-plugin/help-mojo.html does have such options. Here it is still called Expression with ${key}, nowadays it's generated as User property with just key.
If you want onlyAnalyze to be set from commandline, either ask the mojo-team to fix that, or do the following:
<project>
<properties>
<findbugs.onlyAnalyze>false</findbugs.onlyAnalyze> <!-- default value -->
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<configuration>
<onlyAnalyze>${findbugs.onlyAnalyze}</onlyAnalyze>
</configuration>
</plugins>
</build>
</project>
Now you can call mvn findbugs:findbugs -Dfindbugs.onlyAnalyze=true

exec-maven-plugin doesn't use third-party repos

I have a couple of third-party repos configured. I know they're configured correctly because it's downloading artifacts from them. But exec-maven-plugin doesn't seem to recognize those third-party repos. It looks for its dependency in Maven Central and then tells me the POM doesn't exist there. Of course it doesn't; it's in the third party repo! Do I need to do something special to tell exec-maven-plugin to use the third-party repo?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>emulation</id>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>krum.jplex.JPlex</mainClass>
<arguments>
<argument>${basedir}/src/main/jplex/EmulationLexer.jplex</argument>
<argument>${project.build.directory}/generated-sources/jplex</argument>
<argument>${project.build.directory}/generated-resources/jplex</argument>
</arguments>
<sourceRoot>${project.build.directory}/generated-sources/jplex</sourceRoot>
<includePluginDependencies>true</includePluginDependencies>
<classpathScope>compile</classpathScope>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.chalcodes.jplex</groupId>
<artifactId>JPlex</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
</plugin>
A reading of Using Plugin Dependencies instead of Project Dependencies, indicates you will need to specify the following (in addition to what you have)
<configuration>
<includeProjectDependencies>false</includeProjectDependencies>
<includePluginDependencies>true</includePluginDependencies>
<executableDependency>
<groupId>com.chalcodes.jplex</groupId>
<artifactId>1.2.1</artifactId>
</executableDependency>
...
</configuration

maven 3 surefire and maven gwt exclude / include problems

I have a root pom configured with the maven-surefire-plugin and a gwt module pom configured with the gwt-maven-plugin.
After upgrading to Maven 3 I get strange errors.
The project is similar configured like described here: Separate GwtTest tests from standard unit tests
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<useSystemClassLoader>true</useSystemClassLoader>
<useManifestOnlyJar>false</useManifestOnlyJar>
<forkMode>always</forkMode>
<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<property>
<name>listener</name>
<value>org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter</value>
</property>
</properties>
<argLine>-server -Xmx8192m -XX:MaxPermSize=1024M -XX:+CMSClassUnloadingEnabled</argLine>
<excludes>
<exclude>**/*GwtTest*.java</exclude>
</excludes>
</configuration>
</plugin>
AND
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.5.0</version>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
</dependency>
</dependencies>
<configuration>
<modules>
<module>my.app.gwt</module>
</modules>
<runTarget>/</runTarget>
<extraJvmArgs>-Xss512m -Xmx2048m -XX:MaxPermSize=256M</extraJvmArgs>
<hostedWebapp>${project.build.directory}/${project.build.finalName}</hostedWebapp>
<includes>**/*GwtTestSuite.java</includes>
<copyWebapp>true</copyWebapp>
<logLevel>INFO</logLevel>
<persistentunitcache>false</persistentunitcache>
<draftCompile>${gwt.draftCompile}</draftCompile>
<deploy>${project.build.directory}/${project.build.finalName}/WEB-INF/deploy</deploy>
<disableCastChecking>true</disableCastChecking>
<mode>htmlunit</mode>
<skipTests>${skipGwtTests}</skipTests></configuration>
<executions>
<execution>
<id>gwt-compile</id>
<goals>
<goal>compile</goal>
</goals>
<phase>compile</phase>
</execution>
<execution>
<id>gwt-test</id>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
</plugin>
It works with maven 2 but with maven 3 I get :
[ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.5.0:test (gwt-test) on project my-webapp: Unable to parse configuration of mojo org.codehaus.mojo:gwt-maven-plugin:2.5.0:test: When configuring a basic element the configuration cannot contain any child elements. Configuration element 'excludes'. -> [Help 1]
It seems that the gwt plugin can't parse the hierarchical style of the surefire plugin.
It only compiles if I set all excludes/includes inside the gwt plugin as one comma separated string line, but that doesn't work for me, because I need to exclude the gwt tests globally, and include them locally.
The include/exclude sections get merged however, so that the two incompatible syntax definitions won't work together.
I hope somebody can give me a hint.
You can run your GWTTestCases using straight Maven Surefire, see this link.

How to use artifactId with different filename in dependencies

Using Artifactory and Maven, how can one refer to a dependency with the correct group/artifactId/version but use a filname that differs from the artifactId-version.end style?
The problem comes with a dll that cannot be renamed, and the mandatory? Artifactory naming convention.
edit
found one possible expensive way for this specific problem where the filename cannot include the dash-sign: creating a new Artifactory repository layout for which the pro-version is needed - so unfortunately, that is not an option!
partly solution for jUnit tests
using the maven-dependency-plugin and the maven-surefire-plugins one can make jUnits work. unfortunately, it does not solve the problem that the specific sapjco3.dll cannot be found when deployed within a war to a server.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>copy</id>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>sapjco</groupId>
<artifactId>sapjco3</artifactId>
<version>3.0.7</version>
<type>dll</type>
<classifier>win32</classifier>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</artifactItem>
</artifactItems>
<stripVersion>true</stripVersion>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>java.library.path</name>
<value>${project.build.directory}/lib</value>
</property>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
Maven does not care for filenames, it cares for their coordinates. Add your DLL correctly to your remote repo and maven will do the rest.
A dependency snippet might be:
<dependency>
<groupId>com.company</groupId>
<artifactId>my.artifact</atifactId>
<version>1.0</version>
<type>dll</type>
<classifier>win32</classifier>
</dependency>
After you have done this, use either dependency:copy-dependencies or dependency:copy to change the filename at build time.

Resources