Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move buildCyclonedxLib to Build the CycloneDX Java library and app used for SBoM generation from build.sh to sbom.sh #3209

Closed
wants to merge 10 commits into from
16 changes: 1 addition & 15 deletions sbin/build.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -704,20 +704,6 @@ setupAntEnv() {
echo "${javaHome}"
}

# Build the CycloneDX Java library and app used for SBoM generation
buildCyclonedxLib() {
local javaHome="${1}"

# Make Ant aware of cygwin path
if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]]; then
ANTBUILDFILE=$(cygpath -m "${CYCLONEDB_DIR}/build.xml")
else
ANTBUILDFILE="${CYCLONEDB_DIR}/build.xml"
fi
JAVA_HOME=${javaHome} ant -f "${ANTBUILDFILE}" clean
JAVA_HOME=${javaHome} ant -f "${ANTBUILDFILE}" build
}

# Generate the SBoM
generateSBoM() {
local javaHome="${1}"
@@ -793,7 +779,7 @@ generateSBoM() {
addSBOMMetadataTools "${javaHome}" "${classpath}" "${sbomJson}" "FreeType" "$(cat ${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[TARGET_DIR]}/metadata/dependency_version_freetype.txt)"
# Add FreeMarker 3rd party (openj9)
addSBOMMetadataTools "${javaHome}" "${classpath}" "${sbomJson}" "FreeMarker" "$(cat ${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[TARGET_DIR]}/metadata/dependency_version_freemarker.txt)"

# Add Build Docker image SHA1
buildimagesha=$(cat ${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[TARGET_DIR]}/metadata/docker.txt)
# ${BUILD_CONFIG[USE_DOCKER]^} always set to false cannot rely on it.
28 changes: 28 additions & 0 deletions sbin/common/sbom.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
#!/bin/bash
# Build the CycloneDX Java library and app used for SBoM generation
buildCyclonedxLib() {
local javaHome="${1}"

# Check if JDK-17 is available, download it if it isn't
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this boot jdk logic to

setupAntEnv() {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, i was about to say the logic should be in setupAntEnv()

if [ ! -d "${javaHome}" ]; then
# Download JDK-17
apiUrlTemplate="https://api.adoptium.net/v3/binary/latest/\${JDK_BOOT_VERSION}/\${releaseType}/linux/\${downloadArch}/jdk/hotspot/normal/\${vendor}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need these 2 lines:
apiUrlTemplate=...
apiURL=$(eval echo ${apiUrlTemplate})

apiURL=$(eval echo ${apiUrlTemplate})
JDK_BOOT_VERSION="17"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make all these "local" variables

releaseType="ga"
downloadArch="x64"
vendor="adoptium"
apiURL="https://api.adoptium.net/v3/binary/latest/${JDK_BOOT_VERSION}/${releaseType}/linux/${downloadArch}/jdk/hotspot/normal/${vendor}"
echo "Downloading GA release of boot JDK version ${JDK_BOOT_VERSION} from ${apiURL}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing the actual download..

curl -L "${apiURL}" | tar xpzf - --strip-components=1 -C "$jdkDir"

Set jdkDir variable to be "${CYCLONEDB_DIR}/jdk"
Also add that folder to https://github.com/adoptium/temurin-build/blob/master/.gitignore

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then set javaHome in setupAntEnv()

fi

# Make Ant aware of cygwin path
if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]]; then
ANTBUILDFILE=$(cygpath -m "${CYCLONEDB_DIR}/build.xml")
else
ANTBUILDFILE="${CYCLONEDB_DIR}/build.xml"
fi

JAVA_HOME="${javaHome}" ant -f "${ANTBUILDFILE}" clean
JAVA_HOME="${javaHome}" ant -f "${ANTBUILDFILE}" build
}

# Create a default SBOM json file: sbomJson
createSBOMFile() {
local javaHome="${1}"