I have 4 maven projects that should work as one application, one parent project who is responsible for building all other, one war project with jsf and beans, one jpa project with entities and one ejb project with dao and ejb layer. I try to run on tomee server my .war, but it doesn't include the other classes from jpa and ajb project...Here are poms:
EclipseJPA2-parent:
....
<groupId>pka</groupId>
<artifactId>EclipseJPA2-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<profiles>
<profile>
<id>EclipseJPA2</id>
<modules>
<module>../EclipseJPA2-war</module>
<module>../EclipseJPA2-jpa</module>
<module>../EclipseJPA2-ejb</module>
</modules>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>pka</groupId>
<artifactId>EclipseJPA2-war</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>pka</groupId>
<artifactId>EclipseJPA2-jpa</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>pka</groupId>
<artifactId>EclipseJPA2-ejb</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version>
<configuration>
<!-- Tell Maven we are using EJB 3.1 -->
<ejbVersion>3.1</ejbVersion>
<generateClient>true</generateClient>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.openejb.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<tomeeVersion>1.5.2</tomeeVersion>
<tomeeClassifier>plus</tomeeClassifier>
<debugPort>5005</debugPort>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
EclipseJPA2-jpa:
...
<parent>
<groupId>pka</groupId>
<artifactId>EclipseJPA2-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>EclipseJPA2-jpa</artifactId>
<name>EclipseJPA2-jpa</name>
<description></description>
<dependencies>
....
</dependencies>
EclipseJPA2-ejb:
...
<parent>
<groupId>pka</groupId>
<artifactId>EclipseJPA2-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>EclipseJPA2-ejb</artifactId>
<packaging>ejb</packaging>
<name>EclipseJPA2-ejb</name>
<dependencies>
<dependency>
<groupId>pka</groupId>
<artifactId>EclipseJPA2-jpa</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
...
</dependencies>
and EclipseJPA2-war
...
<artifactId>EclipseJPA2-war</artifactId>
<packaging>war</packaging>
<name>EclipseJPA2-war</name>
<parent>
<artifactId>EclipseJPA2-parent</artifactId>
<groupId>pka</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>pka</groupId>
<artifactId>EclipseJPA2-jpa</artifactId>
<type>jar</type>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>pka</groupId>
<artifactId>EclipseJPA2-ejb</artifactId>
<type>ejb</type>
<version>0.0.1-SNAPSHOT</version>
</dependency>
...
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<version.primefaces>3.5</version.primefaces>
<version.primefaces.themes>1.0.9</version.primefaces.themes>
</properties>
<repositories>
...
</repositories>
Do you know how to properly link those projects and include jars in war ?
mvn package output:
....
[INFO] ------------------------------------------------------------------------
[INFO] Building EclipseJPA2-jpa 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # EclipseJPA2-jpa - --
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # EclipseJPA2-jpa ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) # EclipseJPA2-jpa ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) # EclipseJPA2-jpa ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) # EclipseJPA2-jpa ---
[INFO] Surefire report directory: D:\usr\java\moje\system\EclipseJPA2-jpa\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) # EclipseJPA2-jpa ---
....
[INFO] ------------------------------------------------------------------------
[INFO] Building EclipseJPA2-ejb 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # EclipseJPA2-ejb ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # EclipseJPA2-ejb ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) # EclipseJPA2-ejb ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) # EclipseJPA2-ejb ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) # EclipseJPA2-ejb ---
[INFO] Surefire report directory: D:\usr\java\moje\system\EclipseJPA2-ejb\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-ejb-plugin:2.3:ejb (default-ejb) # EclipseJPA2-ejb ---
[INFO] Building EJB EclipseJPA2-ejb-0.0.1-SNAPSHOT with EJB version 3.1
[INFO] Building jar: D:\usr\java\moje\system\EclipseJPA2-ejb\target\EclipseJPA2-ejb-0.0.1-SNAPSHOT.jar
[INFO] Building EJB client EclipseJPA2-ejb-0.0.1-SNAPSHOT-client
[INFO] Building jar: D:\usr\java\moje\system\EclipseJPA2-ejb\target\EclipseJPA2-ejb-0.0.1-SNAPSHOT-client.jar
....
Related
I'm using "mvn test" to run cucumber tests, but when I try to pass options on the command line with
-Dcucumber.options=..., the options are ignored and the ones specified in #CucumberOptions in the runner class are used instead. For example, if I just try to display cucumber help, it ignores it and just runs the tests:
C:\Maven\ArchCuke\untitled>mvn test -Dcucumber.options="--help"
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< org.example:untitled >------------------------
[INFO] Building untitled 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # untitled ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Maven\ArchCuke\untitled\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # untitled ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # untitled ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # untitled ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\Maven\ArchCuke\untitled\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) # untitled ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.example.steps.CucumberTestRunner
Scenario: Add two numbers # features/arith.feature:4
Given A Calculator # org.example.steps.ArithSteps.aCalculator()
When I add 2 and 2 # org.example.steps.ArithSteps.iAddAnd(int,int)
Then I get 4 # org.example.steps.ArithSteps.iGet(int)
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.253 s - in org.example.steps.CucumberTestRunner
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.815 s
[INFO] Finished at: 2020-11-05T10:51:50-08:00
[INFO] ------------------------------------------------------------------------
C:\Maven\ArchCuke\untitled>
This is my runner class
package org.example.steps;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
#RunWith(Cucumber.class)
#CucumberOptions(
features = {"classpath:features"},
plugin = {"pretty"}
)
public class CucumberTestRunner {
}
and this is my pom.xml.
<?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>org.example</groupId>
<artifactId>untitled</artifactId>
<version>1.0-SNAPSHOT</version>
<name>untitled</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<junit.version>4.13</junit.version>
<cucumber.version>6.8.0</cucumber.version>
<maven.compiler.version>3.8.1</maven.compiler.version>
<maven.surefire.version>2.22.2</maven.surefire.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<encoding>UTF-8</encoding>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<!-- Include our runner class or 'mvn test' won't work; name doesn't match default template.
See https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html -->
<configuration>
<includes>
<include>CucumberTestRunner.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
I tried version 3.0.0-M5 of the surefire plugin instead of 2.22.2, with the same results.
What am I doing wrong here?
The cucumber.options property was deprecated and removed. You have to pass each option as a single property.
mvn test -Dcucumber.filter.tags='#smoke and not #ignore'
https://github.com/cucumber/cucumber-jvm/blob/main/release-notes/v5.0.0.md#property-based-options
You should not use the system property directly in your CLI. You should deliver the system property to the surefire subprocess
mvn test "-DargLine=-Dcucumber.filter.tags='#smoke and not #ignore'"
or make a little trick in your POM and then use your original CLI:
<properties>
<argLine>-Dcucumber.filter.tags='${cucumber.filter.tags}'</argLine>
</properties>
For some reason when i do mvn install and check my local repo and look at the pom there, i don't see that the version variable was substituted with the value.
I am using a parent pom with a version in the properties
<properties>
<maven.javadoc.skip>true</maven.javadoc.skip>
<revision>19.3.29</revision>
</properties>
It also contains the flatten plugin entry:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.2.2</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
The child pom uses the ${revision} as the value for the version & ${project.version} for dependencies as recommended by maven:
<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>
<artifactId>analysisModule</artifactId>
<version>${revision}</version>
<parent>
<groupId>com.mycompany.analysis</groupId>
<version>1.0.0</version>
<artifactId>autoav</artifactId>
<relativePath>../autoAV</relativePath>
</parent>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>com.mycompany.analysis</groupId>
<artifactId>analysisCore</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Looking at the local repo pom xml after I 'mvn install' :
<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>
<artifactId>analysisJdbc</artifactId>
<version>${revision}</version>
<description>analysis of jdbc sources</description>
<parent>
<groupId>com.mycompany.analysis</groupId>
<version>1.0.0</version>
<artifactId>autoav</artifactId>
<relativePath>../autoAV</relativePath>
</parent>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>com.mycompany.analysis</groupId>
<artifactId>analysisCore</artifactId>
<version>${project.version}</version>
</dependency>
...
</project>
Shouldn't the ${revision} & ${project.version} been replaced with the actual numbers ?
Isn't that the whole thing about using flatten plugin ?
I followed this
https://www.mojohaus.org/flatten-maven-plugin/examples/example-central-version.html
Adding my output of mvn install (skipping tests) (maven version 3.3.9):
02:12:03 :/code/thedrs/gitrepos/analysis/analysis/analysisJdbc (main) $ mvn install -Dmaven.test.skip=true
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building analysisJdbc 19.3.30
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # analysisJdbc ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # analysisJdbc ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # analysisJdbc ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # analysisJdbc ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # analysisJdbc ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # analysisJdbc ---
[INFO] Building jar: /code/thedrs/gitrepos/analysis/analysis/analysisJdbc/target/analysisJdbc-19.3.30.jar
[INFO] META-INF/maven/com.mycompany.analysis/analysisJdbc/pom.xml already added, skipping
[INFO] META-INF/maven/com.mycompany.analysis/analysisJdbc/pom.properties already added, skipping
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # analysisJdbc ---
[INFO] Installing /code/thedrs/gitrepos/analysis/analysis/analysisJdbc/target/analysisJdbc-19.3.30.jar to /code/thedrs/.m2/com/mycompany/analysis/analysisJdbc/19.3.30/analysisJdbc-19.3.30.jar
[INFO] Installing /code/thedrs/gitrepos/analysis/analysis/analysisJdbc/pom.xml to /code/thedrs/.m2/com/mycompany/analysis/analysisJdbc/19.3.30/analysisJdbc-19.3.30.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.147 s
[INFO] Finished at: 2020-05-06T02:12:40-07:00
[INFO] Final Memory: 14M/356M
[INFO] ------------------------------------------------------------------------
You need to move the plugin from <pluginManagement><plugins> to <plugins>. Alternatively, you can leave it there and just add a short plugin definition (including groupId and artifactId) to the <plugins> section.
<pluginManagement> is just to preconfigure version numbers and configuration. Plugins in <pluginManagement> are not run during the build unless they reappear in <plugins>.
I've been able to achieve that by creating another property for the dependencies. This property will have the same value as ${revision} and will be replaced in the generated pom file.
<properties>
<revision>19.3.29</revision>
<my-lib.version>${revision}</my-lib.version>
</properties>
Then instead of using ${project.version} in your dependencies, use your property:
<dependency>
<groupId>com.mycompany.analysis</groupId>
<artifactId>analysisCore</artifactId>
<version>${my-lib.version}</version>
</dependency>
I have some Maven tests suite using Junit 4.12, that running well using 'mvn test' locally on my Mac, but not running at all on remote CI machine:
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # AndroidAutomationTests ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/circleci/project/AndroidAutomaticTests/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # AndroidAutomationTests ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # AndroidAutomationTests ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/circleci/project/AndroidAutomaticTests/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # AndroidAutomationTests ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.22.0:test (default-test) # AndroidAutomationTests ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.619 s
[INFO] Finished at: 2019-10-17T07:33:04Z
[INFO] ------------------------------------------------------------------------
Here is the POM.xml:
<?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>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<argLine>-Dfile.encoding=UTF-8</argLine>
<systemPropertyVariables>
<browserStack>0</browserStack>
<jenkins>0</jenkins>
<kobiton>0</kobiton>
<bs>null</bs>
<buildDirectory>${project.build.directory}</buildDirectory>
<appPath>k</appPath>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<groupId>GlucoMe</groupId>
<artifactId>AndroidAutomationTests</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20171018</version>
</dependency>
</dependencies>
</project>
Both Maven versions are 3.6.0, and it's exactly the same project and branch.
Any idea?
Also, all tests name ends with "Test" and so are the tests classes.
Thanks!
I'm trying to learn maven and work through the Maven Getting Started Guide (https://maven.apache.org/guides/getting-started/index.html#How_do_I_add_resources_to_my_JAR). I don't get the desired folder structure with a resources folder in the main directory.
I tried all archetypes on https://maven.apache.org/guides/introduction/introduction-to-archetypes.html, but none of them have the desired folder struture
My POM-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/maven-v4_0_0.xsd">
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
</plugin>
</plugins>
</build>
</project>
Command to create the maven project:
mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=com.mycompany.app -DartifactId=my-app
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.mycompany.app:my-app >----------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # my-app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\k01bagci\Desktop\maven example\my-app\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) # my-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # my-app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\k01bagci\Desktop\maven example\my-app\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) # my-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.357 s
[INFO] Finished at: 2019-07-04T11:29:17+02:00
[INFO] ------------------------------------------------------------------------
i have configured my eclipse with maven and testNG, PF my pom.xml below:
<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>
<parent>
<artifactId>iONAutomation</artifactId>
<groupId>com.iON.tcs</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.iON.tcs</groupId>
<artifactId>common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>common</name>
<description>maintains all common code</description>
<profiles>
<profile>
<id>selenium-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.3.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
am runnong from the cmd prompt thu this dir: D:\EclipseWorkspace\iON27Feb2013\iONAutomation\common>
I tried usinng mvn test and mvn -Dtest=NewTest test commands, didnot succeed.
My cmd console displays:
D:\EclipseWorkspace\iON27Feb2013\iONAutomation\common>mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building common 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # common ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # common ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) # co
mmon ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) # commo
n ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) # common ---
[INFO] Surefire report directory: D:\EclipseWorkspace\iON27Feb2013\iONAutomation
\common\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.932s
[INFO] Finished at: Thu Feb 28 19:11:43 IST 2013
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
If you have a profile defined, then afaik, you need to invoke that profile ...mvn test -Pselenium-tests. As such if there is no particular reason for u to use profiles, then you might just go without them, in which case mvn test should work just fine.
Did you try to put
<sourceDirectory>/home/{userName}/{projectLocation}/src/main/java/packageTest</sourceDirectory>
inside your build ?
I had the same problem and this line solved it.
You can also try to add a goal to your pom file
<execution>
<id>default-test</id>
<phase>test</phase>``
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
Hope it will help you !