Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoloboschi committed Oct 26, 2021
1 parent 5fd0341 commit bcab40d
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 33 deletions.
14 changes: 7 additions & 7 deletions bin/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ else
JAVA=${JAVA_HOME}/bin/java
fi

PROJECT_TARGET_DIR=${PROJECT_TARGET_DIR:-build}
BINDIR=${BK_BINDIR:-"`dirname "$0"`"}
BK_HOME=${BK_HOME:-"`cd ${BINDIR}/..;pwd`"}
BK_CONFDIR=${BK_HOME}/conf
Expand Down Expand Up @@ -197,7 +196,7 @@ find_module_jar() {
fi

if [ -z "${MODULE_JAR}" ]; then
BUILT_JAR=$(find_module_jar_at ${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR} ${MODULE_NAME})
BUILT_JAR=$(find_module_jar_at ${BK_HOME}/${MODULE_PATH}/target ${MODULE_NAME})
if [ -z "${BUILT_JAR}" ]; then
echo "Couldn't find module '${MODULE_NAME}' jar." >&2
read -p "Do you want me to run \`mvn package -DskipTests\` for you ? (y|n) " answer
Expand All @@ -213,7 +212,7 @@ find_module_jar() {
;;
esac

BUILT_JAR=$(find_module_jar_at ${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR} ${MODULE_NAME})
BUILT_JAR=$(find_module_jar_at ${BK_HOME}/${MODULE_PATH}/target ${MODULE_NAME})
fi
if [ -n "${BUILT_JAR}" ]; then
MODULE_JAR=${BUILT_JAR}
Expand All @@ -238,12 +237,13 @@ add_maven_deps_to_classpath() {
# Need to generate classpath from maven pom. This is costly so generate it
# and cache it. Save the file into our target dir so a mvn clean will get
# clean it up and force us create a new one.
f="${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR}/cached_classpath.txt"
output="${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR}/build_classpath.out"
f="${BK_HOME}/${MODULE_PATH}/target/cached_classpath.txt"
output="${BK_HOME}/${MODULE_PATH}/target/build_classpath.out"

if [ ! -f ${f} ]; then
echo "the classpath of module '${MODULE_PATH}' is not found, generating it ..." >&2
echo "see output at ${output} for the progress ..." >&2
${MVN} -f "${BK_HOME}/${MODULE_PATH}/pom.xml" dependency:build-classpath -Dmdep.outputFile="${PROJECT_TARGET_DIR}/cached_classpath.txt" &> ${output}
${MVN} -f "${BK_HOME}/${MODULE_PATH}/pom.xml" dependency:build-classpath -Dmdep.outputFile="target/cached_classpath.txt" &> ${output}
echo "the classpath of module '${MODULE_PATH}' is generated at '${f}'." >&2
fi
}
Expand All @@ -258,7 +258,7 @@ set_module_classpath() {
echo ${BK_CLASSPATH}
else
add_maven_deps_to_classpath ${MODULE_PATH} >&2
cat ${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR}/cached_classpath.txt
cat ${BK_HOME}/${MODULE_PATH}/target/cached_classpath.txt
fi
return
}
Expand Down
13 changes: 4 additions & 9 deletions bin/common_gradle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ is_released_binary() {
find_module_jar_at() {
DIR=$1
MODULE=$2
REGEX="^${MODULE}.jar$"
REGEX="^${MODULE}-[0-9\\.]*((-[a-zA-Z]*(-[0-9]*)?)|(-SNAPSHOT))?.jar$"
if [ -d ${DIR} ]; then
cd ${DIR}
for f in *.jar; do
Expand Down Expand Up @@ -213,21 +213,16 @@ find_module_jar() {
echo "Could not find module '${MODULE_JAR}' jar." >&2
exit 1
fi
##echo ${MODULE_JAR}
echo "${MODULE_JAR}"
return
}

add_maven_deps_to_classpath() {
MODULE_PATH=$1
MVN="mvn"
if [ "$MAVEN_HOME" != "" ]; then
MVN=${MAVEN_HOME}/bin/mvn
fi

# Need to generate classpath from maven pom. This is costly so generate it
# and cache it. Save the file into our target dir so a mvn clean will get
# clean it up and force us create a new one.
f="${BK_HOME}/${MODULE_PATH}/build/classpath.txt"
f="${BK_HOME}/${MODULE_PATH}/build/cached_classpath.txt"
if [ ! -f ${f} ]; then
echo "the classpath of module '${MODULE_PATH}' is not found, generating it ..." >&2
${BK_HOME}/gradlew ${MODULE_PATH}:jar
Expand All @@ -245,7 +240,7 @@ set_module_classpath() {
echo ${BK_CLASSPATH}
else
add_maven_deps_to_classpath ${MODULE_PATH} >&2
cat ${BK_HOME}/${MODULE_PATH}/build/classpath.txt
cat ${BK_HOME}/${MODULE_PATH}/build/cached_classpath.txt
fi
return
}
Expand Down
1 change: 0 additions & 1 deletion tests/backward-compat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ subprojects {
apply plugin: 'groovy'
apply plugin: 'com.adarshr.test-logger'


dependencies {
testImplementation 'org.codehaus.groovy:groovy-all:2.4.15'
testImplementation project(":tests:integration-tests-utils")
Expand Down
4 changes: 2 additions & 2 deletions tests/scripts/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ task downloadShunit2(type: Download) {

task extractShunit2(dependsOn: downloadShunit2, type: Copy) {
from zipTree(downloadShunit2.dest)
into new File(buildDir, "lib")
into new File(buildDir, "libs/lib")
}

task executeShTests(dependsOn: extractShunit2, type: Exec) {

workingDir "src/test/bash"
commandLine "./bk_test.sh"
args "build"
args "-e PROJECT_BUILD_SYSTEM=gradle"
}
tasks.test.dependsOn("executeShTests")
1 change: 0 additions & 1 deletion tests/scripts/src/test/bash/bk_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
# */

ARGV0=`basename "$0"`
export PROJECT_TARGET_DIR="build"
PREFIX="bk_test_"
SHELLS="/bin/sh /bin/bash"

Expand Down
34 changes: 22 additions & 12 deletions tests/scripts/src/test/bash/bk_test_bin_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
# * See the License for the specific language governing permissions and
# * limitations under the License.
# */
PROJECT_BUILD_SYSTEM=${PROJECT_BUILD_SYSTEM:-maven}
if [[ $PROJECT_BUILD_SYSTEM == "gradle" ]]; then
PROJECT_TARGET_DIR=build/libs
TEST_CLASSPATH_DIR=build
BK_COMMON_EXEC=common_gradle.sh
else
PROJECT_TARGET_DIR=target
TEST_CLASSPATH_DIR=target
BK_COMMON_EXEC=common.sh
fi

# load test helpers
. ./bk_test_helpers
Expand All @@ -28,7 +38,7 @@
#

testDefaultVariables() {
source ${BK_BINDIR}/common.sh
source ${BK_BINDIR}/${BK_COMMON_EXEC}
assertEquals "BINDIR is not set correctly" "${BK_BINDIR}" "${BINDIR}"
assertEquals "BK_HOME is not set correctly" "${BK_HOMEDIR}" "${BK_HOME}"
assertEquals "DEFAULT_LOG_CONF is not set correctly" "${BK_CONFDIR}/log4j.properties" "${DEFAULT_LOG_CONF}"
Expand All @@ -49,7 +59,7 @@ testDefaultVariables() {
}

testFindModuleJarAt() {
source ${BK_BINDIR}/common.sh
source ${BK_BINDIR}/${BK_COMMON_EXEC}

MODULE="test-module"

Expand Down Expand Up @@ -114,7 +124,7 @@ testFindModuleJar() {
echo "" > ${BK_HOME}/conf/bkenv.sh
echo "" > ${BK_HOME}/conf/bk_cli_env.sh

source ${BK_BINDIR}/common.sh
source ${BK_BINDIR}/${BK_COMMON_EXEC}

MODULE="test-module"
MODULE_PATH="testmodule"
Expand Down Expand Up @@ -159,8 +169,8 @@ testLoadEnvfiles() {
echo "BOOKIE_MAX_HEAP_MEMORY=2048M" > ${BK_HOME}/conf/bkenv.sh
echo "CLI_MAX_HEAP_MEMORY=2048M" > ${BK_HOME}/conf/bk_cli_env.sh

# load the common.sh
source ${BK_BINDIR}/common.sh
# load the ${BK_COMMON_EXEC}
source ${BK_BINDIR}/${BK_COMMON_EXEC}

assertEquals "NETTY_LEAK_DETECTION_LEVEL is not set correctly" "enabled" "${NETTY_LEAK_DETECTION_LEVEL}"
assertEquals "BOOKIE_MAX_HEAP_MEMORY is not set correctly" "2048M" "${BOOKIE_MAX_HEAP_MEMORY}"
Expand All @@ -183,19 +193,19 @@ testSetModuleClasspath() {
echo "" > ${BK_HOME}/conf/bkenv.sh
echo "" > ${BK_HOME}/conf/bk_cli_env.sh

source ${BK_BINDIR}/common.sh
source ${BK_BINDIR}/${BK_COMMON_EXEC}

MODULE_PATH="testmodule"

mkdir -p ${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR}
echo "test-classpath" > ${BK_HOME}/${MODULE_PATH}/${PROJECT_TARGET_DIR}/cached_classpath.txt
mkdir -p ${BK_HOME}/${MODULE_PATH}/${TEST_CLASSPATH_DIR}
echo "test-classpath" > ${BK_HOME}/${MODULE_PATH}/${TEST_CLASSPATH_DIR}/cached_classpath.txt

local result=$(set_module_classpath ${MODULE_PATH})
assertEquals "test-classpath" ${result}
}

testBuildBookieJVMOpts() {
source ${BK_BINDIR}/common.sh
source ${BK_BINDIR}/${BK_COMMON_EXEC}

TEST_LOG_DIR=${BK_TMPDIR}/logdir
TEST_GC_LOG_FILENAME="test-gc.log"
Expand All @@ -210,7 +220,7 @@ testBuildBookieJVMOpts() {
}

testBuildCLIJVMOpts() {
source ${BK_BINDIR}/common.sh
source ${BK_BINDIR}/${BK_COMMON_EXEC}

TEST_LOG_DIR=${BK_TMPDIR}/logdir
TEST_GC_LOG_FILENAME="test-gc.log"
Expand All @@ -225,7 +235,7 @@ testBuildCLIJVMOpts() {
}

testBuildNettyOpts() {
source ${BK_BINDIR}/common.sh
source ${BK_BINDIR}/${BK_COMMON_EXEC}

ACTUAL_NETTY_OPTS=$(build_netty_opts)
EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled \
Expand All @@ -236,7 +246,7 @@ testBuildNettyOpts() {
}

testBuildBookieOpts() {
source ${BK_BINDIR}/common.sh
source ${BK_BINDIR}/${BK_COMMON_EXEC}

ACTUAL_OPTS=$(build_bookie_opts)
EXPECTED_OPTS="-Djava.net.preferIPv4Stack=true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ plugins {
dependencies {
testImplementation depLibs.slf4j
testImplementation depLibs.junit
testImplementation fileTree(dir: '../../../shaded/bookkeeper-server-shaded/', include: ['**/*.jar'])
testImplementation depLibs.commonsConfiguration
testImplementation project(':shaded:bookkeeper-server-shaded')
testImplementation fileTree(dir: '../../../shaded/bookkeeper-server-tests-shaded/', include: ['**/*.jar'])
}

0 comments on commit bcab40d

Please sign in to comment.