本文整理匯總了Java中org.apache.maven.project.MavenProject.getRepositories方法的典型用法代碼示例。如果您正苦於以下問題:Java MavenProject.getRepositories方法的具體用法?Java MavenProject.getRepositories怎麽用?Java MavenProject.getRepositories使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.maven.project.MavenProject
的用法示例。
在下文中一共展示了MavenProject.getRepositories方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addModelRepository
import org.apache.maven.project.MavenProject; //導入方法依賴的package包/類
/**
*
* @param mdl
* @param url of the repository
* @param add true == add to model, will not add if the repo is in project but not in model (eg. central repo)
* @return null if repository with given url exists, otherwise a returned newly created item.
*/
public static Repository addModelRepository(MavenProject project, POMModel mdl, String url) {
if (url.contains(RepositorySystem.DEFAULT_REMOTE_REPO_URL) || /* #212336 */url.contains("http://repo1.maven.org/maven2")) {
return null;
}
List<Repository> repos = mdl.getProject().getRepositories();
if (repos != null) {
for (Repository r : repos) {
if (url.equals(r.getUrl())) {
//already in model..either in pom.xml or added in this session.
return null;
}
}
}
List<org.apache.maven.model.Repository> reps = project.getRepositories();
org.apache.maven.model.Repository prjret = null;
Repository ret = null;
if (reps != null) {
for (org.apache.maven.model.Repository re : reps) {
if (url.equals(re.getUrl())) {
prjret = re;
break;
}
}
}
if (prjret == null) {
ret = mdl.getFactory().createRepository();
ret.setUrl(url);
ret.setId(url);
mdl.getProject().addRepository(ret);
}
return ret;
}