I'm trying to upgrade my cucumber/serenity project but sadly this breaks more then fixes one of the issues is when I want to run a seperate feature file I get the message from intellij
Error:Kotlin: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.13.
But as far as I know and see I never use kotlin. It's a maven project also with following pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>be.nbb.cph</groupId>
<artifactId>hive-serenity</artifactId>
<version>1.0-SNAPSHOT</version>
<name>cph-serenity</name>
<description>Hive Selenium testing</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<serenity.version>2.6.0</serenity.version>
<serenity.maven.version>2.6.0</serenity.maven.version>
<serenity.cucumber.version>2.6.0</serenity.cucumber.version>
<encoding>UTF-8</encoding>
<tags></tags>
<webdriver.base.url></webdriver.base.url>
<!-- <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<serenity.version>2.1.5</serenity.version>
<serenity.cucumber.version>1.9.50</serenity.cucumber.version>-->
<webdriver.driver>chrome</webdriver.driver>
<webdriver.remote.driver>chrome</webdriver.remote.driver>
<serenity.dry.run>false</serenity.dry.run>
<hive.env>local</hive.env>
<cucumber.runner>**/cucumber/CucumberTestSuite.java</cucumber.runner>
<serenity.browser.height>1024</serenity.browser.height>
<serenity.browser.width>1400</serenity.browser.width>
</properties>
<profiles>
<profile>
<id>dryrun</id>
<properties>
<serenity.dry.run>true</serenity.dry.run>
</properties>
</profile>
<profile>
<id>env:local</id>
<properties>
<hive.env>local</hive.env>
<injected.tags>env:local</injected.tags>
<cucumber.runner>**/cucumber/CucumberTestSuite.java</cucumber.runner>
<serenity.project.name>NBB Hive Automated Testing #uat
</serenity.project.name>
</properties>
</profile>
<profile>
<id>env:dev</id>
<properties>
<hive.env>dev</hive.env>
<injected.tags>env:dev</injected.tags>
<cucumber.runner>**/cucumber/CucumberTestSuite.java</cucumber.runner>
<serenity.project.name>NBB Hive Automated Testing #dev
</serenity.project.name>
</properties>
</profile>
<profile>
<id>env:uat</id>
<properties>
<hive.env>uat</hive.env>
<injected.tags>env:uat</injected.tags>
<cucumber.runner>**/cucumber/CucumberTestSuite.java</cucumber.runner>
<serenity.project.name>NBB Hive Automated Testing #uat
</serenity.project.name>
</properties>
</profile>
<profile>
<id>env:prd</id>
<properties>
<hive.env>prd</hive.env>
<injected.tags>env:prd</injected.tags>
<cucumber.runner>**/cucumber/CucumberTestSuite.java</cucumber.runner>
<serenity.project.name>NBB Hive Automated Testing #prd
</serenity.project.name>
</properties>
</profile>
<profile>
<id>target:desktop</id>
<properties>
</properties>
</profile>
<profile>
<id>target:mobile</id>
<properties>
<serenity.browser.height>1024</serenity.browser.height>
<serenity.browser.width>700</serenity.browser.width>
</properties>
</profile>
<profile>
<id>grid:nbb-dev</id>
<properties>
<webdriver.remote.url>http://swvnchseld01.nbb.local:4444/wd/hub</webdriver.remote.url>
</properties>
</profile>
<profile>
<id>grid:nbb-prd</id>
<properties>
<webdriver.remote.url>http://swvnchselp01.nbb.local:4444/wd/hub</webdriver.remote.url>
</properties>
</profile>
<profile>
<id>grid:local</id>
<properties>
<webdriver.remote.url>http://localhost:4444/wd/hub</webdriver.remote.url>
</properties>
</profile>
<profile>
<id>grid:none</id>
<properties>
</properties>
</profile>
<profile>
<id>browser:edge</id>
<properties>
<hive.browser>edge</hive.browser>
<injected.tags>browser:edge</injected.tags>
<webdriver.remote.driver>edge</webdriver.remote.driver>
</properties>
</profile>
<profile>
<id>browser:firefox</id>
<properties>
<hive.browser>firefox</hive.browser>
<injected.tags>browser:firefox</injected.tags>
<webdriver.driver>firefox</webdriver.driver>
<webdriver.remote.driver>firefox</webdriver.remote.driver>
</properties>
</profile>
<profile>
<id>browser:chrome</id>
<properties>
<hive.browser>chrome</hive.browser>
<injected.tags>browser:chrome</injected.tags>
<webdriver.driver>chrome</webdriver.driver>
<webdriver.remote.driver>chrome</webdriver.remote.driver>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber6</artifactId>
<version>${serenity.cucumber.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay-webdriver</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-ensure</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.6.2</version>
</dependency>
</dependencies>
<!-- plugins -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<systemPropertyVariables>
<password>${hive_test_account_1_password}</password>
<password>${hive_test_account_2_password}</password>
<password>${hive_test_account_3_password}</password>
<password>${hive_test_account_4_password}</password>
<password>${hive_test_account_5_password}</password>
<password>${hive_test_account_6_password}</password>
</systemPropertyVariables>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<includes>
<include>**/*Test.java</include>
<include>**/Test*.java</include>
<include>**/*TestSuite.java</include>
<include>**/When*.java</include>
</includes>
<systemPropertyVariables>
<webdriver.base.url>${webdriver.base.url}</webdriver.base.url>
</systemPropertyVariables>
<!-- <parallel>classes</parallel>
<parallel>methods</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>-->
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.version}</version>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${hive.env}/${hive.browser}/${current.time}
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>current-time</id>
<phase>validate</phase>
<goals>
<goal>timestamp-property</goal>
</goals>
<configuration>
<name>current.time</name>
<pattern>yyyyMMdd_HHmmss</pattern>
<timeZone>CET</timeZone>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Does anybody know what's going wrong or how to fix this?
Related
I am trying to run serenity with Maven. Its running and showing success but actual test is not running and report is showing blank. I've attached my proj and POM in attachment. Please helpenter image description here
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>serenity</groupId>
<artifactId>serenity</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>serenity practise</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>4.10</junit.version>
<serenity.version>1.0.47</serenity.version>
<serenity.maven.version>1.0.47</serenity.maven.version>
<webdriver.driver>firefox</webdriver.driver>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>core</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit</artifactId>
<version>${serenity.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18</version>
<configuration>
<includes>
<include>**/*/**/When*.java</include>
</includes>
<systemProperties>
<webdriver.driver>${webdriver.driver}</webdriver.driver>
<surefire.rerunFailingTestsCount>${surefire.rerunFailingTestsCount}</surefire.rerunFailingTestsCount>
<surefire.rerunFailingTestsCount>${surefire.rerunFailingTestsCount}</surefire.rerunFailingTestsCount>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.maven.version}</version>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>core</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I am running Soapui test using Intelliji, however I am unable to run test via Maven. Normal test works fine using SoapUITestRunner.
I am getting below error, even though I have eviware:maven-soapui-plugin:jar:4.5.1 in my project path and under .m2 repository.
Error:
Failed to execute goal on project webservice: Could not resolve dependencies for project webservice:webservice:jar:1.0-SNAPSHOT: Failure to find eviware:maven-soapui-plugin:jar:4.5.1 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
Appreciate your help.
Best Regards,
Kam
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>webservice</groupId>
<artifactId>webservice</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.soapui.plugin.version>4.5.1</maven.soapui.plugin.version>
<soapui.repo.url>http://www.soapui.org/repository/maven2/</soapui.repo.url>
</properties>
<pluginRepositories>
<pluginRepository>
<id>eviwarePluginRepository</id>
<url>http://www.soapui.org/repository/maven2/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>eviware</groupId>
<artifactId>maven-soapui-plugin</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<!-- Source directory configuration -->
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<testFailureIgnore>true</testFailureIgnore>
<!-- Setting properties for test execution -->
<properties>
<!-- Setting ReportNG listeners -->
<property>
<name>listener</name>
<value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>
</property>
</properties>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>eviware</groupId>
<artifactId>maven-soapui-plugin</artifactId>
<version>4.5.1</version>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
<configuration>
<projectFile>${project.basedir}/SoapUIAutomationDemo.xml</projectFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Remove your cached jars from C:\Users\.m2\repository\com\smartbear.
enable proxy if any in your settings.xml under .m2 folder.
My project is composed by a EJB module and a Web module.
The EJB module uses Arquillian with Persistence extension to run integration tests. Arquillian starts up a managed Jboss7, setup the database, run the tests and then shuts down Jboss. I have JaCoCo Maven Plugin configured to generated code coverage reports for those tests and everything is working perfectly - reports are created and exported to a sonar server.
The Web module uses Arquillian with Drone/Graphene extensions to run Selenium tests. So, during my CI build, Arquillian starts a Jboss7, starts firefox and run the Selenium test suites automatically. Here is where I'm having troubles... All the tests run just fine, however JaCoCo reports are not being generated for this module.
Both modules share a common root pom, here is the relevant bit of this pom:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties>
<version.joda.time>2.1</version.joda.time>
<version.junit>4.11</version.junit>
<version.mockito>1.9.5</version.mockito>
<version.jacoco>0.6.0.201210061924</version.jacoco>
<version.arquillian.jacoco>1.0.0.Alpha5</version.arquillian.jacoco>
<version.arquillian.persistence>1.0.0.Alpha6</version.arquillian.persistence>
<version.commons.collections>3.2.1</version.commons.collections>
<version.guava.testlib>14.0.1</version.guava.testlib>
</properties>
<dependencies>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${version.joda.time}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${version.mockito}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-testlib</artifactId>
<version>${version.guava.testlib}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>${version.commons.collections}</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-drone-bom</artifactId>
<version>1.2.0.Alpha2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.0.4.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${version.jacoco}</version>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>target/jacoco-it.exec</destFile>
<propertyName>failsafe.argLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>target/jacoco-it.exec</dataFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.14</version>
<configuration>
<argLine>${failsafe.argLine}</argLine>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jgitflow-plugin</artifactId>
<version>1.0-alpha14</version>
<configuration>
<enableFeatureVersions>true</enableFeatureVersions>
<autoVersionSubmodules>true</autoVersionSubmodules>
<pushReleases>true</pushReleases>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>arquillian-jbossas-managed</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>process-test-classes</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-dist</artifactId>
<version>7.1.1.Final</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>target</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!-- Ignore/Execute plugin execution -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<!-- copy-dependency plugin -->
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>unpack</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
</build>
<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-managed</artifactId>
<version>7.1.1.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-jacoco</artifactId>
<scope>test</scope>
<version>${version.arquillian.jacoco}</version>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.core</artifactId>
<version>${version.jacoco}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-persistence-impl</artifactId>
<version>${version.arquillian.persistence}</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
First let me explain what I am doing:
Creating a Java project in Eclipse (JUNO) to unit test SQL for a Postgres database.
Using Maven2 as the build tool. I have DBUnit, and SQL maven plugins.
The goal is to drop the schema and rebuild the tables and load some data in the tables.
I've tested the SQL so I know it works. I have tested the connections so I know the URL is right.
Now onto my problem. I am new to Maven for unit testing SQL. I have tried to follow most of the online documentation. I have created my pom from the examples. While the Java code compiles, the build blows by the SQL work in the pom.xml file. Here is my pom.xml file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.premierinc.esd</groupId>
<artifactId>sqlunittest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>sqlunittest</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>3.8.1</junit.version>
<maven.compiler.plugin.version>2.5.1</maven.compiler.plugin.version>
<sql.maven.plugin.version>1.5</sql.maven.plugin.version>
<postgresql.jdbc.version>9.1-901.jdbc4</postgresql.jdbc.version>
</properties>
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.jdbc.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>${sql.maven.plugin.version}</version>
<dependencies>
<!-- specify the dependent jdbc driver here -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.jdbc.version}</version>
</dependency>
</dependencies>
<!-- common configuration shared by all executions -->
<configuration>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:5432:testdb</url>
<username>postgres</username>
<password>root</password>
<!-- You can comment out username/password configurations and have
maven to look them up in your settings.xml using ${settingsKey} -->
<settingsKey>sensibleKey</settingsKey>
<!--all executions are ignored if -Dmaven.test.skip=true -->
<skip>${maven.test.skip}</skip>
</configuration>
<executions>
<execution>
<id>drop-schema-before-test-if-any</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<!-- need another database to drop the targeted one -->
<url>jdbc:postgresql://localhost:5432:postgres</url>
<autocommit>true</autocommit>
<sqlCommand>DROP SCHEMA chipen CASCADE</sqlCommand>
<!-- ignore error when database is not available -->
<onError>continue</onError>
</configuration>
</execution>
<execution>
<id>create-schema</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<autocommit>true</autocommit>
<srcFiles>
<srcFile>src/main/sql/CHI-PEN-schema.sql</srcFile>
</srcFiles>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dbunit-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<dependencies>
<!-- specify the dependent jdbc driver here -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.jdbc.version}</version>
</dependency>
</dependencies>
<!-- common configuration shared by all executions -->
<configuration>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:5432:testdb</url>
<username>postgres</username>
<password>root</password>
<!-- You can comment out username/password configurations and have
maven to look them up in your settings.xml using ${settingsKey} -->
<settingsKey>sensibleKey</settingsKey>
<!--all executions are ignored if -Dmaven.test.skip=true -->
<skip>${maven.test.skip}</skip>
</configuration>
<executions>
<execution>
<phase>test-compile</phase>
<goals>
<goal>operation</goal>
</goals>
<!-- specific configurations -->
<configuration>
<type>CLEAN_INSERT</type>
<src>src/test/data/testdb_chipen_data.xml</src>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Any suggestions or hints would be greatly appreciated.
Thanks in advance.
I add the pom of your post here in corrected form. I have removed in particular the repository definition, cause they are the defaults in Maven so convention over configurations mean to define only what is really needed to define.
Furthermore i have removed the pluginManagement tags, cause this means not to really execute the things it means define things. To be more accurate pluginManagement is intended to define the versions of plugins but usually not the configuration. This is usually used in parent pom's:
<project ...>
..
<build>
<pluginManagement>
<plugins>
<plugin>
Plugin groupId, artifactId, version
</plugin>
.
</plugin>
</pluginManagement>
..
</project>
Let us get back to your pom. The follow should run:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.premierinc.esd</groupId>
<artifactId>sqlunittest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>sqlunittest</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>3.8.1</junit.version>
<maven.compiler.plugin.version>2.5.1</maven.compiler.plugin.version>
<sql.maven.plugin.version>1.5</sql.maven.plugin.version>
<postgresql.jdbc.version>9.1-901.jdbc4</postgresql.jdbc.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.jdbc.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>${sql.maven.plugin.version}</version>
<dependencies>
<!-- specify the dependent jdbc driver here -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.jdbc.version}</version>
</dependency>
</dependencies>
<!-- common configuration shared by all executions -->
<configuration>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:5432:testdb</url>
<username>postgres</username>
<password>root</password>
<!-- You can comment out username/password configurations and have
maven to look them up in your settings.xml using ${settingsKey} -->
<settingsKey>sensibleKey</settingsKey>
<!--all executions are ignored if -Dmaven.test.skip=true -->
<skip>${maven.test.skip}</skip>
</configuration>
<executions>
<execution>
<id>drop-schema-before-test-if-any</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<!-- need another database to drop the targeted one -->
<url>jdbc:postgresql://localhost:5432:postgres</url>
<autocommit>true</autocommit>
<sqlCommand>DROP SCHEMA chipen CASCADE</sqlCommand>
<!-- ignore error when database is not available -->
<onError>continue</onError>
</configuration>
</execution>
<execution>
<id>create-schema</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<autocommit>true</autocommit>
<srcFiles>
<srcFile>src/main/sql/CHI-PEN-schema.sql</srcFile>
</srcFiles>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dbunit-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<dependencies>
<!-- specify the dependent jdbc driver here -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.jdbc.version}</version>
</dependency>
</dependencies>
<!-- common configuration shared by all executions -->
<configuration>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:5432:testdb</url>
<username>postgres</username>
<password>root</password>
<!-- You can comment out username/password configurations and have
maven to look them up in your settings.xml using ${settingsKey} -->
<settingsKey>sensibleKey</settingsKey>
<!--all executions are ignored if -Dmaven.test.skip=true -->
<skip>${maven.test.skip}</skip>
</configuration>
<executions>
<execution>
<phase>test-compile</phase>
<goals>
<goal>operation</goal>
</goals>
<!-- specific configurations -->
<configuration>
<type>CLEAN_INSERT</type>
<src>src/test/data/testdb_chipen_data.xml</src>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Apart from the above a thing like this are integration tests and not unit tests but this is a different question/discussion.
With the maven jar plugin I build two jar: bar-1.0.0.jar and bar-1.0.0-client.jar.
Actually in my POM I have the following dependency:
<dependency>
<groupId>de.app.test</groupId>
<artifactId>foo</artifactId>
<version>1.0.0</version>
</dependency>
This artifact exist also in two version bar-1.0.0.jar and bar-1.0.0-client.jar
I want to make bar-1.0.0-client.jar dependent of foo-1.0.0-client.jar and bar-1.0.0.jar dependent of foo-1.0.0.jar.
================
->First (wrong) solution: define the scope as provided and use the right foo package when using bar.jar
->Second (long) solution : Add 'server' classifier to the other jar. Use different profile to build the foo artifact and put the classifier in a property.
<dependency>
<groupId>de.app.test</groupId>
<artifactId>foo</artifactId>
<version>1.0.0</version>
<classifier>${profile.classifier}<classifier>
</dependency>
================
Concerning the profile solution.
Interfaces module pom
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.app</groupId>
<artifactId>myapp-parent</artifactId>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.app</groupId>
<artifactId>myapp-interfaces</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>myapp Interfaces</name>
<profiles>
<profile>
<id>server</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>jar-server</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>server</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>client</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>jar-client</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>client</classifier>
<excludes>
<exclude>**/server/**</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Implementation module pom
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.app</groupId>
<artifactId>myapp-parent</artifactId>
<version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.app</groupId>
<artifactId>myapp-model</artifactId>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>myapp Model</name>
<properties>
<myapp-interfaces.classifier></myapp-interfaces.classifier>
<myapp-interfaces.version>1.1.0-SNAPSHOT</myapp-interfaces.version>
</properties>
<dependencies>
<dependency>
<groupId>com.app</groupId>
<artifactId>myapp-interfaces</artifactId>
<version>${myapp-interfaces.version}</version>
<classifier>${myapp-interfaces.classifier}</classifier>
</dependency>
[...]
</dependencies>
<profiles>
<profile>
<id>server</id>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>jar-server</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>server</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.app</groupId>
<artifactId>myapp-interfaces</artifactId>
<version>${myapp-interfaces.version}</version>
<classifier>${myapp-interfaces.classifier}</classifier>
</dependency>
</dependencies>
<properties>
<myapp-interfaces.classifier>server</myapp-interfaces.classifier>
</properties>
</profile>
<profile>
<id>client</id>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>jar-client</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>client</classifier>
<excludes>
<exclude>**/server/**</exclude>
<exclude>**/META-INF/services/**</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<myapp-interfaces.classifier>client</myapp-interfaces.classifier>
</properties>
<dependencies>
<dependency>
<groupId>com.app</groupId>
<artifactId>myapp-interfaces</artifactId>
<version>${myapp-interfaces.version}</version>
<classifier>${myapp-interfaces.classifier}</classifier>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
The problem with this solution is due to the fact that my client interface have some missing interfaces and maven throw a compilation error during the compile phase.
And if I use myapp-model and an other project I didn't not have dependency to the right myapp-interface.
I wonder if it's possible to build a jar and put a specific pom inside ?
For the Interfaces.
I change nothing and build the both interfaces.jar (client + server).
For the Model
I import the both jar as optional
<dependency>
<groupId>com.app</groupId>
<artifactId>myapp-interfaces</artifactId>
<version>${myapp-interfaces.version}</version>
<classifier>client</classifier>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.app</groupId>
<artifactId>myapp-interfaces</artifactId>
<version>${myapp-interfaces.version}</version>
<classifier>server</classifier>
<optional>true</optional>
</dependency>
With that I can build the both model's version without any error.
In my client application and server application
For each application I create the dependency to the right interfaces.jar and models.jar