Hello,

You will in any case need to add supplementary jar dependencies to your
command line.

The easiest way is to use the maven plugin dependency and execute its
copy-dependencies [
http://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html]
at package phase.

You can do it by adding that plugin configuration:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.4</version>
    <executions>
        <execution>
            <id>copy</id>
            <phase>package</phase>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
            <configuration>

            </configuration>
        </execution>
    </executions>
</plugin>

This would automatically copy the needed jar files in target/dependencies
so that you can adapt java -cp target/<NameOfJar>;taget/dependencies/*
VxcExperience.Selenium.Example.SeleniumDemoTests.RemoteWebDriverTest

I also seen people using unpack goal to unzip all dependencies jar in a
folder in a previous phase so that package phase will create one huge
single jar file but it is very discouraged.



2012/5/15 Bhréin Brannick <[email protected]>

> Hi,
>
> I hoping someone on this mailer can help with the following. I'm a newbie
> to Eclipse & Maven and this may be a basic question but I'm trying to build
> a single executable Jar file that will include project dependencies so for
> this I'm using m2eclipse a maven plugin for eclipse. So here is where I'm
> at present.
>
> The project has two main java files and one test file (default test and
> main file through using m2eclipse new project wizard). I added my own class
> namely the following
>
> *package VxcExperience.Selenium.Example.SeleniumDemoTests;
> import java.net.URL;
> import org.openqa.selenium.Dimension;
> import org.openqa.selenium.Point;
> import org.openqa.selenium.WebDriver;
> import org.openqa.selenium.remote.DesiredCapabilities;
> import org.openqa.selenium.remote.RemoteWebDriver;
> public class RemoteWebDriverTest
> {
>     public static void main(String[] args) throws Exception
>     {
>         WebDriver driver = new RemoteWebDriver(new URL("
> http://10.53.59.247:4444/wd/hub";), DesiredCapabilities.firefox());
>
>             driver.get("http://www.google.com";);
>
>             driver.manage().window().setPosition(new Point(100, 100));
>
>              driver.manage().window().maximize();
>
>              driver.manage().window().setSize(new Dimension(600, 600));
>     }
> }*
>
> As you can see per the above this class would have dependency on Selenium
> packages which I used m2eclipse to resolve and am able to run as a Java
> application within the IDE. Namely all the selenium libraries are located
> under Maven Dependencies within package explorer. So far OK. But what I'm
> trying to do is export it to a single Jar file that would have references
> to selenium dependencies within it so that i can essentially drop on
> another users machine and run like the following from a command line:
>
> *java -classpath <NameOfJar>.jar
> VxcExperience.Selenium.Example.SeleniumDemoTests.RemoteWebDriverTest*
>
> However, this never works as the built jar doesn't include the Selenium
> references from viewing the package using 7-zip. But if i tried the sample
> that is created using the wizard for example
>
> *java -classpath <NameOfJar>.jar
> VxcExperience.Selenium.Example.SeleniumDemoTests.App*
>
> it prints hello world. I wonder what I'm trying to do is achievable using
> eclipse and m2eclipse or am I missing a step? I believe m2eclipse to be the
> tool to use to bundle up dependencies into a runnable single jar file.
> Sorry to spam the wrong mailer if this is not the right place to ask this
> question but I'd appreciate any guidance given. Thanks in advance. Btw my
> pom.xml looks like the following
>
> *<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>VxcExperience.Selenium.Example</groupId>
> <artifactId>SeleniumDemoTests-Project</artifactId>
> <version>0.0.1-SNAPSHOT</version>
> <packaging>jar</packaging>
>
> <name>SeleniumDemoTests-Project</name>
> <url>http://maven.apache.org</url>
>
> <properties>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> </properties>
>
> <dependencies>
> <dependency>
>       <groupId>junit</groupId>
>       <artifactId>junit</artifactId>
>       <scope>provided</scope>
>     </dependency>
>     <dependency>
>         <groupId>org.seleniumhq.selenium</groupId>
>         <artifactId>selenium-server</artifactId>
>         <scope>provided</scope>
>     </dependency>
>     <dependency>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-clean-plugin</artifactId>
>         <version>2.4.1</version>
>     </dependency>
>   </dependencies>
>   <dependencyManagement>
>       <dependencies>
>           <dependency>
>               <groupId>junit</groupId>
>               <artifactId>junit</artifactId>
>               <version>3.8.1</version>
>               <scope>provided</scope>
>           </dependency>
>           <dependency>
>               <groupId>org.seleniumhq.selenium</groupId>
>               <artifactId>selenium-server</artifactId>
>               <version>2.21.0</version>
>               <scope>provided</scope>
>           </dependency>
>       </dependencies>
>   </dependencyManagement>
> </project>*
>
> Kind Regards,
>
> -Bhréin
>
>
> _______________________________________________
> m2e-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/m2e-users
>
>


-- 
 <http://www.visionitgroup.be>

Eric Cornely
Trainer @ Vision IT Group
Chaussée de Louvain 431 (Bât H)
1380 Lasne
Mobile : +32 (0)494 25 22 77
[email protected]

Please consider the environment before printing this e-mail
_______________________________________________
m2e-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/m2e-users

Reply via email to