Skip to content

Commit 3611396

Browse files
committed
Compiling the Java tutorials codes using Apache Ant.
1 parent 9bb17ca commit 3611396

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

samples/CMakeLists.txt

Lines changed: 3 additions & 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(gpu)
1516
add_subdirectory(tapi)
1617

@@ -78,6 +79,8 @@ endif()
7879
add_subdirectory(cpp)
7980
# FIXIT: can't use cvconfig.h in samples: add_subdirectory(gpu)
8081

82+
add_subdirectory(java/tutorial_code)
83+
8184
add_subdirectory(opencl)
8285

8386
if(WIN32)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# ----------------------------------------------------------------------------
2+
# CMake file for Java tutorials compilation.
3+
#
4+
# ----------------------------------------------------------------------------
5+
if(NOT ANT_EXECUTABLE)
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(target_name "compile_java_tutorials")
14+
set(TUTORIALS_DIRS "")
15+
16+
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*/*)
17+
FOREACH(child ${children})
18+
if(IS_DIRECTORY ${curdir}/${child})
19+
FILE(GLOB contains_java_files "${child}/*.java")
20+
if(contains_java_files)
21+
LIST(APPEND TUTORIALS_DIRS ${child})
22+
endif()
23+
endif()
24+
ENDFOREACH()
25+
26+
add_custom_target("${target_name}" ALL
27+
DEPENDS opencv_java
28+
)
29+
30+
FOREACH(tutorial_dir ${TUTORIALS_DIRS})
31+
get_filename_component(tutorial_name ${tutorial_dir} NAME_WE)
32+
add_custom_command(TARGET "${target_name}"
33+
COMMAND ${ANT_EXECUTABLE} -q
34+
-DocvJarDir="${OpenCV_BINARY_DIR}/bin"
35+
-DsrcDir="${tutorial_dir}"
36+
-DdstDir="${opencv_tutorial_java_bin_dir}/${tutorial_name}"
37+
WORKING_DIRECTORY "${curdir}"
38+
COMMENT "Compile the tutorial: ${tutorial_name}"
39+
)
40+
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)