use of com.google.cloud.tools.opensource.dependencies.Bom in project cloud-opensource-java by GoogleCloudPlatform.
the class LinkageCheckerTest method testBomHavingClassifierArtifacts.
@Test
public void testBomHavingClassifierArtifacts() throws Exception {
String pomFile = "bom-with-classifier-artifacts.pom";
Bom bom = Bom.readBom(TestHelper.absolutePathOfResource(pomFile));
LinkageChecker linkageChecker = LinkageChecker.create(bom);
ImmutableSet<LinkageProblem> linkageProblems = linkageChecker.findLinkageProblems();
// bom-with-classifier-artifacts contains com.google.cloud:google-cloud-core:jar:tests:1.96.0.
// This tests-classifier artifact requires Truth and JUnit dependencies to work, but it's not
// declared in its pom.xml (The user of the class needs to declare them because the tests-
// classifier artifacts are intended to be used in tests.) Therefore the linkage errors to the
// classes in the missing dependencies are expected.
Truth.assertThat(linkageProblems).comparingElementsUsing(Correspondence.transforming((LinkageProblem problem) -> problem.getSymbol().getClassBinaryName(), "has missing symbol")).containsAtLeast("com.google.common.testing.EqualsTester", "com.google.common.truth.Truth", "org.junit.Assert");
Truth.assertThat(linkageProblems).comparingElementsUsing(Correspondence.transforming((LinkageProblem problem) -> problem.getSourceClass().getClassPathEntry().getArtifact().toString(), "has source class belonging to artifact")).contains("com.google.cloud:google-cloud-core:jar:tests:1.96.0");
}
use of com.google.cloud.tools.opensource.dependencies.Bom in project java-cloud-bom by googleapis.
the class DashboardMain method main.
/**
* Generates a code hygiene dashboard for a BOM. This tool takes a path to pom.xml of the BOM as
* an argument or Maven coordinates to a BOM.
*
* <p>Generated dashboard is at {@code target/$groupId/$artifactId/$version/index.html}, where
* each value is from BOM coordinates except {@code $version} is "snapshot" if the BOM has
* snapshot version.
*/
public static void main(String[] arguments) throws IOException, TemplateException, RepositoryException, URISyntaxException, ParseException, MavenRepositoryException {
DashboardArguments dashboardArguments = DashboardArguments.readCommandLine(arguments);
// If looking to edit the dashboard structure, see DashboardMain#generateDashboard.
if (dashboardArguments.hasVersionlessCoordinates()) {
generateAllVersions(dashboardArguments.getVersionlessCoordinates());
return;
}
Bom bom;
if (dashboardArguments.hasFile()) {
Path bomFile = dashboardArguments.getBomFile();
checkArgument(Files.isRegularFile(bomFile), "The input BOM %s is not a regular file", bomFile);
checkArgument(Files.isReadable(bomFile), "The input BOM %s is not readable", bomFile);
bom = Bom.readBom(bomFile);
} else {
bom = Bom.readBom(dashboardArguments.getBomCoordinates());
}
if (dashboardArguments.getReport()) {
if (!report(bom, System.out)) {
throw new RuntimeException("Failed to converge dependencies");
}
} else {
generate(bom);
}
if (dashboardArguments.getOutputFile() != null) {
Path relativePath = dashboardArguments.getOutputFile();
Files.createDirectories(relativePath.getParent());
File file = new File(String.valueOf(relativePath));
OutputStream outputStream = new FileOutputStream(file);
if (!report(bom, outputStream)) {
throw new RuntimeException("Failed to converge dependencies");
}
outputStream.close();
}
}
use of com.google.cloud.tools.opensource.dependencies.Bom in project java-cloud-bom by googleapis.
the class BomContentTest method checkBom.
private void checkBom(Path bomPath) throws Exception {
Bom bom = Bom.readBom(bomPath);
List<Artifact> artifacts = bom.getManagedDependencies();
for (Artifact artifact : artifacts) {
assertReachable(buildMavenCentralUrl(artifact));
}
assertNoDowngradeRule(bom);
assertUniqueClasses(artifacts);
assertBomIsImported(bom);
}
use of com.google.cloud.tools.opensource.dependencies.Bom in project java-cloud-bom by googleapis.
the class BomContentTest method checkBomReachable.
private void checkBomReachable(Path bomPath) throws Exception {
Bom bom = Bom.readBom(bomPath);
List<Artifact> artifacts = bom.getManagedDependencies();
for (Artifact artifact : artifacts) {
assertReachable(buildMavenCentralUrl(artifact));
}
}
Aggregations