How to create a Gradle java project in IntelliJ IDEA

IntelliJ IDEA: is a Java integrated development environment (IDE) for developing computer software. It is developed by JetBrains (formerly known as IntelliJ), and is available as an Apache 2 Licensed community edition and in a proprietary commercial edition. Both can be used for commercial development
Prerequisite Software:
1. Jdk download and install

2. IntelliJ IDEA download and install
3. Gradle distribution download and extract desired location
Create a Gradle Java project in IntelliJ IDEA:
1. Open IntelliJ IDEA, install or enable Gradle Plugins from here File --> Settings --> Plugins  and restart

2.  File --> New --> Project
       a. Select 'Gradle' from left sidebar, Set jdk path, Select Java and Click 'Next' button

          b. Enter GroupId and ArtifactId, then Click 'Next' button

             c. Select 'Create directories for empty content roots automatically', 'Create separate module per source set' and 'Use local gradle distribution' then set gradle distribution path as 'gradle home' input and Click 'Next' button

           d. Type Project name and set desired Project location which want to save project, finally Click 'Finish' button
         e. Gradle project created
3. Add gradle dependencies
     a.  Click View --> Tools WIndows --> Gradle
     b. Click on 'build.gradle' file from left sidebar (1) 
     c. Add desired dependency under (2)

  dependencies {  
    testCompile group: 'junit', name: 'junit', version: '4.12'  
   // https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java  
   compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.0.1'  
 // https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver  
   compile group: 'org.seleniumhq.selenium', name: 'selenium-chrome-driver', version: '3.0.1'  
   // https://mvnrepository.com/artifact/info.cukes/cucumber-junit  
   compile group: 'info.cukes', name: 'cucumber-junit', version: '1.2.5'  
   // https://mvnrepository.com/artifact/info.cukes/cucumber-java  
   compile group: 'info.cukes', name: 'cucumber-java', version: '1.2.5'  
 // https://mvnrepository.com/artifact/info.cukes/cucumber-core  
   compile group: 'info.cukes', name: 'cucumber-core', version: '1.2.5'  
 )  
        added upper dependencies for Cucumber and Selenium Webdriver 
Note:
Two https://mvnrepository.com/ and http://search.maven.org/ site where you will desired dependency 
     d. Click refresh button (3)  to import jar files and Synchronizing Changes in Gradle Project

4. Add java package or class 
   a. add main project code : src --> main --> java
  b. add code testing main project : src --> test --> java

No comments:

Post a Comment