Create executable JAR in Cucumber/Java project in Intellij/idea

2,044 views
Skip to first unread message

Vegard Nyeng

unread,
Aug 12, 2014, 6:58:19 AM8/12/14
to cu...@googlegroups.com

I need to create an executable JAR for my Javabased Cucumber project.

This is my folder structure:

https://imagizer.imageshack.us/v2/229x373q90/674/EiXWux.png

(The Bellyclass in main/java/skeleton is also not used). All the feature steps are in the resources/skeleton folder and all step definitions are under test/java/skeleton

the files that are not displayed are: - gitignore, build.xml, cucumber-java-skeleton.iml, pom.xml and README.md

I've tried to do some research, but struggled finding out what I should include in my pom.xml file. I have currently ran my project using Intellij, but I need to hand it over to someone that can easily run the project on iOS/Mac.

Best regards, V.

aslak hellesoy

unread,
Aug 12, 2014, 8:12:52 AM8/12/14
to Cucumber Users
On Tue, Aug 12, 2014 at 11:58 AM, Vegard Nyeng <vegard...@testify.no> wrote:

I need to create an executable JAR for my Javabased Cucumber project.

Why do you need to do this?

Aslak 

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vegard Nyeng

unread,
Aug 12, 2014, 8:20:53 AM8/12/14
to cu...@googlegroups.com
I just need to find the simplest way possible that I can let another person execute the feature-files from his Mac. 

- V

Vegard Nyeng

unread,
Aug 12, 2014, 8:42:23 AM8/12/14
to cu...@googlegroups.com
I thought it would be the easiest way for the person to run the feature-files from his Mac. 

Vegard


kl. 14:12:52 UTC+2 tirsdag 12. august 2014 skrev Aslak Hellesøy følgende:

aslak hellesoy

unread,
Aug 12, 2014, 8:59:46 AM8/12/14
to Cucumber Users
On Tue, Aug 12, 2014 at 1:20 PM, Vegard Nyeng <vegard...@testify.no> wrote:
I just need to find the simplest way possible that I can let another person execute the feature-files from his Mac. 


Can't they run `mvn test`?

I don't remember if maven is installed by default on a mac, but if not - that's certainly easier to install with e.g. homebrew than fiddling with self-executing jars IMO.

Aslak

Robert

unread,
Aug 14, 2014, 12:17:49 AM8/14/14
to cu...@googlegroups.com
Vegard,


On Tuesday, August 12, 2014 5:42:23 AM UTC-7, Vegard Nyeng wrote:
I thought it would be the easiest way for the person to run the feature-files from his Mac. 

Vegard


As Aslak noted, I think the easiest way to handle this is with Maven.  We currently support our projects on Windows and Mac using Maven.  In fact, I should also add Linux to that mix, since our CI server runs our tests from a Linux box. :-)

Michaes S

unread,
Aug 14, 2014, 2:38:32 AM8/14/14
to cu...@googlegroups.com
I use Cucumber-JVM's command line interface (cli) to run the features. I pack all dependent libraries (including cucumber jvm & gherkin) using maven assembly plugin into single jar. I provide the user with only single jar and they run it through command line. They just need java for that. (no need of maven, as it is still an alien to some people :)) Checkout earlier posts by Aslak where he mentions how to run features using cli.

Michaes

mohan....@gmail.com

unread,
Aug 18, 2014, 3:11:42 PM8/18/14
to cu...@googlegroups.com

Hi Michaes,
Can you please share me pom.xml used to create executablejar, so that it jar can be used to run from java instead of maven
For some reason, the jar file created does nt have all dependent jars files

Also, I would like to know how to run from "'maven test""
When I run maven test, cucumber features files are not excuted

Thanks
Mohan

James Nord

unread,
Aug 28, 2014, 5:35:03 AM8/28/14
to cu...@googlegroups.com
the following will create an executable jar for you to run assuming you have all of your dependencies setup.


<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>cucumber.api.cli.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>

/James

Reply all
Reply to author
Forward
0 new messages