forked from guoguibing/librec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibrec.cmd
172 lines (145 loc) · 4.27 KB
/
librec.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
@echo off
@REM Copyright (C) 2016 LibRec
@REM This file is part of LibRec.
@REM LibRec is free software: you can redistribute it and/or modify
@REM it under the terms of the GNU General Public License as published by
@REM the Free Software Foundation, either version 3 of the License, or
@REM (at your option) any later version.
@REM LibRec is distributed in the hope that it will be useful,
@REM but WITHOUT ANY WARRANTY; without even the implied warranty of
@REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@REM GNU General Public License for more details.
@REM You should have received a copy of the GNU General Public License
@REM along with LibRec. If not, see <http://www.gnu.org/licenses/>.
setlocal enabledelayedexpansion
rem CONSTRUCT CLASSPATH
set PWD=%~dp0
set LIBREC_HOME=%PWD:~0,-5%
set LIB=%LIBREC_HOME%\lib
set LIB_CLASSPATH=
for /f "delims=" %%f in ('dir /b /od "%LIB%"\*.jar') do (set "LIB_CLASSPATH=!LIB_CLASSPATH!%LIB%\%%f;")
set CLASSPATH=%LIB_CLASSPATH%%LIBREC_HOME%\conf;%LIBREC_HOME%\bin;
set JAVA_ARG=
set LIBREC_MAIN=net.librec.tool.driver.DataDriver
set IS_VERBOSE="false"
rem SHOW HELP OR VERSION
if "%~1" equ "" goto ECHO_HELP
if "%~1" equ "help" goto ECHO_HELP
if "%~1" equ "-h" goto ECHO_HELP
if "%~1" equ "-help" goto ECHO_HELP
if "%~1" equ "--help" goto ECHO_HELP
if "%~1" equ "version" goto ECHO_VERSION
if "%~1" equ "-v" goto ECHO_VERSION
if "%~1" equ "-version" goto ECHO_VERSION
if "%~1" equ "--version" goto ECHO_VERSION
rem GET LIBREC_MAIN
if "%~1" equ "data" (set LIBREC_MAIN=net.librec.tool.driver.DataDriver)
if "%~1" equ "rec" (set LIBREC_MAIN=net.librec.tool.driver.RecDriver)
shift
rem GET JAVA_ARG
:LOOP
if "%~1" equ "" goto END
if "%~1" neq "-exec" goto NOT_EXEC
set "JAVA_ARG=!JAVA_ARG!-exec"
shift
goto LOOP
:NOT_EXEC
if "%~1" neq "-build" goto NOT_BUILD
set "JAVA_ARG=!JAVA_ARG!-build"
shift
goto LOOP
:NOT_BUILD
if "%~1" neq "-load" goto NOT_LOAD
set "JAVA_ARG=!JAVA_ARG!-load"
shift
goto LOOP
:NOT_LOAD
if "%~1" neq "-save" goto NOT_SAVE
set "JAVA_ARG=!JAVA_ARG!-save"
shift
goto LOOP
:NOT_SAVE
if "%~1" neq "-D" goto NOT_D
set "JAVA_ARG=!JAVA_ARG! -D"
shift
set "JAVA_ARG=!JAVA_ARG! %~1"
shift
set "JAVA_ARG=!JAVA_ARG!=%~1"
shift
goto LOOP
:NOT_D
if "%~1" neq "-jobconf" goto NOT_JOBCONF
set "JAVA_ARG=!JAVA_ARG! -jobconf"
shift
set "JAVA_ARG=!JAVA_ARG! %~1"
shift
set "JAVA_ARG=!JAVA_ARG!=%~1"
shift
goto LOOP
:NOT_JOBCONF
if "%~1" neq "-conf" goto NOT_CONF
set "JAVA_ARG=!JAVA_ARG! -conf"
shift
set "JAVA_ARG=!JAVA_ARG! %~1"
shift
goto LOOP
:NOT_CONF
if "%~1" neq "-libjars" goto NOT_LIBJARS
shift
set CLASSPATH=%LIB_CLASSPATH%%~1
shift
:GETJARS
set temp=%~1
set jarFile=%temp:~-4%
if "%jarFile%" equ ".jar" (
set CLASSPATH=%CLASSPATH%;%~1
shift
goto :GETJARS
)
goto LOOP
:NOT_LIBJARS
if "%~1" neq "-verbose" goto NOT_VERBOSE
shift
set IS_VERBOSE="true"
goto LOOP
:NOT_VERBOSE
:END
rem GET AND CHECK JAVA_VERSION
PATH %PATH%;%JAVA_HOME%\bin\
for /f tokens^=2-5^ delims^=.-_^" %%j in ('java -fullversion 2^>^&1') do set "jver=%%j%%k%%l%%m"
if %jver% LSS 17000 (
echo. Please update your JDK version to 1.7 or higher
) else (
if %IS_VERBOSE% equ "true" (
rem echo. JDK version: %jver%
echo. CLASSPATH:%CLASSPATH%
echo. LIBREC_MAIN:%LIBREC_MAIN%
echo. JAVA_ARG:%JAVA_ARG%
)
java -cp "%CLASSPATH%" %LIBREC_MAIN% %JAVA_ARG%
)
goto :skip
:ECHO_HELP
echo.
echo Usage: librec [command] [options]...
echo.
echo commands:
echo rec run recommender
echo data load data
echo.
echo global options:
echo -help display this help text
echo -exec run Recommender
echo -version show Librec version info
echo.
echo job options:
echo -conf [file] path to config file
echo -D, -jobconf [prop] set configuration items (key=value)
echo -libjars add entend jar files to classpath
echo -verbose print details of parameters
goto :skip
:ECHO_VERSION
echo.
echo LibRec 2.0.0
echo.
:skip