Running Cucumber tests directly from executable jar

I would divide the problem you are thinking of in two parts. Create an executable jar Run Cucumber from your own main method Creating an executable jar using Maven can be done in different ways. One way of doing it is described here: http://www.thinkcode.se/blog/2011/03/05/create-an-executable-jar-from-maven It is a small example that only focuses on executing something … Read more

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

How to exclude maven dependencies?

You can utilize the dependency management mechanism. If you create entries in the <dependencyManagement> section of your pom for spring-security-web and spring-web with the desired 3.1.0 version set the managed version of the artifact will override those specified in the transitive dependency tree. I’m not sure if that really saves you any code, but it … Read more

Maven best practice for creating ad hoc zip artifact

Decide what classifier you will use for your zip file, for sake of argument let’s say it would be sample. In your project create file assembly/sample.xml Fill in assembly/sample.xml with something like this: <?xml version=”1.0″ encoding=”UTF-8″?> <assembly xmlns=”http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=” http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd” > <id>sample</id> <formats> <format>zip</format> </formats> <fileSets> <fileSet> <outputDirectory>/</outputDirectory> <directory>some/directory/in/your/project</directory> </fileSet> </fileSets> <!– use … Read more

Make maven’s surefire show stacktrace in console

A related problem that I found is that surefire in recent versions apparently sets trimStackTrace to true by default (rendering most stack trace in failed tests useless), which is quite inconvenient. Setting -DtrimStackTrace=false or defining <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <trimStackTrace>false</trimStackTrace> </configuration> </plugin> solved this.

Change source directory in profile maven

According to the documentation, you can change only few <build> parameters in the profile and <sourceDirectory> is not one of them. I’d configure the main <build> to take sources from path defined by some property (eg. src.dir), set this property to src/main/java and override it in the custom profile: <project> … <properties> <src.dir>src/main/java</src.dir> </properties> <build> … Read more

How to override the `project.build.finalName` Maven property from the command line?

See Introduction to the POM finalName is created as: <build> <finalName>${project.artifactId}-${project.version}</finalName> </build> One of the solutions is to add own property: <properties> <finalName>${project.artifactId}-${project.version}</finalName> </properties> <build> <finalName>${finalName}</finalName> </build> And now try: mvn -DfinalName=build clean package

Resolving SNAPSHOT dependencies with timestamps from Ivy

Ivy supports resolving timestamped snapshots, but with the following limitation: the specified pattern on your ibiblio resolver must end with: [organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext] This is not the case in your setup, so Ivy won’t try to find your timestamped snapshot. Updating your pattern to this one should solve your problem; update the definition of your archiva-snapshots repository … Read more