use of org.apache.maven.model.Repository in project che by eclipse.
the class MavenModelUtil method convertToMavenRepository.
public static Repository convertToMavenRepository(MavenRemoteRepository repository) {
Repository result = new Repository();
result.setId(repository.getId());
result.setName(repository.getName());
result.setUrl(repository.getUrl());
if (repository.getLayout() == null) {
result.setLayout("default");
} else {
result.setLayout(repository.getLayout());
}
if (repository.getSnapshotsPolicy() != null) {
result.setSnapshots(convertToMavenPolicy(repository.getSnapshotsPolicy()));
}
if (repository.getReleasesPolicy() != null) {
result.setReleases(convertToMavenPolicy(repository.getReleasesPolicy()));
}
return result;
}
use of org.apache.maven.model.Repository in project bazel by bazelbuild.
the class Resolver method resolveEffectiveModel.
/**
* Resolves all dependencies from a given "model source," which could be either a URL or a local
* file.
* @return the model.
*/
@Nullable
public Model resolveEffectiveModel(ModelSource modelSource, Set<String> exclusions, Rule parent) {
Model model = modelResolver.getEffectiveModel(modelSource, handler);
if (model == null) {
return null;
}
for (Repository repo : model.getRepositories()) {
modelResolver.addRepository(repo);
}
for (Dependency dependency : model.getDependencies()) {
if (!dependency.getScope().equals(COMPILE_SCOPE)) {
continue;
}
if (dependency.isOptional()) {
continue;
}
if (exclusions.contains(dependency.getGroupId() + ":" + dependency.getArtifactId())) {
continue;
}
try {
Rule artifactRule = new Rule(getArtifact(dependency), dependency.getExclusions());
HashSet<String> localDepExclusions = new HashSet<>(exclusions);
localDepExclusions.addAll(artifactRule.getExclusions());
boolean isNewDependency = addArtifact(artifactRule, model.toString());
if (isNewDependency) {
ModelSource depModelSource = modelResolver.resolveModel(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion());
if (depModelSource != null) {
artifactRule.setRepository(depModelSource.getLocation(), handler);
artifactRule.setSha1(downloadSha1(artifactRule));
resolveEffectiveModel(depModelSource, localDepExclusions, artifactRule);
} else {
handler.handle(Event.error("Could not get a model for " + dependency));
}
}
if (parent != null) {
parent.addDependency(artifactRule);
parent.getDependencies().addAll(artifactRule.getDependencies());
} else {
addArtifact(artifactRule, modelSource.getLocation());
}
} catch (UnresolvableModelException | InvalidArtifactCoordinateException e) {
handler.handle(Event.error("Could not resolve dependency " + dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion() + ": " + e.getMessage()));
}
}
return model;
}
use of org.apache.maven.model.Repository in project maven-plugins by apache.
the class AbstractAntTestMavenProjectStub method getRepositories.
/**
* @see org.apache.maven.project.MavenProject#getRepositories()
*/
public List getRepositories() {
Repository repo = new Repository();
repo.setId("central");
repo.setName("central");
repo.setUrl("http://repo1.maven.org/maven2");
return Collections.singletonList(repo);
}
use of org.apache.maven.model.Repository in project maven-plugins by apache.
the class MavenJDOMWriter method iterateRepository.
// -- void iterateReportSet(Counter, Element, java.util.Collection, java.lang.String, java.lang.String)
/**
* Method iterateRepository
*
* @param counter
* @param childTag
* @param parentTag
* @param list
* @param parent
*/
protected void iterateRepository(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) {
boolean shouldExist = list != null && list.size() > 0;
Element element = updateElement(counter, parent, parentTag, shouldExist);
if (shouldExist) {
Iterator it = list.iterator();
Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator();
if (!elIt.hasNext()) {
elIt = null;
}
Counter innerCount = new Counter(counter.getDepth() + 1);
while (it.hasNext()) {
Repository value = (Repository) it.next();
Element el;
if (elIt != null && elIt.hasNext()) {
el = (Element) elIt.next();
if (!elIt.hasNext()) {
elIt = null;
}
} else {
el = factory.element(childTag, element.getNamespace());
insertAtPreferredLocation(element, el, innerCount);
}
updateRepository(value, childTag, innerCount, el);
innerCount.increaseCount();
}
if (elIt != null) {
while (elIt.hasNext()) {
elIt.next();
elIt.remove();
}
}
}
}
use of org.apache.maven.model.Repository in project bazel by bazelbuild.
the class MavenConnector method getMavenCentral.
public static Repository getMavenCentral() {
Repository repository = new Repository();
repository.setId("central");
repository.setName("default");
repository.setUrl(MAVEN_CENTRAL_URL);
return repository;
}
Aggregations