diff --git a/bin/common.sh b/bin/common.sh index 30cda1c9a9a..a61edcfb064 100755 --- a/bin/common.sh +++ b/bin/common.sh @@ -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 @@ -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 @@ -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} @@ -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 } @@ -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 } diff --git a/bin/common_gradle.sh b/bin/common_gradle.sh index 9910d8c344a..2c873fe319d 100755 --- a/bin/common_gradle.sh +++ b/bin/common_gradle.sh @@ -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 @@ -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 @@ -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 } diff --git a/tests/backward-compat/build.gradle b/tests/backward-compat/build.gradle index 863c12fd690..c64d49171e9 100644 --- a/tests/backward-compat/build.gradle +++ b/tests/backward-compat/build.gradle @@ -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") diff --git a/tests/scripts/build.gradle b/tests/scripts/build.gradle index ef1fe0243e6..5f67058f191 100644 --- a/tests/scripts/build.gradle +++ b/tests/scripts/build.gradle @@ -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") diff --git a/tests/scripts/src/test/bash/bk_test.sh b/tests/scripts/src/test/bash/bk_test.sh index 20ee97d4c46..3c7b02e6fe1 100755 --- a/tests/scripts/src/test/bash/bk_test.sh +++ b/tests/scripts/src/test/bash/bk_test.sh @@ -21,7 +21,6 @@ # */ ARGV0=`basename "$0"` -export PROJECT_TARGET_DIR="build" PREFIX="bk_test_" SHELLS="/bin/sh /bin/bash" diff --git a/tests/scripts/src/test/bash/bk_test_bin_common.sh b/tests/scripts/src/test/bash/bk_test_bin_common.sh index 18e898c74bc..c0fc934e7c7 100644 --- a/tests/scripts/src/test/bash/bk_test_bin_common.sh +++ b/tests/scripts/src/test/bash/bk_test_bin_common.sh @@ -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 @@ -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}" @@ -49,7 +59,7 @@ testDefaultVariables() { } testFindModuleJarAt() { - source ${BK_BINDIR}/common.sh + source ${BK_BINDIR}/${BK_COMMON_EXEC} MODULE="test-module" @@ -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" @@ -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}" @@ -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" @@ -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" @@ -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 \ @@ -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" diff --git a/tests/shaded/bookkeeper-server-tests-shaded-test/build.gradle b/tests/shaded/bookkeeper-server-tests-shaded-test/build.gradle index 9ad1b71b2f9..eae3130f711 100644 --- a/tests/shaded/bookkeeper-server-tests-shaded-test/build.gradle +++ b/tests/shaded/bookkeeper-server-tests-shaded-test/build.gradle @@ -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']) }