use of org.apache.maven.model.Dependency in project maven-plugins by apache.
the class DependencyConvergenceReport method toDependency.
/**
* Convert Artifact to Dependency
*
* @param artifact
* @return Dependency object
*/
private Dependency toDependency(Artifact artifact) {
Dependency dependency = new Dependency();
dependency.setGroupId(artifact.getGroupId());
dependency.setArtifactId(artifact.getArtifactId());
dependency.setVersion(artifact.getVersion());
dependency.setClassifier(artifact.getClassifier());
dependency.setScope(artifact.getScope());
return dependency;
}
use of org.apache.maven.model.Dependency in project maven-plugins by apache.
the class DefaultRepositoryAssembler method buildRemoteRepository.
public void buildRemoteRepository(File repositoryDirectory, RepositoryInfo repository, RepositoryBuilderConfigSource configSource) throws RepositoryAssemblyException {
MavenProject project = configSource.getProject();
ProjectBuildingRequest buildingRequest = configSource.getProjectBuildingRequest();
Iterable<ArtifactResult> result = null;
Collection<Dependency> dependencies = project.getDependencies();
if (dependencies == null) {
Logger logger = getLogger();
if (logger.isDebugEnabled()) {
logger.debug("dependency-artifact set for project: " + project.getId() + " is null. Skipping repository processing.");
}
return;
}
Collection<Dependency> managedDependencies = null;
if (project.getDependencyManagement() != null) {
managedDependencies = project.getDependencyManagement().getDependencies();
}
// Older Aether versions use an cache which can't be cleared. So can't delete repoDir and use it again.
// Instead create a temporary repository, delete it at end (should be in a finally-block)
File tempRepo = new File(repositoryDirectory.getParentFile(), repositoryDirectory.getName() + "_tmp");
buildingRequest = repositoryManager.setLocalRepositoryBasedir(buildingRequest, tempRepo);
try {
result = dependencyResolver.resolveDependencies(buildingRequest, dependencies, managedDependencies, null);
} catch (DependencyResolverException e) {
throw new RepositoryAssemblyException("Error resolving artifacts: " + e.getMessage(), e);
}
ArtifactFilter filter = buildRepositoryFilter(repository, project);
buildingRequest = repositoryManager.setLocalRepositoryBasedir(buildingRequest, repositoryDirectory);
Map<String, GroupVersionAlignment> groupVersionAlignments = createGroupVersionAlignments(repository.getGroupVersionAlignments());
assembleRepositoryArtifacts(buildingRequest, result, filter, groupVersionAlignments);
if (repository.isIncludeMetadata()) {
// assembleRepositoryMetadata( result, filter, centralRepository, targetRepository );
}
try {
FileUtils.deleteDirectory(tempRepo);
} catch (IOException e) {
// noop
}
}
use of org.apache.maven.model.Dependency in project maven-plugins by apache.
the class ShadeMojo method updateExcludesInDeps.
public boolean updateExcludesInDeps(MavenProject project, List<Dependency> dependencies, List<Dependency> transitiveDeps) throws DependencyGraphBuilderException {
DependencyNode node = dependencyGraphBuilder.buildDependencyGraph(project, null);
boolean modified = false;
for (DependencyNode n2 : node.getChildren()) {
for (DependencyNode n3 : n2.getChildren()) {
// check if it really isn't in the list of original dependencies. Maven
// prior to 2.0.8 may grab versions from transients instead of
// from the direct deps in which case they would be marked included
// instead of OMITTED_FOR_DUPLICATE
// also, if not promoting the transitives, level 2's would be included
boolean found = false;
for (Dependency dep : transitiveDeps) {
if (dep.getArtifactId().equals(n3.getArtifact().getArtifactId()) && dep.getGroupId().equals(n3.getArtifact().getGroupId()) && (dep.getType() == null || dep.getType().equals(n3.getArtifact().getType()))) {
found = true;
break;
}
}
if (!found) {
for (Dependency dep : dependencies) {
if (dep.getArtifactId().equals(n2.getArtifact().getArtifactId()) && dep.getGroupId().equals(n2.getArtifact().getGroupId()) && (dep.getType() == null || dep.getType().equals(n2.getArtifact().getType()))) {
Exclusion exclusion = new Exclusion();
exclusion.setArtifactId(n3.getArtifact().getArtifactId());
exclusion.setGroupId(n3.getArtifact().getGroupId());
dep.addExclusion(exclusion);
modified = true;
break;
}
}
}
}
}
return modified;
}
use of org.apache.maven.model.Dependency in project maven-plugins by apache.
the class WebappStructureTest method testDependencyAnalysisWithRemovedDependency.
public void testDependencyAnalysisWithRemovedDependency() {
final List<Dependency> dependencies = new ArrayList<Dependency>();
dependencies.add(createDependency("groupTest", "artifactTest", "1.0"));
final Dependency removedDependency = createDependency("groupTest", "removedDep", "5.2");
dependencies.add(removedDependency);
final WebappStructure cache = new WebappStructure(dependencies);
final List<Dependency> newDependencies = new ArrayList<Dependency>(dependencies);
newDependencies.remove(removedDependency);
final WebappStructure webappStructure = new WebappStructure(newDependencies, cache);
webappStructure.analyseDependencies(new WebappStructure.DependenciesAnalysisCallback() {
int count = 0;
public void unchangedDependency(Dependency dependency) {
if (count == 0) {
count++;
} else {
fail("Should have called unchanged dependency only once");
}
}
public void newDependency(Dependency dependency) {
fail("Should have failed to trigger this callback");
}
public void removedDependency(Dependency dependency) {
if (!removedDependency.equals(dependency)) {
fail("Called removed dependency with an unexpected dependency " + dependency);
}
}
public void updatedVersion(Dependency dependency, String previousVersion) {
fail("Should have failed to trigger this callback");
}
public void updatedScope(Dependency dependency, String previousScope) {
fail("Should have failed to trigger this callback");
}
public void updatedOptionalFlag(Dependency dependency, boolean previousOptional) {
fail("Should have failed to trigger this callback");
}
public void updatedUnknown(Dependency dependency, Dependency previousDep) {
fail("Should have failed to trigger this callback");
}
});
}
use of org.apache.maven.model.Dependency in project maven-plugins by apache.
the class WebappStructureTest method testRegisterForced.
public void testRegisterForced() {
final String path = "WEB-INF/web.xml";
final WebappStructure structure = new WebappStructure(new ArrayList<Dependency>());
assertFalse("New file should return false", structure.registerFileForced("overlay1", path));
assertEquals("overlay1", structure.getOwner(path));
}
Aggregations