Skip to content

Commit 14bb21f

Browse files
committed
add find_java
1 parent da482b4 commit 14bb21f

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
--!A cross-platform build utility based on Lua
2+
--
3+
-- Licensed under the Apache License, Version 2.0 (the "License");
4+
-- you may not use this file except in compliance with the License.
5+
-- You may obtain a copy of the License at
6+
--
7+
-- http://www.apache.org/licenses/LICENSE-2.0
8+
--
9+
-- Unless required by applicable law or agreed to in writing, software
10+
-- distributed under the License is distributed on an "AS IS" BASIS,
11+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
-- See the License for the specific language governing permissions and
13+
-- limitations under the License.
14+
--
15+
-- Copyright (C) 2015-present, TBOOX Open Source Group.
16+
--
17+
-- @author ruki
18+
-- @file find_java.lua
19+
--
20+
21+
-- imports
22+
import("lib.detect.find_program")
23+
import("lib.detect.find_programver")
24+
25+
-- find java
26+
--
27+
-- @param opt the argument options, e.g. {version = true}
28+
--
29+
-- @return program, version
30+
--
31+
-- @code
32+
--
33+
-- local java = find_java()
34+
-- local java, version = find_java({version = true})
35+
--
36+
-- @endcode
37+
--
38+
function main(opt)
39+
opt = opt or {}
40+
opt.check = opt.check or "-version"
41+
opt.command = opt.command or "-version"
42+
43+
local program = find_program(opt.program or "java", opt)
44+
local version = nil
45+
if program and opt and opt.version then
46+
version = find_programver(program, opt)
47+
end
48+
return program, version
49+
end
50+

0 commit comments

Comments
 (0)