Skip to content

Commit

Permalink
Merge pull request IQSS#10247 from dsd-sztaki-hu/intellij-webapp-hotr…
Browse files Browse the repository at this point in the history
…eload

Intellij IDEA webapp hotreload
  • Loading branch information
pdurbin committed Jan 25, 2024
2 parents 8d9bd2f + 743dbbc commit cea3e62
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ services:
volumes:
- ./docker-dev-volumes/app/data:/dv
- ./docker-dev-volumes/app/secrets:/secrets
# Uncomment to map the glassfish applications folder so that we can update webapp resources using scripts/intellij/cpwebapp.sh
# - ./docker-dev-volumes/glassfish/applications:/opt/payara/appserver/glassfish/domains/domain1/applications
# Uncomment for changes to xhtml to be deployed immediately (if supported your IDE or toolchain).
# Replace 6.0 with the current version.
# - ./target/dataverse-6.0:/opt/payara/deployments/dataverse
Expand Down
33 changes: 33 additions & 0 deletions scripts/intellij/cpwebapp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
#
# cpwebapp <project dir> <file in webapp>
#
# Usage:
#
# Add a File watcher by importing watchers.xml into IntelliJ IDEA, and let it do the copying whenever you save a
# file under webapp.
#
# https://www.jetbrains.com/help/idea/settings-tools-file-watchers.html
#
# Alternatively, you can add an External tool and trigger via menu or shortcut to do the copying manually:
#
# https://www.jetbrains.com/help/idea/configuring-third-party-tools.html
#

PROJECT_DIR=$1
FILE_TO_COPY=$2
RELATIVE_PATH="${FILE_TO_COPY#$PROJECT_DIR/}"

Check warning on line 19 in scripts/intellij/cpwebapp.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Expansions inside ${..} need to be quoted separately, otherwise they match as patterns. [SC2295](https://github.com/koalaman/shellcheck/wiki/SC2295) Raw Output: ./scripts/intellij/cpwebapp.sh:19:31:info:Expansions inside ${..} need to be quoted separately, otherwise they match as patterns. [SC2295](https://github.com/koalaman/shellcheck/wiki/SC2295)

# Check if RELATIVE_PATH starts with 'src/main/webapp', otherwise ignore
if [[ $RELATIVE_PATH == src/main/webapp* ]]; then
# Get current version. Any other way to do this? A simple VERSION file would help.
VERSION=`perl -ne 'print $1 if /<revision>(.*?)<\/revision>/' ./modules/dataverse-parent/pom.xml`

Check failure on line 24 in scripts/intellij/cpwebapp.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Use $(...) notation instead of legacy backticks `...`. [SC2006](https://github.com/koalaman/shellcheck/wiki/SC2006) Raw Output: ./scripts/intellij/cpwebapp.sh:24:13:style:Use $(...) notation instead of legacy backticks `...`. [SC2006](https://github.com/koalaman/shellcheck/wiki/SC2006)
RELATIVE_PATH_WITHOUT_WEBAPP="${RELATIVE_PATH#src/main/webapp/}"
TARGET_DIR=./docker-dev-volumes/glassfish/applications/dataverse-$VERSION
TARGET_PATH="${TARGET_DIR}/${RELATIVE_PATH_WITHOUT_WEBAPP}"

mkdir -p "$(dirname "$TARGET_PATH")"
cp "$FILE_TO_COPY" "$TARGET_PATH"

echo "File $FILE_TO_COPY copied to $TARGET_PATH"
fi
22 changes: 22 additions & 0 deletions scripts/intellij/watchers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<TaskOptions>
<TaskOptions>
<option name="arguments" value="$ProjectFileDir$ $FilePath$" />
<option name="checkSyntaxErrors" value="false" />
<option name="description" />
<option name="exitCodeBehavior" value="ERROR" />
<option name="fileExtension" value="*" />
<option name="immediateSync" value="false" />
<option name="name" value="Dataverse webapp file copy on save" />
<option name="output" value="" />
<option name="outputFilters">
<array />
</option>
<option name="outputFromStdout" value="false" />
<option name="program" value="$ProjectFileDir$/scripts/intellij/cpwebapp.sh" />
<option name="runOnExternalChanges" value="true" />
<option name="scopeName" value="Current File" />
<option name="trackOnlyRoot" value="false" />
<option name="workingDir" value="$ProjectFileDir$" />
<envs />
</TaskOptions>
</TaskOptions>

0 comments on commit cea3e62

Please sign in to comment.