lundi 1 août 2016

MAVEN: How to create executable jar file for groovy classes

I have a project where all files are Groovy classes and they are solely for test automation like below:

import geb.Browser
....
....

@Stepwise
class HomePage extends GebReportingSpec
{

def "Open Homepage"()
{
    cleanReportGroupDir()
    when: "Opening browser"
    to TopPage;
    and:
    report "HomePage opened"

    then: "Click Login Button"
    loginButton.click()
    and:
    report "Login Button Clicked"
}

def "Enter credentials and log in to xxx.co.jp"()
{
    when: "Log in page opened"
    at LoginPage
    and:
    report "Log in page opened"

    then: "Enter User Name and Password"
    username.value("xxx@gmail.com")
    password.value("password")
    and:
    signin.click()
    and:
    at TopPage
    report "Entered credentials and logged in"
}

def "Signin completed and top page opened. Now go to mypage"()
{
    when: "Signed in and top page is opened"
        myPage.click()

    then: "Waiting for loading mypage"  
        waitFor{at MyPage}
        report "MyPage opened"      
}

def "Click log Out button and log out from mypage"()
{
    when: "Logged into mypage"
        logout.click()

    then: "Waiting for loading mypage"
        waitFor{at BackToTopPage}
        report "Clicked logout button"      
}

def "After logged out , go back to homepage"()
{
    when: "Click \"Go To Top\" Button"
        goBackToTopPage.click()

    then: "Check if logged out"
        report "At homepage after logout"
}

}

I have the folder structure like below:

enter image description here

When I create package with mvn clean package command, and try to execute the created jar file, the following error occurs:

C:\Users\GebSpockBuildTest\target>java -jar Geb-0.0.1-SNAPSHOT.jar
Geb-0.0.1-SNAPSHOT.jarにメイン・マニフェスト属性がありません

Translation: It is saying that, it does not find the main class in the manifest

Does someone know how to create runnable jar in this case?

Aucun commentaire:

Enregistrer un commentaire