有没有办法简单地为gradle设置一个全局的系统范围代理?
是的,我知道当前 systemProp.http.proxyHost
文件中有gradle.properties
,...等设置,但它仅适用于实际项目。但
那么,是否有任何“global gradle.properties”文件?
答案 0 :(得分:36)
是的,似乎有可能。请参阅here,尤其是:
我们可以定义一个
gradle.properties
文件并在其中设置属性 文件。我们可以将文件放在项目目录中或<USER_HOME>/.gradle
目录。属性中定义的属性 我们的主目录中的文件优先于定义的属性 在我们的项目目录中的文件中。作为奖励,我们也可以定义 在gradle.properties文件中的系统属性,我们只需要前缀 属性名称为systemProp
..
可以在以下路径中找到gradle.properties文件:
# windows gradle file
%userprofile%\.gradle\gradle.properties
# linux gradle file
~/.gradle/gradle.properties
答案 1 :(得分:8)
轻松复制和粘贴@Opal's answer
的解决方案systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=8080
将此添加到$HOME/.gradle/gradle.properties
(Linux,OSX,Unices)或%userprofile%\.gradle\gradle.properties
(Windows,as of @fty4)。
答案 2 :(得分:1)
以防万一,请不要忘记为例外列表设置let stabilize m input =
// prepends v n-times on vs
let rec prepend n v vs = if n > 0 then prepend (n - 1) v (v::vs) else vs
// Returns 0 if n < m (not stable) otherwise v (stable)
let stable n v = if n < m then 0 else v
// fold a sequence of potentially integers into stable sequence
// v: value to check if stable, n: number of times v appeared in sequence,
// vs: the aggregated stable sequence, u: next value to check
let folder (v, n, vs) u =
// Check invariant
assert (n = 0 || (n > 0 && v <> 0))
// n > 0 => we are checking if v is stable, if v = u increase n by 1
if n > 0 && v = u then (u, n + 1, vs)
// u = 0, we have received a 0, prepend the checked sequence and reset v, n
elif u = 0 then (0, 0, 0::prepend n (stable n v) vs)
// u <> 0, we have a value we need to check, preprend the checked sequence and start checking u
else (u, 1, prepend n (stable n v) vs)
let (v, n, vs) = input |> List.fold folder (0, 0, [])
// Handle the fold remainder
let vs = prepend n (stable n v) vs
// Result is reversed, so reverse it to get the result in the right order
let vs = vs |> List.rev
vs
[<EntryPoint>]
let main argv =
let i = [0; +1; +1; +1; 0; +1; -1; -1; 0; -1; -1; -1; -1; +1; +1; -1; +1; +1; +1; +1; +1; +1; +1; 0]
let e = [0; +1; +1; +1; 0; 0; 0; 0; 0; -1; -1; -1; -1; 0; 0; 0; +1; +1; +1; +1; +1; +1; +1; 0]
let vs = stabilize 3 i
printfn "Input : %A" i
printfn "Expected: %A" e
printfn "Actual : %A" vs
printfn "Result : %A" (vs = e)
0
systemProp.https.nonProxyHosts = artifactory.yourCompany.com | localhost | * .nonproxyrepos.com