How can I get my gradle test task to use python pip install for library that isn't on maven central?
<p>I am trying to set up a gradle task that will run Robot tests. Robot uses a python library to interact with Selenium in order to test a web page through a browser. But unfortunately it seems the only way to install the <a href="https://github.com/robotframework/Selenium2Library" rel="nofollow">https://github.com/robotframework/Selenium2Library</a> is via pip - <code>pip install robotframework-selenium2library</code>. Is there a way to get Gradle to run this command in my task?</p>

<p>Here's what I have:</p>

<p>build.gradle:</p>

<pre><code>configurations {
    //...
    acceptanceTestRuntime {extendsFrom testCompile, runtime}
}
dependencies {
    //...
    acceptanceTestRuntime group: 'org.robotframework', name: 'robotframework', version: '2.8.7'
    //The following doesn't work, apparently this library isn't on maven...
    //acceptanceTestRuntime group: 'org.robotframework', name: 'Selenium2Library', version: '1.+'
}
sourceSets {
    //...
    acceptanceTest {
        runtimeClasspath = sourceSets.test.output + configurations.acceptanceTestRuntime
    }
}
task acceptanceTest(type: JavaExec) {
    classpath = sourceSets.acceptanceTest.runtimeClasspath
    main = 'org.robotframework.RobotFramework'
    args '--variable', 'BROWSER:gc'
    args '--outputdir', 'target'
    args 'src/testAcceptance'
}
</code></pre>

<p>My robot resources file - login.resource.robot:</p>

<pre><code>*** Settings ***
Documentation   A resource file for my example login page test.
Library         Selenium2Library

*** Variables ***
${SERVER}           localhost:8080
(etc.)

*** Keywords ***
Open Browser to Login Page
    Open Browser    ${LOGIN_URL}    ${BROWSER}
    Maximize Browser Window
    Set Selenium Speed  ${DELAY}
    Login Page Should Be Open

Login Page Should Be Open
    Location Should Be     ${LOGIN_URL}
</code></pre>

<p>And when I run this task, my robot tests are run, BUT they fail. Because certain keywords that are defined in the robotframework-selenium2Library aren't recognized, such as "Open Browser", and an exception is thrown. </p>

<p>How can I get gradle to import this selenium library for this task? Can I install and call pip via some python plugin?</p>

<p>I had to use a gradle Exec task to run a python script that then kicked off the robot tests. So it looked like this:</p>

<p>build.gradle</p>

<pre><code>task acceptanceTest(type: Exec) {
    workingDir 'src/testAcceptance'
    commandLine 'python', 'run.py'
}
</code></pre>

<p>src/testAcceptance/run.py</p>

<pre><code>import os
import robot
import setup 
#Which runs setup.py

os.environ['ROBOT_OPTIONS'] = '--variable BROWSER.gc --outputdir results'
robot.run('.')
</code></pre>

<p>src/testAcceptance/setup.py</p>

<pre><code>import os
import sys
import pip
import re

pip.main(['install', 'robotframework==3.0'])
pip.main(['install', 'robotframework-selenium2library==1.8.0'])
# Checksums can be looked up by chromedriver version here - http://chromedriver.storage.googleapis.com/index.html
pip.main(['install', '--upgrade', 'chromedriver_installer',
    '--install-option=--chromedriver-version=2.24',
    '--install-option=--chromedriver-checksums=1a46c83926f891d502427df10b4646b9,d117b66fac514344eaf80691ae9a4687,' +
    'c56e41bdc769ad2c31225b8495fc1a93,8e6b6d358f1b919a0d1369f90d61e1a4'])

#Add the Scripts dir to the path, since that's where the chromedriver is installed
scriptsDir = re.sub('[A-Za-z0-9\\.]+$', '', sys.executable) + 'Scripts'
os.environ['PATH'] += os.pathsep + scriptsDir
</code></pre>

python selenium gradle robotframework selenium2library