我正在尝试在 gradle 构建中声明源依赖项。在 settings.gradle 中,我定义了:
sourceControl {
gitRepository("https://github.com/my-organization/myRepo.git") {
producesModule("com.jrandrews:my-dependency")
}
}
Run Code Online (Sandbox Code Playgroud)
在 build.gradle 中,我已经声明:
configurations{ application }
dependencies {
application('com.jrandrews:my-dependency') {
version { branch = 'master' }
}
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试了主题的几种变体来尝试声明 auth 方法和 auth 属性。“gradle dependencies --stacktrace”总是导致以下形式的失败:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':dependencies'.
...
Caused by: org.gradle.api.GradleException: Could not locate branch 'master' for Git repository at https://github.com/....
...
Caused by: org.eclipse.jgit.api.errors.TransportException: https://github.com/***.git: Authentication is required but no CredentialsProvider has been registered
at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:222)
at org.eclipse.jgit.api.LsRemoteCommand.call(LsRemoteCommand.java:161)
at org.gradle.vcs.git.internal.GitVersionControlSystem.getRemoteRefs(GitVersionControlSystem.java:103)
... 136 more …Run Code Online (Sandbox Code Playgroud) 给出以下内容:
class A
{
public void Foo(object o)
{
Console.WriteLine("general");
}
public void Foo(B o)
{
Console.WriteLine("specific");
}
}
class B
{
A a = new A();
public void CallFoo(object x)
{
a.Foo(x);
}
public static void Main()
{
B b = new B();
b.CallFoo(b);
b.a.Foo(b);
}
}
Run Code Online (Sandbox Code Playgroud)
我观察以下输出:
general
specific
Run Code Online (Sandbox Code Playgroud)
很自然,我很困惑.这里发生了什么?