How to pass java code a parameter from maven for testing

This is the exact thing I was looking for my automation test and I got it working. Command Line argument mvn clean test -Denv.USER=UAT -Dgroups=Sniff 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>TestNg</groupId> <artifactId>TestNg</artifactId> <version>1.0</version> <dependencies> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.8</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.12.4</version> <configuration> … Read more

pom.xml environment variable with default fallback

I wasn’t really satisfied with the accepted approach, so I simplified it a little. Basically set a default property in the normal properties block, and only override when appropriate (instead of an effective switch statement): <properties> <!– Sane default –> <buildNumber>0</buildNumber> <!– the other props you use –> </properties> <profiles> <profile> <id>ci</id> <activation> <property> <name>env.buildNumber</name> … Read more

By default, where does Spring Boot expect views to be stored?

The Solution I found the answer via trial-and-error, which turned out rather annoying. I hope someone can correct me if this conclusion is wrong, but it appears that Spring Boot does not like the string WEB-INF. I renamed the WEB-INF directory to view and changed the application.properties to the following and the view loaded successfully. … Read more

maven exclude plugin defined in parent pom

I had a similar requirement to run some plugins in the child but not the parent POM. i achieved this by stating <skip>true</skip> in the parent POM. the parent pom entry is below <plugin> <groupId>eviware</groupId> <artifactId>maven-soapui-plugin</artifactId> <version>4.0.0</version> <inherited>false</inherited> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> </dependency> </dependencies> <configuration> <skip>true</skip> </configuration> </plugin> The child project pom entry is … Read more

Is it possible to use maven buildnumber plugin to generate build number without any scm check?

Define a dummy SCM and then use buildNumber item to get sequential build number instead of value defined by revisionOnScmFailure property. pom.xml: <project …> <scm> <connection>scm:svn:http://127.0.0.1/dummy</connection> <developerConnection>scm:svn:https://127.0.0.1/dummy</developerConnection> <tag>HEAD</tag> <url>http://127.0.0.1/dummy</url> </scm> <build> <plugins> … <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>buildnumber-maven-plugin</artifactId> <version>1.1</version> <executions> <execution> <id>buildnumber</id> <phase>validate</phase> <goals> <goal>create</goal> </goals> </execution> </executions> <configuration> <format>{0,number}</format> <items> <item>buildNumber</item> </items> <doCheck>false</doCheck> <doUpdate>false</doUpdate> <revisionOnScmFailure>unknownbuild</revisionOnScmFailure> </configuration> … Read more

tech