Multiple maven plugins to run a phase - java

I am doing a maven smartbear soapui project. I have dependency for two plugins. `
<build>
<plugins>
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-pro-maven-plugin</artifactId>
<version>5.1.2</version>
<executions>
<execution>
<id>pro</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<projectFile>${projectFile}</projectFile>
<outputFolder>${basedir}/target/surefire-reports</outputFolder>
<junitReport>true</junitReport>
<exportAll>true</exportAll>
<printReport>true</printReport>
<testFailIgnore>true</testFailIgnore>
</configuration>
</execution>
</executions>
<configuration>
<soapuiProperties>
<property>
<name>soapui.logroot</name>
<value>${project.build.directory}/surefire-reports/</value>
</property>
<property>
<name>soapui.https.protocols</name>
<value>TLSv1.2,SSLv3</value>
</property>
</soapuiProperties>
</configuration>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.9-RC1</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.9-RC1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.19.1</version>
<type>maven-plugin</type>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>com.github.redfish4ktc.soapui</groupId>
<artifactId>maven-soapui-extension-plugin</artifactId>
<version>4.6.4.2</version>
<executions>
<execution>
<id>redfish</id>
<phase>test</phase>
<configuration>
<testSuiteProperties>
<properties>
<property>PropertyCode=${propertyCode}</property>
<property>Environment=${environment}</property>
<Gateway>Gateway=${gateway}</Gateway>
</properties>
</testSuiteProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>`
My tests need to have dependency plugin redfish as it supports soapuiTestSuite properties configuration.
Now when I tried to run this mvn install test, the build starts to run with first plugin and fails as it doesn't have second plugin downloaded and later runs again downloading second but fails. I need to have both the plugins and whole configuration setup before I run the goal.
I am new to Maven structure.

Add execute at the second plugin.
For example, if you want to execute maven-soapui-extension-plugin before soapui-pro-maven-plugin you can add this execution:
<executions>
<execution>
<id>soapui-tests</id>
<phase>verify</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
And just do 'mvn install', because you have executions attached to default Maven lifecycle.
Look at the list of default Maven Lifecycle in the execution order: validate, initialize, .. deploy (docs here).

Related

Intellij: maven clean verify: Failed to execute goal org.jasig.mojo.jspc:jspc-maven-plugin:2.0.2:compile: Failed to compile JSPS

My project POM has following plugins-
<build>
<plugins>
<plugin>
<groupId>org.jasig.mojo.jspc</groupId>
<artifactId>jspc-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<directory>${basedir}/src/main/webapp/</directory>
<includes>
<include>**/*.jsp</include>
</includes>
</sources>
<includeInProject>false</includeInProject>
<validateXml>false</validateXml>
</configuration>
<dependencies>
<dependency>
<groupId>org.jasig.mojo.jspc</groupId>
<artifactId>jspc-compiler-tomcat8</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.5.3</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>utf8</encoding>
</configuration>
</plugin>
</plugins>
</build>
I'm using apache-maven-3.6.3 and Intellij IDE for building my project.
But when executing mvn clean verify, I get the error-
Failed to execute goal
org.jasig.mojo.jspc:jspc-maven-plugin:2.0.2:compile: Failed to compile
JSPS
It is due to in tomcat 7 by default SKIP IDENTIFIER CHECK feature is false.
Hence supply-Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true as an argument while maven clean installing.
Alternatively a work around is also to use org.apache.sling jspc-maven-plugin
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>jspc-maven-plugin</artifactId>
<version>2.2.2</version>
<executions>
<execution>
<id>compile-jsp</id>
<goals>
<goal>jspc</goal>
</goals>
</execution>
</executions>
</plugin>

Generate .jasper with maven plugin

I´m looking to improve the performance of my application, which has two types of reports, and compile then at execution time like this :
final JasperDesign design = JRXmlLoader.load(input);
final JasperReport compiledReport = JasperCompileManager.compileReport(design);
This code executes every time when the user wants to see the report on the app.
To avoid this, I´m trying to execute the compilation of the .jrxml through maven jasperreports plugin, but it doesn't work, and there isn't an error on console.
The .jasper files don't appear in my directory "outputDirectory".
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jasperreports-maven-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<inherited>false</inherited>
<goals>
<goal>compile-reports</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceDirectory>src/main/resources/reports</sourceDirectory>
<outputDirectory>src/main/resources/reports/jasper</outputDirectory>
<compiler>net.sf.jasperreports.engine.design.JRJdtCompiler</compiler>
</configuration>
</plugin>
I know this is old, but this happened to me when I defined the plugin in the <pluginManagement> section of the POM instead of in <plugins>.
This was the pom config I used
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jasperreports-maven-plugin</artifactId>
<version>1.0-beta-2</version>
<executions>
<execution>
<goals>
<goal>compile-reports</goal>
</goals>
<configuration>
<!-- jrxml file directory-->
<sourceDirectory>src\\main\\resources\\reports\\template</sourceDirectory>
<sourceFileExt>.jrxml</sourceFileExt>
<compiler>net.sf.jasperreports.engine.design.JRJavacCompiler</compiler>
<!-- Destination for jasper file -->
<outputDirectory>src\\main\\resources\\reports\\jasper</outputDirectory>
</configuration>
</execution>
</executions>
<dependencies>
<!-- These plugins are used to specify correct version for jrxml xml validation -->
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.5.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Maven ignores execution's configuration when specific execution is ran

I have a Maven plugin configuration, which I want to run from CLI. It looks like the following:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dbunit-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<configuration>
<driver>${knossos.jdbc.driver}</driver>
<url>${knossos.jdbc.url}</url>
<username>${knossos.jdbc.user}</username>
<password>${knossos.jdbc.password}</password>
</configuration>
<dependencies>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>db</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>fill-dabatase</id>
<phase>test</phase>
<goals>
<goal>operation</goal>
</goals>
<configuration>
<type>INSERT</type>
<src>src/test/resources/data/full.xml</src>
</configuration>
</execution>
</executions>
</plugin>
According to new Maven's feature, I execute
mvn initialize dbunit:operation#fill-database
This should run the execution but it fails with error on getting "src" and "type" configuration parameters"
[ERROR] Failed to execute goal org.codehaus.mojo:dbunit-maven-plugin:1.0-beta-3:operation (fill-database) on project KnossosWebApp: The parameters 'src', 'type' for goal org.codehaus.mojo:dbunit-maven-plugin:1.0-beta-3:operation are missing or invalid -> [Help 1]
But when I'm running the same execution though the Maven phase "test", it works Ok.
mvn test
Is the the issue of Maven plugin execution?
As a temporary workaround I moved execution's configuration to plugin configuration. This way it works for both phase and goal executions.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dbunit-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<configuration>
<driver>${knossos.jdbc.driver}</driver>
<url>${knossos.jdbc.url}</url>
<username>${knossos.jdbc.user}</username>
<password>${knossos.jdbc.password}</password>
<type>INSERT</type>
<src>src/test/resources/data/full.xml</src>
</configuration>
<dependencies>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>db</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>fill-dabatase</id>
<phase>test</phase>
<goals>
<goal>operation</goal>
</goals>
</execution>
</executions>
</plugin>

Not able to bind plugin goals to maven lifecycle phases

I am using maven sql plugin. I am using the plugin to setup the my test db before executing integration tests. Here is my plugin configuration from my project pom. When I execute mvn clean install I expect the plugin goals to execute. But they are not getting executed. Any help will be appreciated. I am facing similar issue for aspectj plugin (configuration provided below).
My SQL plugin configuration:
<!-- Maven SQL Plugin for setting up test schema for integration tests -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies> <!-- specify the dependent JDBC driver here -->
<dependency>
<groupId>${jdbc.groupId}</groupId>
<artifactId>${jdbc.artifactId}</artifactId>
<version>${jdbc.version}</version>
</dependency>
</dependencies>
<!-- common configuration shared by all executions -->
<configuration>
<driver>org.hsqldb.jdbcDriver</driver>
<url>jdbc:hsqldb:sample</url>
<username>sa</username>
<password></password>
</configuration>
<executions>
<execution>
<id>create_db_schema</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<!-- specific configuration for this execution -->
<configuration>
<srcFiles>
<srcFile>src/test/resources/test-schema.sql</srcFile>
</srcFiles>
</configuration>
</execution>
<execution>
<id>shutdown_db_instance</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<sqlCommand>SHUTDOWN IMMEDIATELY</sqlCommand>
</configuration>
</execution>
</executions>
</plugin>
My aspectj plugin configuration:
<!-- AspectJ Compile-time waving for spring cross-store. -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<outxml>true</outxml>
<showWeaveInfo>true</showWeaveInfo>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
<aspectLibrary>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-cross-store</artifactId>
</aspectLibrary>
</aspectLibraries>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
Be sure that these plugins are not defined inside project/build/pluginManagement/plugins, but in project/build/plugins.
Only the latter are executed, those plugins will then will be checked with the pluginManagement for the final configuration.

jaxws-maven-plugin wsgen on test endpoint

I'm trying to get maven 3 to run wsgen against two web service endpoints. One is a 'production' endpoint, located under src/main/java, and the other is a 'test' endpoint that is located under src/test/java.
The problem is, wsgen does not find the 'test' sei class as (presumably) it only has src/main/java on the classpath. It is not possible to directly set the wsgen classpath using jaxws-maven-plugin (there's no config element for it). I've tried binding to the generate-test-sources phase but no joy
Here's the pom snippet:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<!-- this works fine -->
<execution>
<id>Production</id>
<configuration>
<genWsdl>true</genWsdl>
<verbose>true</verbose>
<protocol>soap1.1</protocol>
<sei>com.foo.ws.ProductionEndPoint</sei>
<sourceDestDir>${project.build.directory}/jaxws/wsgen/src</sourceDestDir>
<destDir>${project.build.directory}/jaxws/wsgen/classes</destDir>
<packageName>com.foo.ws</packageName>
</configuration>
<goals>
<goal>wsgen</goal>
</goals>
</execution>
<!-- this fails with Class Not Found on the sei class -->
<execution>
<phase>generate-test-sources</phase>
<id>Test</id>
<configuration>
<genWsdl>true</genWsdl>
<verbose>true</verbose>
<protocol>soap1.1</protocol>
<sei>com.foo.ws.TestEndPoint</sei>
<sourceDestDir>${project.build.directory}/jaxws/wsgen/src</sourceDestDir>
<destDir>${project.build.directory}/jaxws/wsgen/classes</destDir>
<packageName>com.foo.ws.test</packageName>
</configuration>
<goals>
<goal>wsgen</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.1.4</version>
</dependency>
</dependencies>
</plugin>
</plugin>
</build>
You should bind to the process-test-classes phase
Instead of
<phase>process-test-classes</phase>
It should be
<phase>process-test-classes</phase>

Categories

Resources