-
Notifications
You must be signed in to change notification settings - Fork 25
/
harvest.ps1
49 lines (39 loc) · 1.95 KB
/
harvest.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Find the first parent directory containing the VERSION file
$AppHome=(Get-Item -Path $MyInvocation.MyCommand.Path).Directory
while ($null -ne $AppHome -and !(Test-Path "$AppHome/VERSION")) {
$AppHome=$AppHome.Parent
}
Set-Location $AppHome
# Check java version, make sure it is Java 17
$JAVA_VERSION = (java -version 2>&1 | Select-String "version" | Select-String "17\.")
if ($null -eq $JAVA_VERSION) {
Write-Output "WARNING: Java 17 is required to run this program"
}
$args1 = $args
if ($args1.Length -eq 0) {
Write-Output "Usage: .\harvest.ps1 <URL>"
Write-Output "For example: .\harvest.ps1 https://www.amazon.com/b?node=1292115011"
# create an array
$args1 = @("https://www.amazon.com/b?node=1292115011")
}
$FILES=(Get-ChildItem -Path "$AppHome/exotic-standalone/target/" -Filter "PulsarRPAPro.jar" -Recurse)
$FILE_COUNT = ($FILES | Measure-Object).Count
if ($FILE_COUNT -eq 0) {
&"$AppHome/mvnw" -DskipTests=true
}
# Get the first file in $FILES
$JAR = $FILES | Select-Object -First 1
$JAR = $JAR.FullName
$URL = $args1[0]
$args1 = $args1[1..($args1.Length - 1)]
$HARVEST_ARGS = "-diagnose -vj $($args1 -join ' ')"
# --add-opens java.base/java.time=ALL-UNNAMED to fix JEP 396: Strongly Encapsulate JDK Internals by Default,
# the problem appears when upgrading java from 11 to 17.
$JVM_OPTS = "--add-opens=java.base/java.time=ALL-UNNAMED"
# $JVM_OPTS = "--add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.management/javax.management=ALL-UNNAMED --add-opens=java.naming/javax.naming=ALL-UNNAMED"
Write-Output "java $JVM_OPTS -jar $JAR harvest $URL $HARVEST_ARGS"
try {
java $JVM_OPTS -jar "$JAR" harvest "$URL" $HARVEST_ARGS
} catch {
Write-Error "Failed to execute the Java application: $_"
}