Skip to content

Commit 20f603a

Browse files
committed
Merge pull request opencv#8993 from Cartucho:compiling_java_code
2 parents 8088d67 + 9884915 commit 20f603a

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

samples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
1111
# ----------------------------------------------------------------------------
1212

1313
add_subdirectory(cpp)
14+
add_subdirectory(java/tutorial_code)
1415
add_subdirectory(dnn)
1516
add_subdirectory(gpu)
1617
add_subdirectory(tapi)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# ----------------------------------------------------------------------------
2+
# CMake file for Java tutorials compilation.
3+
#
4+
# ----------------------------------------------------------------------------
5+
if(NOT ANT_EXECUTABLE OR NOT TARGET opencv_java)
6+
return()
7+
endif()
8+
9+
project(compile_java_tutorials)
10+
11+
set(curdir "${CMAKE_CURRENT_SOURCE_DIR}")
12+
set(opencv_tutorial_java_bin_dir "${CMAKE_CURRENT_BINARY_DIR}/.compiled")
13+
set(TUTORIALS_DIRS "")
14+
15+
file(GLOB children RELATIVE ${curdir} ${curdir}/*/*)
16+
foreach(child ${children})
17+
if(IS_DIRECTORY ${curdir}/${child})
18+
file(GLOB contains_java_files "${child}/*.java")
19+
if(contains_java_files)
20+
list(APPEND TUTORIALS_DIRS ${child})
21+
endif()
22+
endif()
23+
endforeach()
24+
25+
add_custom_target("${PROJECT_NAME}"
26+
DEPENDS opencv_java
27+
)
28+
29+
foreach(TUTORIAL_DIR ${TUTORIALS_DIRS})
30+
get_filename_component(TUTORIAL_NAME ${TUTORIAL_DIR} NAME_WE)
31+
add_custom_command(TARGET "${PROJECT_NAME}"
32+
COMMAND ${ANT_EXECUTABLE} -q
33+
-DocvJarDir="${OpenCV_BINARY_DIR}/bin"
34+
-DsrcDir="${TUTORIAL_DIR}"
35+
-DdstDir="${opencv_tutorial_java_bin_dir}/${TUTORIAL_NAME}"
36+
WORKING_DIRECTORY "${curdir}"
37+
COMMENT "Compile the tutorial: ${TUTORIAL_NAME}"
38+
)
39+
endforeach()

samples/java/tutorial_code/build.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<project default="compile">
2+
3+
<property name="lib.dir" value="${ocvJarDir}"/>
4+
<path id="classpath">
5+
<fileset dir="${lib.dir}" includes="**/*.jar"/>
6+
</path>
7+
8+
<target name="compile">
9+
<mkdir dir="${dstDir}"/>
10+
<javac includeantruntime="false" srcdir="${srcDir}" destdir="${dstDir}" classpathref="classpath"/>
11+
</target>
12+
13+
</project>

0 commit comments

Comments
 (0)