11package com .redhat .hacbs .container .build .preprocessor ;
22
3+ import static org .apache .commons .lang3 .StringUtils .isNotEmpty ;
4+
35import java .io .IOException ;
46import java .nio .file .Files ;
57import java .nio .file .Path ;
911import io .quarkus .logging .Log ;
1012import picocli .CommandLine ;
1113
12- import static org .apache .commons .lang3 .StringUtils .isNotEmpty ;
13-
1414/**
1515 * We keep all the options the same between maven, gradle, sbt and ant for now to keep the pipeline setup simpler.
1616 * Some of these may be ignored by different processors
@@ -55,13 +55,84 @@ public String toString() {
5555 @ Override
5656 public void run () {
5757
58- Log .warnf ("### Using tool {} with version {} and javaHome {}" , type , buildToolVersion , javaHome );
58+ Log .warnf ("### Using tool %s with version %s and javaHome %s" , type , buildToolVersion , javaHome );
59+ Log .warnf ("### ENV %s" , System .getenv ("jvm-build-service" ));
60+ Log .warnf ("### BUILD_SCRIPT %s" , System .getenv ("BUILD_SCRIPT" ));
5961
6062 Path jbsDirectory = Path .of (buildRoot .toString (), ".jbs" );
6163 //noinspection ResultOfMethodCallIgnored
6264 jbsDirectory .toFile ().mkdirs ();
6365
64- Log .warnf ("### ENV %s" , System .getenv ("jvm-build-service" ));
66+ String runBuild = """
67+ #!/usr/bin/env bash
68+ set -o verbose
69+ set -eu
70+ set -o pipefail
71+
72+ export LANG="en_US.UTF-8"
73+ export LC_ALL="en_US.UTF-8"
74+ export JAVA_HOME=%s
75+ # This might get overridden by the tool home configuration below. This is
76+ # useful if Gradle/Ant also requires Maven configured.
77+ export MAVEN_HOME=/opt/maven/3.8.8
78+ export %s_HOME=/opt/%s/%s
79+
80+ cd %s
81+ mkdir -p ../logs ../packages
82+
83+ if [ ! -z ${JAVA_HOME+x} ]; then
84+ echo "JAVA_HOME:$JAVA_HOME"
85+ PATH="${JAVA_HOME}/bin:$PATH"
86+ fi
87+
88+ if [ ! -z ${MAVEN_HOME+x} ]; then
89+ echo "MAVEN_HOME:$MAVEN_HOME"
90+ PATH="${MAVEN_HOME}/bin:$PATH"
91+
92+ if [ ! -d "${MAVEN_HOME}" ]; then
93+ echo "Maven home directory not found at ${MAVEN_HOME}" >&2
94+ exit 1
95+ fi
96+ fi
97+
98+ if [ ! -z ${GRADLE_HOME+x} ]; then
99+ echo "GRADLE_HOME:$GRADLE_HOME"
100+ PATH="${GRADLE_HOME}/bin:$PATH"
101+
102+ if [ ! -d "${GRADLE_HOME}" ]; then
103+ echo "Gradle home directory not found at ${GRADLE_HOME}" >&2
104+ exit 1
105+ fi
106+ fi
107+
108+ if [ ! -z ${ANT_HOME+x} ]; then
109+ echo "ANT_HOME:$ANT_HOME"
110+ PATH="${ANT_HOME}/bin:$PATH"
111+
112+ if [ ! -d "${ANT_HOME}" ]; then
113+ echo "Ant home directory not found at ${ANT_HOME}" >&2
114+ exit 1
115+ fi
116+ fi
117+
118+ if [ ! -z ${SBT_DIST+x} ]; then
119+ echo "SBT_DIST:$SBT_DIST"
120+ PATH="${SBT_DIST}/bin:$PATH"
121+
122+ if [ ! -d "${SBT_DIST}" ]; then
123+ echo "SBT home directory not found at ${SBT_DIST}" >&2
124+ exit 1
125+ fi
126+ fi
127+ echo "PATH:$PATH"
128+
129+ #fix this when we no longer need to run as root
130+ export HOME=/root
131+
132+
133+ """ .formatted (javaHome , type .name (), type , buildToolVersion , buildRoot );
134+
135+ Log .warnf ("### runBuild is %s" , runBuild );
65136
66137 String containerFile = """
67138 FROM %s
@@ -71,8 +142,8 @@ public void run() {
71142
72143 // This block is only needed for running inside JBS
73144 if (isNotEmpty (System .getenv ("jvm-build-service" ))) {
145+ //RUN mkdir -p /var/workdir/software/settings /original-content/marker
74146 containerFile += """
75- RUN mkdir -p /var/workdir/software/settings /original-content/marker
76147
77148 ARG CACHE_URL=""
78149 ENV CACHE_URL=$CACHE_URL
0 commit comments