diff options
author | Nobuaki Sukegawa <nsuke@apache.org> | 2016-02-27 03:04:34 +0900 |
---|---|---|
committer | Nobuaki Sukegawa <nsuke@apache.org> | 2016-02-27 16:55:55 +0900 |
commit | aa7d0d5f2a9e8b201e8d0f5a37f420b9846e4625 (patch) | |
tree | c83ca59c05bd5277df77b7b5537c4b018a8d783e | |
parent | 6bbc9e3a60014a3f5e0c26c842f7d345935bfe0d (diff) | |
download | thrift-aa7d0d5f2a9e8b201e8d0f5a37f420b9846e4625.tar.gz |
THRIFT-3677 Improve CMake Java build
This closes #897
-rwxr-xr-x | appveyor.yml | 19 | ||||
-rw-r--r-- | build/cmake/CPackConfig.cmake | 2 | ||||
-rw-r--r-- | lib/java/CMakeLists.txt | 26 | ||||
-rw-r--r--[-rwxr-xr-x] | lib/java/build.xml | 17 |
4 files changed, 42 insertions, 22 deletions
diff --git a/appveyor.yml b/appveyor.yml index 61c5f9a71..f36c7f06e 100755 --- a/appveyor.yml +++ b/appveyor.yml @@ -53,27 +53,32 @@ install: - move *.h include\ - cd .. - cinst winflexbison -- cinst nsis -# TODO: Enable Java build # - cinst ant -ignoreDependencies +- cd \ +- appveyor DownloadFile http://www.us.apache.org/dist//ant/binaries/apache-ant-1.9.6-bin.zip +- 7z x apache-ant-1.9.6-bin.zip +- cd %APPVEYOR_BUILD_FOLDER% # TODO: Enable Haskell build # - cinst HaskellPlatform -version 2014.2.0.0 build_script: -# - set PATH=C:\ProgramData\chocolatey\bin;C:\tools\apache-ant-1.9.4\bin;%PATH% -# - set JAVA_HOME=C:\Program Files\Java\jdk1.7.0 -# - set PATH=%JAVA_HOME%\bin;%PATH% +- set PATH=C:\ProgramData\chocolatey\bin;C:\apache-ant-1.9.6\bin;%PATH% +- set JAVA_HOME=C:\Program Files\Java\jdk1.7.0 +- set PATH=%JAVA_HOME%\bin;%PATH% # - set PATH=%PATH%;C:\Program Files (x86)\Haskell Platform\2014.2.0.0\bin # - set PATH=%PATH%;C:\Program Files (x86)\Haskell Platform\2014.2.0.0\lib\extralibs\bin - set PATH=C:\Python27-x64;%PATH% - mkdir cmake-build - cd cmake-build -- cmake -G "Visual Studio 14 2015 Win64" -DWITH_JAVA=OFF -DWITH_SHARED_LIB=OFF -DLIBEVENT_ROOT=%APPVEYOR_BUILD_FOLDER%\libevent-2.0.22-stable -DZLIB_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8 -DZLIB_LIBRARY=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8\release\zlibstatic.lib -DBOOST_ROOT="%BOOST_ROOT% -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR% .. +- cmake -G "Visual Studio 14 2015 Win64" -DWITH_JAVA=ON -DWITH_SHARED_LIB=OFF -DLIBEVENT_ROOT=%APPVEYOR_BUILD_FOLDER%\libevent-2.0.22-stable -DZLIB_INCLUDE_DIR=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8 -DZLIB_LIBRARY=%APPVEYOR_BUILD_FOLDER%\zlib-1.2.8\release\zlibstatic.lib -DBOOST_ROOT="%BOOST_ROOT% -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR% .. +- findstr /b /e BUILD_COMPILER:BOOL=ON CMakeCache.txt +- findstr /b /e BUILD_JAVA:BOOL=ON CMakeCache.txt +- findstr /b /e BUILD_TESTING:BOOL=ON CMakeCache.txt # - cmake --build . - cmake --build . --config Release # TODO: Fix cpack # - cpack -- ctest -C Release -VV -E "(concurrency_test|processor_test|python_test$|^Python)" +- ctest -C Release -VV -E "(concurrency_test|processor_test|python_test$|^Python|^Java)" #TODO make it perfect ;-r diff --git a/build/cmake/CPackConfig.cmake b/build/cmake/CPackConfig.cmake index 45077c00c..fdc1b4e76 100644 --- a/build/cmake/CPackConfig.cmake +++ b/build/cmake/CPackConfig.cmake @@ -58,7 +58,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows") "https://issues.apache.org/jira/browse/THRIFT" "Apache Thrift - Issues") set(CPACK_NSIS_CONTACT ${CPACK_PACKAGE_CONTACT}) set(CPACK_NSIS_MODIFY_PATH "ON") - set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) + set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}") else() set(CPACK_GENERATOR "DEB" ) set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT}) diff --git a/lib/java/CMakeLists.txt b/lib/java/CMakeLists.txt index 2014f5ccb..57b97f105 100644 --- a/lib/java/CMakeLists.txt +++ b/lib/java/CMakeLists.txt @@ -28,7 +28,7 @@ if(ANDROID) set(THRIFT_AAR outputs/aar/thrift-debug.aar outputs/aar/thrift-release.aar) add_custom_command( OUTPUT ${THRIFT_AAR} - COMMAND ${GRADLE_EXECUTABLE} -p${CMAKE_CURRENT_SOURCE_DIR}/android -PbuildDir=${CMAKE_CURRENT_BINARY_DIR} assemble + COMMAND ${GRADLE_EXECUTABLE} -p"${CMAKE_CURRENT_SOURCE_DIR}/android" -PbuildDir="${CMAKE_CURRENT_BINARY_DIR}" assemble DEPENDS ${java_sources} ${android_sources}) add_custom_target(thrift_aar ALL DEPENDS ${THRIFT_AAR}) @@ -46,21 +46,35 @@ else(ANDROID) set(JAVA_DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${DOC_INSTALL_DIR}/java") endif() - add_custom_target(ant_build ALL - COMMAND ${Ant_EXECUTABLE} ${ANT_FLAGS} -Dbuild.dir=${CMAKE_CURRENT_BINARY_DIR} -Dworking.dir=${work_dir} -f build.xml + file(GLOB_RECURSE ThriftJava_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.java) + set(ThriftJava_ARTIFACTS + libthrift-${thrift_VERSION}.jar + libthrift-${thrift_VERSION}.pom + ) + add_custom_command( + OUTPUT ${ThriftJava_ARTIFACTS} + COMMAND ${Ant_EXECUTABLE} ${ANT_FLAGS} -Dbuild.dir="${CMAKE_CURRENT_BINARY_DIR}" -f build.xml + MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/build.xml + DEPENDS ${ThriftJava_SOURCES} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + + add_custom_target(ThriftJava ALL COMMENT "Building Java library using Ant" + DEPENDS ${ThriftJava_ARTIFACTS} ) # Hook the ant install task into CMake install install(CODE "execute_process( COMMAND ${Ant_EXECUTABLE} ${ANT_FLAGS} install - -Dbuild.dir=${CMAKE_CURRENT_BINARY_DIR} -Dworking.dir=${work_dir} - -Dinstall.path=${JAVA_INSTALL_DIR} -Dinstall.javadoc.path=${JAVA_DOC_INSTALL_DIR} -f build.xml + -Dbuild.dir=\"${CMAKE_CURRENT_BINARY_DIR}\" + -Dinstall.path=\"${JAVA_INSTALL_DIR}\" -Dinstall.javadoc.path=\"${JAVA_DOC_INSTALL_DIR}\" -f build.xml WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )") if(BUILD_TESTING) - #add_subdirectory(test) + add_test(NAME JavaTest + COMMAND ${Ant_EXECUTABLE} ${ANT_FLAGS} -Dbuild.dir="${CMAKE_CURRENT_BINARY_DIR}" -Dthrift.compiler="${THRIFT_COMPILER}" -f build.xml test + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) endif() endif(ANDROID) diff --git a/lib/java/build.xml b/lib/java/build.xml index 62680b79c..1097af54d 100755..100644 --- a/lib/java/build.xml +++ b/lib/java/build.xml @@ -36,6 +36,7 @@ <property name="final.name" value="${thrift.artifactid}-${version}"/> + <property name="thrift.compiler" location="../../compiler/cpp/thrift"/> <property name="src" location="${basedir}/src"/> <property name="build.dir" location="${basedir}/build"/> <property name="build.lib.dir" location="${build.dir}/lib"/> @@ -260,31 +261,31 @@ <target name="generate"> <!-- Generate the thrift gen-java source --> - <exec executable="../../compiler/cpp/thrift" failonerror="true"> + <exec executable="${thrift.compiler}" failonerror="true"> <arg line="--gen java ${test.thrift.home}/ThriftTest.thrift"/> </exec> - <exec executable="../../compiler/cpp/thrift" failonerror="true"> + <exec executable="${thrift.compiler}" failonerror="true"> <arg line="--gen java ${test.thrift.home}/DebugProtoTest.thrift"/> </exec> - <exec executable="../../compiler/cpp/thrift" failonerror="true"> + <exec executable="${thrift.compiler}" failonerror="true"> <arg line="--gen java ${test.thrift.home}/OptionalRequiredTest.thrift"/> </exec> - <exec executable="../../compiler/cpp/thrift" failonerror="true"> + <exec executable="${thrift.compiler}" failonerror="true"> <arg line="--gen java:beans,nocamel ${test.thrift.home}/JavaBeansTest.thrift"/> </exec> - <exec executable="../../compiler/cpp/thrift" failonerror="true"> + <exec executable="${thrift.compiler}" failonerror="true"> <arg line="--gen java ${test.thrift.home}/ManyOptionals.thrift"/> </exec> <exec executable="mkdir" failonerror="true"> <arg line="-p ${genfullcamel}"/> </exec> - <exec executable="../../compiler/cpp/thrift" failonerror="true"> + <exec executable="${thrift.compiler}" failonerror="true"> <arg line="--gen java:fullcamel -out ${genfullcamel} ${test.thrift.home}/FullCamelTest.thrift"/> </exec> <exec executable="mkdir" failonerror="true"> <arg line="-p ${genreuse}"/> </exec> - <exec executable="../../compiler/cpp/thrift" failonerror="true"> + <exec executable="${thrift.compiler}" failonerror="true"> <arg line="--gen java:reuse-objects -out ${genreuse} ${test.thrift.home}/ReuseObjects.thrift"/> </exec> </target> @@ -370,7 +371,7 @@ <!-- Dependencies needed for testing --> <artifact:dependencies filesetId="test-dependency-jars" useScope="runtime"> - <dependency groupId="org.slf4j" artifactId="slf4j-log4j12" version="1.5.8"/> + <dependency groupId="org.slf4j" artifactId="slf4j-log4j12" version="${slf4j.version}"/> <dependency groupId="junit" artifactId="junit" version="4.4"/> </artifact:dependencies> |