Skip to content

Commit 6e9067b

Browse files
beepsoftpoikilothermstevenwinship
authored
Fix cpwebapp.sh on macOS (#11935)
macOS doesn't support -P for grep, use awk instead. Co-authored-by: Oliver Bertuch <[email protected]> Co-authored-by: Steven Winship <[email protected]>
1 parent ad031a9 commit 6e9067b

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

docker/util/intellij/cpwebapp.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,26 @@ PROJECT_DIR="$1"
99
FILE_TO_COPY="$2"
1010
RELATIVE_PATH="${FILE_TO_COPY#"${PROJECT_DIR}/"}"
1111

12-
# Check if RELATIVE_PATH starts with 'src/main/webapp', otherwise ignore
12+
# Only act on files under src/main/webapp
1313
if [[ "$RELATIVE_PATH" == "src/main/webapp"* ]]; then
14-
# Extract version from POM, so we don't need to have Maven on the PATH
15-
VERSION=$(grep -oPm1 "(?<=<revision>)[^<]+" "$PROJECT_DIR/modules/dataverse-parent/pom.xml")
14+
POM="$PROJECT_DIR/modules/dataverse-parent/pom.xml"
1615

17-
# Construct the target path by cutting off the local prefix and prepend with in-container path
18-
RELATIVE_PATH_WITHOUT_WEBAPP="${RELATIVE_PATH#src/main/webapp/}"
19-
TARGET_PATH="/opt/payara/appserver/glassfish/domains/domain1/applications/dataverse-$VERSION/${RELATIVE_PATH_WITHOUT_WEBAPP}"
16+
# Extract <revision> in a portable way
17+
VERSION="$(awk -F'[<>]' '/<revision>/{print $3; exit}' "$POM")"
2018

21-
# Copy file to container
22-
docker cp "$FILE_TO_COPY" "dev_dataverse:$TARGET_PATH"
19+
if [[ -z "${VERSION:-}" ]]; then
20+
echo "Error: Could not extract <revision> from $POM" >&2
21+
exit 1
22+
fi
23+
24+
CONTAINER="dev_dataverse"
25+
26+
# Build target path
27+
RELATIVE_PATH_WITHOUT_WEBAPP="${RELATIVE_PATH#src/main/webapp/}"
28+
TARGET_PATH="/opt/payara/appserver/glassfish/domains/domain1/applications/dataverse-$VERSION/${RELATIVE_PATH_WITHOUT_WEBAPP}"
29+
30+
# Copy file into container
31+
docker cp "$FILE_TO_COPY" "$CONTAINER:$TARGET_PATH"
32+
33+
echo "Copied $FILE_TO_COPY$CONTAINER:$TARGET_PATH"
2334
fi

0 commit comments

Comments
 (0)