Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First check if it is likely a valid descriptor before issue validation #2681

Merged
merged 1 commit into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ private Dependency createScopedDependency(ArtifactDescriptor descriptor, String
return dependency;
}

private boolean isValidMavenDescriptor(MavenDependencyDescriptor dependencyDescriptor) {
public static boolean isValidMavenDescriptor(MavenDependencyDescriptor dependencyDescriptor) {
if (dependencyDescriptor == null) {
return false;
}
//TODO we should make this configurable maybe on the tycho plugin level e.g.
// <plugin>
// <groupId>org.eclipse.tycho</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,23 +401,27 @@ public void injectDependenciesIntoMavenModel(MavenProject project, AbstractTycho
if (configuration.getP2MetadataHandling() == InjectP2MavenMetadataHandling.inject) {
descriptorMapping = resolverFactory::resolveDependencyDescriptor;
} else if (configuration.getP2MetadataHandling() == InjectP2MavenMetadataHandling.validate) {
descriptorMapping = descriptor -> {
MavenDependencyDescriptor result = resolverFactory.resolveDependencyDescriptor(descriptor);
if (result != null) {
try {
dependenciesResolver.resolveArtifact(project, context.getSession(), result.getGroupId(),
result.getArtifactId(), result.getVersion());
} catch (ArtifactResolutionException e) {
logger.warn("Mapping P2 > Maven Coordinates failed: " + e.getMessage());
}
}
return null;
};
descriptorMapping = descriptor -> resolveDescriptorWithValidation(project, logger, descriptor);
} else {
descriptorMapping = null;
}
MavenDependencyInjector.injectMavenDependencies(project, dependencyArtifacts, testDependencyArtifacts,
bundleReader, descriptorMapping, logger, repositorySystem, context.getSession().getSettings(),
buildPropertiesParser);
}

private MavenDependencyDescriptor resolveDescriptorWithValidation(MavenProject project, Logger logger,
ArtifactDescriptor descriptor) {
MavenDependencyDescriptor result = resolverFactory.resolveDependencyDescriptor(descriptor);
if (MavenDependencyInjector.isValidMavenDescriptor(result)) {
try {
dependenciesResolver.resolveArtifact(project, context.getSession(), result.getGroupId(),
result.getArtifactId(), result.getVersion());
} catch (ArtifactResolutionException e) {
logger.warn("Mapping P2 > Maven Coordinates failed: " + e.getMessage());
return null;
}
}
return result;
}
}