Skip to content

Commit 680e606

Browse files
committed
Cleanup
1 parent 3b9787e commit 680e606

File tree

8 files changed

+49
-72
lines changed

8 files changed

+49
-72
lines changed
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22

3-
$JAVA_HOME/bin/java --list-modules > java-modules.txt
4-
< java-modules.txt sed "s/\\@.*//" > modules.txt
5-
grep -Fx -f stripped-deps.txt modules.txt | tr '\n' ',' | tr -d "[:space:]" > module-deps.txt
6-
echo "jdk.zipfs" >> module-deps.txt
3+
function generatejdkdeps() {
4+
$JAVA_HOME/bin/java --list-modules > java-modules.txt
5+
< java-modules.txt sed "s/\\@.*//" > modules.txt
6+
grep -Fx -f stripped-deps.txt modules.txt | tr '\n' ',' | tr -d "[:space:]" > module-deps.txt
7+
echo "jdk.zipfs" >> module-deps.txt
8+
}

modules/jlink/artifacts/opt/jboss/container/java/s2i/mkdeps.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,24 @@
22
set -euo pipefail
33
shopt -s globstar
44

5+
#TODO:
56
project="${project-spring-boot-sample-simple}"
67
jarfile="${jarfile-$project/target/spring-boot-sample-simple-1.5.0.BUILD-SNAPSHOT.jar}"
78
libdir="${libdir-$project/target/lib}"
89

9-
test -f "$jarfile"
10-
test -d "$libdir"
10+
function generate_deps() {
11+
#Test that file dependencies exist
12+
test -f "$jarfile"
13+
test -d "$libdir"
1114

12-
# Create a temporary directory for a module path
13-
# This works around "Module java.xml.bind not found, required by java.ws.rs"
14-
mkdir dependencies
15-
find $libdir -type f -name '*.jar' -print0 | xargs -r0 cp -vt dependencies
15+
# Create a temporary directory for a module path
16+
# This works around "Module java.xml.bind not found, required by java.ws.rs"
17+
mkdir dependencies
18+
find $libdir -type f -name '*.jar' -print0 | xargs -r0 cp -vt dependencies
1619

17-
$JAVA_HOME/bin/jdeps --multi-release 11 -R -s \
20+
$JAVA_HOME/bin/jdeps --multi-release $JAVA_VERSION -R -s \
1821
--module-path dependencies \
1922
"$jarfile" \
2023
"$libdir"/**/*.jar \
21-
> deps.txt
24+
> deps.txt
25+
}

modules/jlink/artifacts/opt/jboss/container/java/s2i/mkjreimage.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
# TODO: Still Needed?
23
set -euo pipefail
34

45
outdir="${outdir-spring-boot-jre}"
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
test -f deps.txt
5-
6-
<deps.txt \
7-
grep 'java\|jdk\.' | # mostly removes target/, but also jdk8internals
8-
sed -E "s/Warning: .*//" | #remove extraneous warnings
9-
sed -E "s/.*-> //" | # remove src of src -> dep
10-
sed -E "s/.*\.jar//" | # remove extraneous dependencies
11-
sed "s#/.*##" | # delete anything after a slash. in practice target/..
12-
sort | uniq |
13-
tee stripped-deps.txt
4+
function mkstrippeddeps() {
5+
test -f deps.txt
6+
<deps.txt \
7+
grep 'java\|jdk\.' | # mostly removes target/, but also jdk8internals
8+
sed -E "s/Warning: .*//" | #remove extraneous warnings
9+
sed -E "s/.*-> //" | # remove src of src -> dep
10+
sed -E "s/.*\.jar//" | # remove extraneous dependencies
11+
sed "s#/.*##" | # delete anything after a slash. in practice target/..
12+
sort | uniq |
13+
tee stripped-deps.txt
14+
}

modules/jlink/artifacts/opt/jboss/container/java/s2i/runall.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

modules/s2i/bash/artifacts/usr/local/s2i/assemble

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ source "${JBOSS_CONTAINER_MAVEN_S2I_MODULE}/maven-s2i"
88
# include our s2i_core_*() overrides/extensions
99
source "${JBOSS_CONTAINER_JAVA_S2I_MODULE}/s2i-core-hooks"
1010

11+
# include our jlink scripts
12+
source "${JBOSS_CONTAINER_JAVA_JLINK_MODULE}/mkdeps"
13+
source "${JBOSS_CONTAINER_JAVA_JLINK_MODULE}/mkjreimage"
14+
source "${JBOSS_CONTAINER_JAVA_JLINK_MODULE}/mkstrippeddeps"
15+
source "${JBOSS_CONTAINER_JAVA_JLINK_MODULE}/generatejdkdeps"
16+
source "${JBOSS_CONTAINER_JAVA_JLINK_MODULE}/runall"
17+
#TODO: Are all of these needed or can we just invoke runall?
18+
1119
# inject our overridden maven_s2i_*() functions
1220
source "${JBOSS_CONTAINER_JAVA_S2I_MODULE}/maven-s2i-overrides"
1321

@@ -18,48 +26,25 @@ maven_s2i_build
1826

1927
shopt -s globstar
2028
echo "Setting environment variables"
21-
jarfile="/deployments/*.jar"
22-
libdir="/deployments/lib"
23-
$JAVA_HOME/
29+
jarfile=$JAVA_APP_JAR
30+
libdir=$JAVA_LIB_DIR
2431

2532
echo "Checking that jarfile and libdir exist"
2633
test -f "$jarfile"
2734
test -d "$libdir"
2835

29-
# Create a temporary directory for a module path
30-
mkdir dependencies
31-
cp /deployments/lib/**/*.jar dependencies
32-
# Calculate dependencies
33-
$JAVA_HOME/bin/jdeps --module-path dependencies --ignore-missing-deps --multi-release 11 -R -s \
34-
"$jarfile" \
35-
"$libdir"/**/*.jar \
36-
> deps.txt
37-
# Clean up temporary directory
38-
rm -rf dependencies
36+
echo "Invoking mkdeps"
37+
generate_deps
3938

40-
# Strip down the dependencies to the ones we're looking for
41-
<deps.txt \
42-
grep 'java\|jdk\.' | # mostly removes target/, but also jdk8internals
43-
sed -E "s/Warning: .*//" | #remove extraneous warnings
44-
sed -E "s/.*-> //" | # remove src of src -> dep
45-
sed -E "s/.*\.jar//" | # remove extraneous dependencies
46-
sed "s#/.*##" | # delete anything after a slash. in practice target/..
47-
sort | uniq |
48-
tee stripped-deps.txt
39+
echo "Stripping dependencies"
40+
mkstrippeddeps
4941

50-
echo "Checking against jdk modules"
51-
$JAVA_HOME/bin/java --list-modules > java-modules.txt
52-
cat java-modules.txt | sed "s/\\@.*//" > modules.txt
53-
grep -Fx -f stripped-deps.txt modules.txt | tr '\n' ',' | tr -d "[:space:]" > module-deps.txt
54-
echo "jdk.zipfs" >> module-deps.txt
42+
echo "Generating JDK dependencies"
43+
generatejdkdeps
5544

5645
echo "Linking jre"
5746
$JAVA_HOME/bin/jlink --output runtime-jre \
5847
--add-modules $(cat module-deps.txt) \
5948
-G --no-header-files --no-man-pages
6049

61-
rm *.txt
62-
echo "Repacking jre"
63-
INSTALL_BASE="/lib/jvm/java-11-openjdk"
64-
JDK_IMAGE="runtime-jre"
65-
echo -n "Replacing shared libraries from JDK image '$JDK_IMAGE' with shared libraries from '$INSTALL_BASE'... "
50+
rm *.txt

modules/s2i/core/artifacts/opt/jboss/container/s2i/core/s2i-core

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function s2i_core_env_init() {
3333
S2I_IMAGE_SOURCE_MOUNTS="${S2I_IMAGE_SOURCE_MOUNTS:-${CUSTOM_INSTALL_DIRECTORIES}}"
3434
S2I_ENABLE_INCREMENTAL_BUILDS="${S2I_ENABLE_INCREMENTAL_BUILDS:-true}"
3535
S2I_DELETE_SOURCE="${S2I_DELETE_SOURCE:-true}"
36-
S2I_ENABLE_JLINK="${S2I_ENABLE_JLINK:-true}"
36+
S2I_ENABLE_JLINK="${S2I_ENABLE_JLINK:-false}"
3737
}
3838

3939
# extensions may override this method to initialize environment variables

modules/s2i/core/module.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ envs:
112112
Delete source files at the end of build. Defaults to true.
113113
example: "false"
114114

115-
- name: S2I_ENABLE_JLINK_WORKFLOW
115+
- name: S2I_ENABLE_JLINK
116116
description: ^
117117
Enables the Jdeps/JLink workflow to minimize JRE size
118118
example: "false"

0 commit comments

Comments
 (0)