Skip to content

Commit

Permalink
new update of dtcw
Browse files Browse the repository at this point in the history
  • Loading branch information
github-action committed Dec 20, 2023
1 parent 8167b96 commit ae33ae7
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 34 deletions.
5 changes: 3 additions & 2 deletions dtcw
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set -o pipefail

# See https://github.com/docToolchain/docToolchain/releases for available versions.
# Set DTC_VERSION to "latest" to get the latest, yet unreleased version.
: "${DTC_VERSION:=3.1.2}"
: "${DTC_VERSION:=3.2.0}"

# The 'generateSite' and 'copyThemes' tasks support DTC_SITETHEME, an URL of a theme.
# export DTC_SITETHEME=https://....zip
Expand Down Expand Up @@ -594,8 +594,9 @@ build_command() {
local container_name=doctoolchain-${version}
container_name+="-$(date '+%Y%m%d_%H%M%S')"
pwd=$(has cygpath && cygpath -w "${PWD}" || echo "${PWD}")

docker_args="run --rm -i --platform linux/amd64 -u $(id -u):$(id -g) --name ${container_name} \
-e DTC_HEADLESS=true -e DTC_SITETHEME -e DTC_PROJECT_BRANCH=${DTC_PROJECT_BRANCH} -p 8042:8042 \
-e DTC_HEADLESS=true -e DTC_SITETHEME -e DTC_PROJECT_BRANCH=${DTC_PROJECT_BRANCH} \
--entrypoint /bin/bash -v '${pwd}:/project' doctoolchain/doctoolchain:v${version}"

cmd="docker ${docker_args} -c \"doctoolchain . ${*} ${DTC_OPTS} && exit\""
Expand Down
45 changes: 29 additions & 16 deletions dtcw.bat
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ErrorActionPreference = "Stop"

# See https://github.com/docToolchain/docToolchain/releases for available versions.
# Set DTC_VERSION to "latest" to get the latest, yet unreleased version.
$DTC_VERSION = "3.1.2"
$DTC_VERSION = "3.2.0"
if ($env:DTC_VERSION) { $DTC_VERSION = $env:DTC_VERSION }

#here you can specify the URL of a theme to use with generateSite-task
Expand Down Expand Up @@ -399,26 +399,38 @@ function download_file($url, $file) {

function assert_java_version_supported() {
# Defines the order in which Java is searched.
$JAVA_CMD = ""
if (Get-Command java -ErrorAction SilentlyContinue) {
$JAVA_CMD = "java"
}
if ( $null -ne $env:JAVA_HOME -and $env:JAVA_HOME -ne "") {
$JAVA_CMD = "$env:JAVA_HOME/bin/java"
Write-Warning "here '$env:JAVA_HOME'"
}
if (Test-Path "$DTC_JAVA_HOME") {
Write-Host "local java JDK-17 found"
$javaHome = "$DTC_JAVA_HOME/jdk-17.0.7+7"
$JAVA_CMD = "$javaHome/bin/java"
$JAVA_CMD = $null

if ( Test-Path "$DTC_JAVA_HOME") {
Write-Host "Check Java from $javaHome"
# Get the list of directories that start with 'jdk-'
$javaDirs = Get-ChildItem -Path $DTC_JAVA_HOME -Directory | Where-Object { $_.Name -like "jdk-*" }
# Select the first directory from the list
$selectedJavaDir = $javaDirs | Select-Object -First 1
# Construct the complete Java path
$javaHome = Join-Path -Path $DTC_JAVA_HOME -ChildPath $selectedJavaDir.Name

$JAVA_CMD = Get-Command "$javaHome\bin\java" -ErrorAction SilentlyContinue
$dtc_opts = "$dtc_opts '-Dorg.gradle.java.home=$javaHome' "
}
if ($JAVA_CMD -eq "") {

if ( $null -eq $JAVA_CMD) {
Write-Host "Check Java from Path"
$JAVA_CMD = Get-Command java -ErrorAction SilentlyContinue
}

if ( $null -eq $JAVA_CMD -and $null -ne $env:JAVA_HOME -and $env:JAVA_HOME -ne "") {
Write-Host "Check Java from $env:JAVA_HOME"
$JAVA_CMD = Get-Command "$env:JAVA_HOME\bin\java" -ErrorAction SilentlyContinue
}

if ($null -eq $JAVA_CMD) {
Write-Warning "unable to locate a Java Runtime"
java_help_and_die
}

# We got a Java version
$javaversion = ((Invoke-Expression -Command "$JAVA_CMD -version 2>&1" | Select-String -Pattern 'version').Line | Select-Object -First 1 ).Split('"')[1].Split(".")[0]
$javaversion = ($JAVA_CMD | Select-Object -ExpandProperty Version).Major

Write-Output "Java Version $javaversion"

Expand Down Expand Up @@ -553,9 +565,10 @@ function build_command($environment, $version, $_args) {
}
$container_name="doctoolchain-${version}-$(date -uFormat '+%Y%m%d_%H%M%S')"
$docker_cmd = Get-Command docker

# TODO: DTC_PROJECT_BRANCH is not passed into the docker environment
# See https://github.com/docToolchain/docToolchain/issues/1087
$docker_args = "run --rm -i --name ${container_name} -e DTC_HEADLESS=1 -e DTC_SITETHEME -e DTC_PROJECT_BRANCH=${DTC_PROJECT_BRANCH} -p 8042:8042 --entrypoint /bin/bash -v '${PWD}:/project' doctoolchain/doctoolchain:v${version}"
$docker_args = "run --rm -i --name ${container_name} -e DTC_HEADLESS=1 -e DTC_SITETHEME -e DTC_PROJECT_BRANCH=${DTC_PROJECT_BRANCH} --entrypoint /bin/bash -v '${PWD}:/project' doctoolchain/doctoolchain:v${version}"
$cmd = "$docker_cmd ${docker_args} -c ""doctoolchain . $_args ${DTC_OPTS} && exit "" "

} else {
Expand Down
45 changes: 29 additions & 16 deletions dtcw.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $ErrorActionPreference = "Stop"

# See https://github.com/docToolchain/docToolchain/releases for available versions.
# Set DTC_VERSION to "latest" to get the latest, yet unreleased version.
$DTC_VERSION = "3.1.2"
$DTC_VERSION = "3.2.0"
if ($env:DTC_VERSION) { $DTC_VERSION = $env:DTC_VERSION }

#here you can specify the URL of a theme to use with generateSite-task
Expand Down Expand Up @@ -390,26 +390,38 @@ function download_file($url, $file) {

function assert_java_version_supported() {
# Defines the order in which Java is searched.
$JAVA_CMD = ""
if (Get-Command java -ErrorAction SilentlyContinue) {
$JAVA_CMD = "java"
}
if ( $null -ne $env:JAVA_HOME -and $env:JAVA_HOME -ne "") {
$JAVA_CMD = "$env:JAVA_HOME/bin/java"
Write-Warning "here '$env:JAVA_HOME'"
}
if (Test-Path "$DTC_JAVA_HOME") {
Write-Host "local java JDK-17 found"
$javaHome = "$DTC_JAVA_HOME/jdk-17.0.7+7"
$JAVA_CMD = "$javaHome/bin/java"
$JAVA_CMD = $null

if ( Test-Path "$DTC_JAVA_HOME") {
Write-Host "Check Java from $javaHome"
# Get the list of directories that start with 'jdk-'
$javaDirs = Get-ChildItem -Path $DTC_JAVA_HOME -Directory | Where-Object { $_.Name -like "jdk-*" }
# Select the first directory from the list
$selectedJavaDir = $javaDirs | Select-Object -First 1
# Construct the complete Java path
$javaHome = Join-Path -Path $DTC_JAVA_HOME -ChildPath $selectedJavaDir.Name

$JAVA_CMD = Get-Command "$javaHome\bin\java" -ErrorAction SilentlyContinue
$dtc_opts = "$dtc_opts '-Dorg.gradle.java.home=$javaHome' "
}
if ($JAVA_CMD -eq "") {

if ( $null -eq $JAVA_CMD) {
Write-Host "Check Java from Path"
$JAVA_CMD = Get-Command java -ErrorAction SilentlyContinue
}

if ( $null -eq $JAVA_CMD -and $null -ne $env:JAVA_HOME -and $env:JAVA_HOME -ne "") {
Write-Host "Check Java from $env:JAVA_HOME"
$JAVA_CMD = Get-Command "$env:JAVA_HOME\bin\java" -ErrorAction SilentlyContinue
}

if ($null -eq $JAVA_CMD) {
Write-Warning "unable to locate a Java Runtime"
java_help_and_die
}

# We got a Java version
$javaversion = ((Invoke-Expression -Command "$JAVA_CMD -version 2>&1" | Select-String -Pattern 'version').Line | Select-Object -First 1 ).Split('"')[1].Split(".")[0]
$javaversion = ($JAVA_CMD | Select-Object -ExpandProperty Version).Major

Write-Output "Java Version $javaversion"

Expand Down Expand Up @@ -544,9 +556,10 @@ function build_command($environment, $version, $_args) {
}
$container_name="doctoolchain-${version}-$(date -uFormat '+%Y%m%d_%H%M%S')"
$docker_cmd = Get-Command docker

# TODO: DTC_PROJECT_BRANCH is not passed into the docker environment
# See https://github.com/docToolchain/docToolchain/issues/1087
$docker_args = "run --rm -i --name ${container_name} -e DTC_HEADLESS=1 -e DTC_SITETHEME -e DTC_PROJECT_BRANCH=${DTC_PROJECT_BRANCH} -p 8042:8042 --entrypoint /bin/bash -v '${PWD}:/project' doctoolchain/doctoolchain:v${version}"
$docker_args = "run --rm -i --name ${container_name} -e DTC_HEADLESS=1 -e DTC_SITETHEME -e DTC_PROJECT_BRANCH=${DTC_PROJECT_BRANCH} --entrypoint /bin/bash -v '${PWD}:/project' doctoolchain/doctoolchain:v${version}"
$cmd = "$docker_cmd ${docker_args} -c ""doctoolchain . $_args ${DTC_OPTS} && exit "" "

} else {
Expand Down

0 comments on commit ae33ae7

Please sign in to comment.