POM.xml
<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>Imageproceesing</groupId>
<artifactId>beginner</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>beginner</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<environment>${env}</environment>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/net.sourceforge.tess4j/tess4j -->
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>4.4.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Environment is the parameter i'm going to pass via
mvn clean test -Denv=dev
in Test class
public class AppTest
{
@Test
public void demo()
{
String environment=System.getProperty("environment");
if(environment.equals("dev"))
//...rest code here
System.out.println("check the code");
}
}
I'm in need to pass the environment variable from command line to pom and to Java, but every time I'm getting null.