Maven CLI Options Reference says -D option define a system property. The question is how to retrieve this option in Java Code.
I tried the following snippet and command, but couldn't retrieve it.
public class Test2Class {
@Test
public void test() {
System.out.println((new Properties()).get("env"));
}
}
mvn -Dtest=Test2Class test -Denv=dev
What else should I do to make it work?