Skip to content

Commit

Permalink
launcher gets classpath from maven/gradle, #236 (#419)
Browse files Browse the repository at this point in the history
* launcher gets classpath from maven/gradle, #236

Signed-off-by: sriv <srikanth.ddit@gmail.com>

* fix launcher.sh pom path

Signed-off-by: sriv <srikanth.ddit@gmail.com>

* fix launcher script

Signed-off-by: sriv <srikanth.ddit@gmail.com>

* Updated launcher.sh to use Gauge's maven and gradle plugin to get classpath.

Signed-off-by: Dharmendra Singh <dharmenn@thoughtworks.com>

* Updated launcher.ps1 to use Gauge's maven and gradle plugin to get classpath.

Signed-off-by: Dharmendra Singh <dharmenn@thoughtworks.com>

Co-authored-by: Dharmendra Singh <dharmenn@thoughtworks.com>
  • Loading branch information
sriv and negiDharmendra authored Apr 20, 2020
1 parent 58e7cfd commit b889d24
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
14 changes: 11 additions & 3 deletions bin/launcher.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ elseif ("$env:JAVA_HOME" -ne "") {
$javacCommand = "$env:JAVA_HOME\bin\$javacCommand"
}

$verison = (Get-Command $javaCommand | Select-Object -ExpandProperty Version).Major | Out-String
if ( "$verison" -as [int] -lt 9 ) {
$version = (Get-Command $javaCommand | Select-Object -ExpandProperty Version).Major | Out-String
if ( "$version" -as [int] -lt 9 ) {
Write-Output "This version of gauge-java plugin does not support Java versions < 1.9"
Write-Output "Please upgrade your Java version or use a version of gauge-java <= v0.7.4"
exit 1;
Expand All @@ -24,9 +24,17 @@ if ( "$verison" -as [int] -lt 9 ) {

$DefaultBuildDir = "gauge_bin"
$PluginDir = Get-Location
$global:classpath = $env:gauge_custom_classpath
Set-Location $env:GAUGE_PROJECT_ROOT

if (-not (Test-Path env:gauge_custom_classpath)) {
if (Test-Path "pom.xml" -PathType Leaf) {
$global:classpath = (mvn -q test-compile gauge:classpath)
} elseif (Test-Path "build.gradle" -PathType Leaf) {
$global:classpath = (./gradlew -q clean classpath)
}
} else {
$global:classpath = $env:gauge_custom_classpath
}

function AddRunnerInClassPath {
$global:classpath += "$PluginDir\libs\*"
Expand Down
18 changes: 15 additions & 3 deletions bin/launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

set -e

project_root="$GAUGE_PROJECT_ROOT"
default_build_dir="gauge_bin"
class_path="$gauge_custom_classpath"
plugin_dir=$(pwd)
project_root="$GAUGE_PROJECT_ROOT"
compile_dir="$gauge_custom_compile_dir"
TMP_DIR="$(dirname $(mktemp -u))/"

Expand Down Expand Up @@ -35,6 +34,19 @@ fi

cd "$project_root"

if [ -z "${gauge_custom_classpath}" ]; then
GAUGE_MAVEN_POM_FILE="${GAUGE_MAVEN_POM_FILE:-pom.xml}"
GAUGE_GRADLE_BUILD_FILE="${GAUGE_GRADLE_BUILD_FILE:-build.gradle}"
if test -f $GAUGE_MAVEN_POM_FILE; then
class_path=$(mvn -q test-compile gauge:classpath)
fi
if test -f $GAUGE_GRADLE_BUILD_FILE; then
class_path=$(./gradlew -q clean classpath)
fi
else
class_path="$gauge_custom_classpath";
fi

function get_abs() {
if [[ "$1" == /* ]]; then
echo "$1"
Expand Down Expand Up @@ -144,7 +156,7 @@ function init() {
}

tasks=(init start)
if [[ " ${tasks[@]} " =~ " $1 " ]]; then
if [[ " ${tasks[*]} " =~ $1 ]]; then
$1
exit 0
fi
Expand Down

0 comments on commit b889d24

Please sign in to comment.