Skip to content

Commit f5bebbb

Browse files
author
Vinay Shankar Shukla
authored
Use arguments file to avoid long classpaths. #402 (#413)
* Use argumetns file to avoid long classpaths. #402 Signed-off-by: BugDiver <[email protected]> * Running tests with java 12 Signed-off-by: BugDiver <[email protected]>
1 parent 0c18de2 commit f5bebbb

File tree

3 files changed

+55
-62
lines changed

3 files changed

+55
-62
lines changed

.github/workflows/tests.yml

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -44,30 +44,11 @@ jobs:
4444
- name: Setup java
4545
uses: actions/setup-java@v1
4646
with:
47-
java-version: '1.8'
47+
java-version: '12.x.x'
4848

49-
- name: Setup go 1.13.1
50-
uses: actions/setup-go@v1
49+
- uses: bugdiver/setup-gauge@master
5150
with:
52-
go-version: 1.13.1
53-
54-
- name: Install gauge on linux
55-
if: matrix.os != 'windows-latest'
56-
run: |
57-
git clone --depth=1 https://github.com/getgauge/gauge
58-
cd gauge
59-
go run build/make.go --verbose
60-
go run build/make.go --install --prefix=/tmp/
61-
echo "::add-path::/tmp/bin"
62-
63-
- name: Install gauge (windows)
64-
if: matrix.os == 'windows-latest'
65-
run: |
66-
git clone --depth=1 https://github.com/getgauge/gauge
67-
cd gauge
68-
go run build/make.go --verbose
69-
go run build/make.go --install
70-
echo "::add-path::C:\Program Files\gauge\bin"
51+
gauge-version: master
7152

7253
- name: Install html report
7354
run: |
@@ -80,6 +61,7 @@ jobs:
8061
if: matrix.os != 'windows-latest'
8162
run: |
8263
./build.sh forceinstall
64+
shell: bash
8365

8466
- name: Install Gauge Java plugin from source
8567
if: matrix.os == 'windows-latest'
@@ -94,18 +76,11 @@ jobs:
9476
run: |
9577
git clone --depth=1 https://github.com/getgauge/gauge-tests
9678
97-
- name: Run FTs on linux
98-
if: matrix.os != 'windows-latest'
79+
- name: Run FTs
9980
run: |
10081
cd gauge-tests
10182
./gradlew clean javaFT
102-
103-
- name: Run FTs on windows
104-
if: matrix.os == 'windows-latest'
105-
shell: pwsh
106-
run: |
107-
cd gauge-tests
108-
.\gradlew.bat clean javaFT
83+
shell: bash
10984

11085
- uses: actions/upload-artifact@v1
11186
if: failure()
@@ -132,25 +107,11 @@ jobs:
132107
- name: Setup java
133108
uses: actions/setup-java@v1
134109
with:
135-
java-version: '1.8'
136-
137-
- name: Install gauge on linux
138-
if: matrix.os != 'windows-latest'
139-
run: |
140-
git clone https://github.com/getgauge/gauge
141-
cd gauge
142-
go run build/make.go --verbose
143-
go run build/make.go --install --prefix=/tmp/
144-
echo "::add-path::/tmp/bin"
110+
java-version: '12.x.x'
145111

146-
- name: Install gauge (windows)
147-
if: matrix.os == 'windows-latest'
148-
run: |
149-
git clone https://github.com/getgauge/gauge
150-
cd gauge
151-
go run build/make.go --verbose
152-
go run build/make.go --install
153-
echo "::add-path::C:\Program Files\gauge\bin"
112+
- uses: bugdiver/setup-gauge@master
113+
with:
114+
gauge-version: master
154115

155116
- name: Install Gauge Java plugin from source
156117
if: matrix.os != 'windows-latest'

bin/launcher.ps1

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,34 @@ Param(
22
[String]$TaskName # The name of the task to run
33
)
44

5-
$DefaultBuildDir = "gauge_bin"
6-
$PluginDir = Get-Location
7-
$global:classpath = $env:gauge_custom_classpath
8-
Set-Location $env:GAUGE_PROJECT_ROOT
9-
105
$javaCommand = "java"
116
$javacCommand = "javac"
127

138
if ("$env:gauge_java_home" -ne "") {
14-
$javaCommand = "$env:gauge_java_home\bin\$javaCommand"
15-
$javacCommand = "$env:gauge_java_home\bin\$javacCommand"
9+
$javaCommand = "$env:gauge_java_home\bin\$javaCommand"
10+
$javacCommand = "$env:gauge_java_home\bin\$javacCommand"
1611
}
1712
elseif ("$env:JAVA_HOME" -ne "") {
18-
$javaCommand = "$env:JAVA_HOME\bin\$javaCommand"
19-
$javacCommand = "$env:JAVA_HOME\bin\$javacCommand"
13+
$javaCommand = "$env:JAVA_HOME\bin\$javaCommand"
14+
$javacCommand = "$env:JAVA_HOME\bin\$javacCommand"
2015
}
2116

17+
$verison = (Get-Command $javaCommand | Select-Object -ExpandProperty Version).Major | Out-String
18+
if ( "$verison" -as [int] -lt 9 ) {
19+
Write-Output "This version of the plugin does not support java version < 1.9";
20+
Write-Output "Please upgrade your java version or stick to an older version of gauge-java."
21+
exit 1;
22+
}
23+
24+
25+
$DefaultBuildDir = "gauge_bin"
26+
$PluginDir = Get-Location
27+
$global:classpath = $env:gauge_custom_classpath
28+
Set-Location $env:GAUGE_PROJECT_ROOT
29+
30+
2231
function AddRunnerInClassPath {
23-
$global:classpath = $global:classpath + "$PluginDir\*" + ";" + "$PluginDir\libs\*"
32+
$global:classpath += "$PluginDir\libs\*"
2433
}
2534

2635
function GetAdditionalPath() {
@@ -87,6 +96,17 @@ function AddClassPathRequiredForExecution() {
8796
}
8897
}
8998

99+
function EscapeSpaceInClasspath {
100+
$classpath = $global:classpath.Split(";")
101+
$global:classpath = ""
102+
foreach ($cp in $classpath.Split(";")) {
103+
if ($cp.Contains(" ") ) {
104+
$cp = "`"$cp`"" -replace '\\','\\'
105+
}
106+
$global:classpath+="$cp;"
107+
}
108+
}
109+
90110
$tasks = @{ }
91111
$tasks.Add('init', {
92112
if ("$global:classpath" -eq "" ) { AddRunnerInClassPath }
@@ -100,12 +120,15 @@ $tasks.Add('start', {
100120
AddRunnerInClassPath
101121
AddClassPathRequiredForExecution
102122
}
103-
$env:CLASSPATH = $global:classpath
104123
if ("$env:GAUGE_DEBUG_OPTS" -ne "" ) {
105124
$debugArgs = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=$env:GAUGE_DEBUG_OPTS,timeout=25000"
106125
Write-Output "`nRunner Ready for Debugging"
107126
}
108-
& $javaCommand `"-Dfile.encoding=UTF-8`" $debugArgs $env:gauge_jvm_args com.thoughtworks.gauge.GaugeRuntime --start
127+
EscapeSpaceInClasspath
128+
$random = (Get-Random)
129+
$targetFile = Join-Path "$env:TEMP" "$random.txt"
130+
Write-Output "-cp $global:classpath `"-Dfile.encoding=UTF-8`" $debugArgs $env:gauge_jvm_args com.thoughtworks.gauge.GaugeRuntime --start" | Out-File $targetFile -Append -Encoding default
131+
& $javaCommand "@$targetFile"
109132
exit
110133
})
111134

bin/launcher.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ elif [ ! -z "${JAVA_HOME}" ]; then
1919
javacCommand="${JAVA_HOME}/bin/${javacCommand}"
2020
fi
2121

22+
version=$("$javaCommand" -version 2>&1 | awk -F '"' '/version/ {print $2}')
23+
if [[ "$version" < "1.9" ]]; then
24+
echo -e "This version of gauge-java plugin does not support Java versions < 1.9";
25+
echo -e "Please upgrade your Java version or use a version of gauge-java <= v0.7.4"
26+
exit 1;
27+
fi
28+
2229
cd "$project_root"
2330

2431
function get_abs() {
@@ -118,7 +125,9 @@ function start() {
118125
args="${args} -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=${GAUGE_DEBUG_OPTS},timeout=25000"
119126
echo -e "\nRunner Ready for Debugging"
120127
fi
121-
CLASSPATH="${class_path}" $javaCommand ${args} com.thoughtworks.gauge.GaugeRuntime --start
128+
target_file="$TMPDIR$RANDOM-$RANDOM.txt"
129+
echo "-cp \"${class_path}\" ${args} com.thoughtworks.gauge.GaugeRuntime --start" >$target_file
130+
$javaCommand @$target_file
122131
}
123132

124133
function init() {

0 commit comments

Comments
 (0)