Migrate maven dependencies to gradle












2















I start with software testing - using Cucumber, Java, gradle.
I try to learn this with the book "The Cucumber for Java Book"



But I try to do I with gradle instead of maven... But now I have some problems...
I stick on page 149. I have to give so dependecies:



<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
</dependency>


I try to "translate" this to gradle



dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'io.cucumber:cucumber-java:2.4.0'
testCompile 'io.cucumber:cucumber-junit:2.4.0'
testCompile group: 'info.cukes', name: 'cucumber-picocontainer', version: '1.2.5'
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'
}


Is this right?
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'



After that I have to run:



mvn exec:java -Dexec.mainClass="nicebank.AtmServer"


But how can I do this with gradle?



I hope someone can help me :)










share|improve this question























  • the dependency for jetty-webapp looks OK (but you should replace compile by implementation if you use latest version of Gradle). And for running the app you could use JavaExec task from the Gradle Java Plugin, see docs.gradle.org/current/dsl/org.gradle.api.tasks.JavaExec.html

    – M.Ricciuti
    Nov 13 '18 at 13:42













  • Thank you for the quick comment :) But I dont really know how I can configurate the JaceExec task for my project :(

    – Deviasa
    Nov 13 '18 at 13:56
















2















I start with software testing - using Cucumber, Java, gradle.
I try to learn this with the book "The Cucumber for Java Book"



But I try to do I with gradle instead of maven... But now I have some problems...
I stick on page 149. I have to give so dependecies:



<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
</dependency>


I try to "translate" this to gradle



dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'io.cucumber:cucumber-java:2.4.0'
testCompile 'io.cucumber:cucumber-junit:2.4.0'
testCompile group: 'info.cukes', name: 'cucumber-picocontainer', version: '1.2.5'
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'
}


Is this right?
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'



After that I have to run:



mvn exec:java -Dexec.mainClass="nicebank.AtmServer"


But how can I do this with gradle?



I hope someone can help me :)










share|improve this question























  • the dependency for jetty-webapp looks OK (but you should replace compile by implementation if you use latest version of Gradle). And for running the app you could use JavaExec task from the Gradle Java Plugin, see docs.gradle.org/current/dsl/org.gradle.api.tasks.JavaExec.html

    – M.Ricciuti
    Nov 13 '18 at 13:42













  • Thank you for the quick comment :) But I dont really know how I can configurate the JaceExec task for my project :(

    – Deviasa
    Nov 13 '18 at 13:56














2












2








2








I start with software testing - using Cucumber, Java, gradle.
I try to learn this with the book "The Cucumber for Java Book"



But I try to do I with gradle instead of maven... But now I have some problems...
I stick on page 149. I have to give so dependecies:



<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
</dependency>


I try to "translate" this to gradle



dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'io.cucumber:cucumber-java:2.4.0'
testCompile 'io.cucumber:cucumber-junit:2.4.0'
testCompile group: 'info.cukes', name: 'cucumber-picocontainer', version: '1.2.5'
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'
}


Is this right?
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'



After that I have to run:



mvn exec:java -Dexec.mainClass="nicebank.AtmServer"


But how can I do this with gradle?



I hope someone can help me :)










share|improve this question














I start with software testing - using Cucumber, Java, gradle.
I try to learn this with the book "The Cucumber for Java Book"



But I try to do I with gradle instead of maven... But now I have some problems...
I stick on page 149. I have to give so dependecies:



<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
</dependency>


I try to "translate" this to gradle



dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'io.cucumber:cucumber-java:2.4.0'
testCompile 'io.cucumber:cucumber-junit:2.4.0'
testCompile group: 'info.cukes', name: 'cucumber-picocontainer', version: '1.2.5'
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'
}


Is this right?
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'



After that I have to run:



mvn exec:java -Dexec.mainClass="nicebank.AtmServer"


But how can I do this with gradle?



I hope someone can help me :)







java maven gradle cucumber






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 13:39









DeviasaDeviasa

507




507













  • the dependency for jetty-webapp looks OK (but you should replace compile by implementation if you use latest version of Gradle). And for running the app you could use JavaExec task from the Gradle Java Plugin, see docs.gradle.org/current/dsl/org.gradle.api.tasks.JavaExec.html

    – M.Ricciuti
    Nov 13 '18 at 13:42













  • Thank you for the quick comment :) But I dont really know how I can configurate the JaceExec task for my project :(

    – Deviasa
    Nov 13 '18 at 13:56



















  • the dependency for jetty-webapp looks OK (but you should replace compile by implementation if you use latest version of Gradle). And for running the app you could use JavaExec task from the Gradle Java Plugin, see docs.gradle.org/current/dsl/org.gradle.api.tasks.JavaExec.html

    – M.Ricciuti
    Nov 13 '18 at 13:42













  • Thank you for the quick comment :) But I dont really know how I can configurate the JaceExec task for my project :(

    – Deviasa
    Nov 13 '18 at 13:56

















the dependency for jetty-webapp looks OK (but you should replace compile by implementation if you use latest version of Gradle). And for running the app you could use JavaExec task from the Gradle Java Plugin, see docs.gradle.org/current/dsl/org.gradle.api.tasks.JavaExec.html

– M.Ricciuti
Nov 13 '18 at 13:42







the dependency for jetty-webapp looks OK (but you should replace compile by implementation if you use latest version of Gradle). And for running the app you could use JavaExec task from the Gradle Java Plugin, see docs.gradle.org/current/dsl/org.gradle.api.tasks.JavaExec.html

– M.Ricciuti
Nov 13 '18 at 13:42















Thank you for the quick comment :) But I dont really know how I can configurate the JaceExec task for my project :(

– Deviasa
Nov 13 '18 at 13:56





Thank you for the quick comment :) But I dont really know how I can configurate the JaceExec task for my project :(

– Deviasa
Nov 13 '18 at 13:56












2 Answers
2






active

oldest

votes


















0














As I said in my comment, the dependency for jetty-webapp seems OK but you should use implementation instead of compile ( compile has been deprecated, see Java dependency configurations):



implementation group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'


or



implementation "org.eclipse.jetty:jetty-webapp:9.4.12.v20180830"


For the equivalent of "maven exec:java" in Gradle , you could use the Gradle JavaExec task type: try to define a task in your build as follows:



task runApp(type: JavaExec) {
classpath = sourceSets.main.runtimeClasspath

main = 'nicebank.AtmServer'

}


(not tested, you migth have to adapt it) , and run it with



gradle runApp


You could alternatively use Gretty plugin to run your webapp (no need to define your own JavaExec task in this case), as documented here and here:



plugins{
// your existing plugins
id "org.gretty" version "2.2.0"
}


You can then run the application with:



gradle appRun





share|improve this answer


























  • Thank you very much! It works fine now :)

    – Deviasa
    Nov 13 '18 at 15:17



















1














Your dependency looks good. Just one note: consider using implementation over compile as it improves the performance. Read about compile deprecation here.



You can also put your properties in gradle.properties file and reference them in the build script:



gradle.properties:



jettyVersion=9.4.12.v20180830


build.gradle:



implementation group: 'org.eclipse.jetty', name: 'jetty-webapp', version: jettyVersion


Jetty team also published BOMs: — org.eclipse.jetty:jetty-bom:9.4.12.v20180830 in your case. If you use multiple projects of the same version you can import the BOM and skip the version completely:



dependencies {
implementation 'org.eclipse.jetty:jetty-bom:9.4.12.v20180830'
implementation 'org.eclipse.jetty:jetty-webapp'
implementation 'org.eclipse.jetty:jetty-runner'
}


As for the "exec" task: if you have only one main class in your project, like nicebank.AtmServer, consider using Gradle's Application Plugin:



plugins {
id 'application'
}

mainClassName = 'nicebank.AtmServer'


This way you don't need to create "exec" task manually, you'll get one (run) from the plugin. As a bonus you'll get two "distribution" tasks that will create a ready-for-distribution archive with your app: distZip and distTar.






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53282313%2fmigrate-maven-dependencies-to-gradle%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    As I said in my comment, the dependency for jetty-webapp seems OK but you should use implementation instead of compile ( compile has been deprecated, see Java dependency configurations):



    implementation group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'


    or



    implementation "org.eclipse.jetty:jetty-webapp:9.4.12.v20180830"


    For the equivalent of "maven exec:java" in Gradle , you could use the Gradle JavaExec task type: try to define a task in your build as follows:



    task runApp(type: JavaExec) {
    classpath = sourceSets.main.runtimeClasspath

    main = 'nicebank.AtmServer'

    }


    (not tested, you migth have to adapt it) , and run it with



    gradle runApp


    You could alternatively use Gretty plugin to run your webapp (no need to define your own JavaExec task in this case), as documented here and here:



    plugins{
    // your existing plugins
    id "org.gretty" version "2.2.0"
    }


    You can then run the application with:



    gradle appRun





    share|improve this answer


























    • Thank you very much! It works fine now :)

      – Deviasa
      Nov 13 '18 at 15:17
















    0














    As I said in my comment, the dependency for jetty-webapp seems OK but you should use implementation instead of compile ( compile has been deprecated, see Java dependency configurations):



    implementation group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'


    or



    implementation "org.eclipse.jetty:jetty-webapp:9.4.12.v20180830"


    For the equivalent of "maven exec:java" in Gradle , you could use the Gradle JavaExec task type: try to define a task in your build as follows:



    task runApp(type: JavaExec) {
    classpath = sourceSets.main.runtimeClasspath

    main = 'nicebank.AtmServer'

    }


    (not tested, you migth have to adapt it) , and run it with



    gradle runApp


    You could alternatively use Gretty plugin to run your webapp (no need to define your own JavaExec task in this case), as documented here and here:



    plugins{
    // your existing plugins
    id "org.gretty" version "2.2.0"
    }


    You can then run the application with:



    gradle appRun





    share|improve this answer


























    • Thank you very much! It works fine now :)

      – Deviasa
      Nov 13 '18 at 15:17














    0












    0








    0







    As I said in my comment, the dependency for jetty-webapp seems OK but you should use implementation instead of compile ( compile has been deprecated, see Java dependency configurations):



    implementation group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'


    or



    implementation "org.eclipse.jetty:jetty-webapp:9.4.12.v20180830"


    For the equivalent of "maven exec:java" in Gradle , you could use the Gradle JavaExec task type: try to define a task in your build as follows:



    task runApp(type: JavaExec) {
    classpath = sourceSets.main.runtimeClasspath

    main = 'nicebank.AtmServer'

    }


    (not tested, you migth have to adapt it) , and run it with



    gradle runApp


    You could alternatively use Gretty plugin to run your webapp (no need to define your own JavaExec task in this case), as documented here and here:



    plugins{
    // your existing plugins
    id "org.gretty" version "2.2.0"
    }


    You can then run the application with:



    gradle appRun





    share|improve this answer















    As I said in my comment, the dependency for jetty-webapp seems OK but you should use implementation instead of compile ( compile has been deprecated, see Java dependency configurations):



    implementation group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.12.v20180830'


    or



    implementation "org.eclipse.jetty:jetty-webapp:9.4.12.v20180830"


    For the equivalent of "maven exec:java" in Gradle , you could use the Gradle JavaExec task type: try to define a task in your build as follows:



    task runApp(type: JavaExec) {
    classpath = sourceSets.main.runtimeClasspath

    main = 'nicebank.AtmServer'

    }


    (not tested, you migth have to adapt it) , and run it with



    gradle runApp


    You could alternatively use Gretty plugin to run your webapp (no need to define your own JavaExec task in this case), as documented here and here:



    plugins{
    // your existing plugins
    id "org.gretty" version "2.2.0"
    }


    You can then run the application with:



    gradle appRun






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 13 '18 at 14:49

























    answered Nov 13 '18 at 14:01









    M.RicciutiM.Ricciuti

    2,9612418




    2,9612418













    • Thank you very much! It works fine now :)

      – Deviasa
      Nov 13 '18 at 15:17



















    • Thank you very much! It works fine now :)

      – Deviasa
      Nov 13 '18 at 15:17

















    Thank you very much! It works fine now :)

    – Deviasa
    Nov 13 '18 at 15:17





    Thank you very much! It works fine now :)

    – Deviasa
    Nov 13 '18 at 15:17













    1














    Your dependency looks good. Just one note: consider using implementation over compile as it improves the performance. Read about compile deprecation here.



    You can also put your properties in gradle.properties file and reference them in the build script:



    gradle.properties:



    jettyVersion=9.4.12.v20180830


    build.gradle:



    implementation group: 'org.eclipse.jetty', name: 'jetty-webapp', version: jettyVersion


    Jetty team also published BOMs: — org.eclipse.jetty:jetty-bom:9.4.12.v20180830 in your case. If you use multiple projects of the same version you can import the BOM and skip the version completely:



    dependencies {
    implementation 'org.eclipse.jetty:jetty-bom:9.4.12.v20180830'
    implementation 'org.eclipse.jetty:jetty-webapp'
    implementation 'org.eclipse.jetty:jetty-runner'
    }


    As for the "exec" task: if you have only one main class in your project, like nicebank.AtmServer, consider using Gradle's Application Plugin:



    plugins {
    id 'application'
    }

    mainClassName = 'nicebank.AtmServer'


    This way you don't need to create "exec" task manually, you'll get one (run) from the plugin. As a bonus you'll get two "distribution" tasks that will create a ready-for-distribution archive with your app: distZip and distTar.






    share|improve this answer






























      1














      Your dependency looks good. Just one note: consider using implementation over compile as it improves the performance. Read about compile deprecation here.



      You can also put your properties in gradle.properties file and reference them in the build script:



      gradle.properties:



      jettyVersion=9.4.12.v20180830


      build.gradle:



      implementation group: 'org.eclipse.jetty', name: 'jetty-webapp', version: jettyVersion


      Jetty team also published BOMs: — org.eclipse.jetty:jetty-bom:9.4.12.v20180830 in your case. If you use multiple projects of the same version you can import the BOM and skip the version completely:



      dependencies {
      implementation 'org.eclipse.jetty:jetty-bom:9.4.12.v20180830'
      implementation 'org.eclipse.jetty:jetty-webapp'
      implementation 'org.eclipse.jetty:jetty-runner'
      }


      As for the "exec" task: if you have only one main class in your project, like nicebank.AtmServer, consider using Gradle's Application Plugin:



      plugins {
      id 'application'
      }

      mainClassName = 'nicebank.AtmServer'


      This way you don't need to create "exec" task manually, you'll get one (run) from the plugin. As a bonus you'll get two "distribution" tasks that will create a ready-for-distribution archive with your app: distZip and distTar.






      share|improve this answer




























        1












        1








        1







        Your dependency looks good. Just one note: consider using implementation over compile as it improves the performance. Read about compile deprecation here.



        You can also put your properties in gradle.properties file and reference them in the build script:



        gradle.properties:



        jettyVersion=9.4.12.v20180830


        build.gradle:



        implementation group: 'org.eclipse.jetty', name: 'jetty-webapp', version: jettyVersion


        Jetty team also published BOMs: — org.eclipse.jetty:jetty-bom:9.4.12.v20180830 in your case. If you use multiple projects of the same version you can import the BOM and skip the version completely:



        dependencies {
        implementation 'org.eclipse.jetty:jetty-bom:9.4.12.v20180830'
        implementation 'org.eclipse.jetty:jetty-webapp'
        implementation 'org.eclipse.jetty:jetty-runner'
        }


        As for the "exec" task: if you have only one main class in your project, like nicebank.AtmServer, consider using Gradle's Application Plugin:



        plugins {
        id 'application'
        }

        mainClassName = 'nicebank.AtmServer'


        This way you don't need to create "exec" task manually, you'll get one (run) from the plugin. As a bonus you'll get two "distribution" tasks that will create a ready-for-distribution archive with your app: distZip and distTar.






        share|improve this answer















        Your dependency looks good. Just one note: consider using implementation over compile as it improves the performance. Read about compile deprecation here.



        You can also put your properties in gradle.properties file and reference them in the build script:



        gradle.properties:



        jettyVersion=9.4.12.v20180830


        build.gradle:



        implementation group: 'org.eclipse.jetty', name: 'jetty-webapp', version: jettyVersion


        Jetty team also published BOMs: — org.eclipse.jetty:jetty-bom:9.4.12.v20180830 in your case. If you use multiple projects of the same version you can import the BOM and skip the version completely:



        dependencies {
        implementation 'org.eclipse.jetty:jetty-bom:9.4.12.v20180830'
        implementation 'org.eclipse.jetty:jetty-webapp'
        implementation 'org.eclipse.jetty:jetty-runner'
        }


        As for the "exec" task: if you have only one main class in your project, like nicebank.AtmServer, consider using Gradle's Application Plugin:



        plugins {
        id 'application'
        }

        mainClassName = 'nicebank.AtmServer'


        This way you don't need to create "exec" task manually, you'll get one (run) from the plugin. As a bonus you'll get two "distribution" tasks that will create a ready-for-distribution archive with your app: distZip and distTar.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 13 '18 at 14:44

























        answered Nov 13 '18 at 14:32









        madheadmadhead

        14.3k1383123




        14.3k1383123






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53282313%2fmigrate-maven-dependencies-to-gradle%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Xamarin.iOS Cant Deploy on Iphone

            Glorious Revolution

            Dulmage-Mendelsohn matrix decomposition in Python