In a class derived from Project
the instruction this.getSCMs().add(gitSCM)
causes the compilation error:
incompatible types: GitSCM cannot be converted to CAP#1
where CAP#1 is a fresh type-variable:
CAP#1 extends SCM frpù capture of ? extends SCM
The object gitSCM is being initialized as follows:
public void addGitRepo(String url, String branch)
{
List<UserRemoteConfig> repoList = new ArrayList<UserRemoteConfig>();
repoList.add(new UserRemoteConfig(url, null, null, null));
BranchSpec spec = new BranchSpec(branch);
ArrayList<BranchSpec> specList = new ArrayList<BranchSpec>();
specList.add(spec);
ArrayList<GitSCMExtension> scmExtensions = new ArrayList<GitSCMExtension>();
scmExtensions.add(new CleanCheckout());
GitSCM gitSCM = new GitSCM(repoList, specList, false, null, null, "", scmExtensions);
getSCMs().add(gitSCM);
}
GitSCM extends GitSCMBackwardsCompatibility, which extends SCM.
getSCMs returns a collection of SCM.
Even if I cast GitSCM to SCM I get the same error.
Why am I getting this error?
Thanks for your attention,
Ivo