@Test public void testBazelDependencyGenerationWithoutArtifactField() throws ProviderImplementationException { DependencySynonymFormatter formatter = compatibleDependencyFormatRegistry.getProviderImplementation( Maven2LayoutProvider.ALIAS, BazelDependencyFormatter.ALIAS); assertThat(formatter).as("Failed to look up dependency synonym formatter!").isNotNull(); MavenArtifactCoordinates coordinates = new MavenArtifactCoordinates() { @Override public String getArtifactId() { return "maven-snippet"; } }; String snippet = formatter.getDependencySnippet(coordinates); System.out.print(snippet); assertThat("maven_jar(\n name = \"maven-snippet\",\n)\n") .as("Failed to generate dependency!").isEqualTo(snippet); }
@Override public String getDependencySnippet(ArtifactCoordinates artifactCoordinates) { MavenArtifactCoordinates coordinates = (MavenArtifactCoordinates) artifactCoordinates; return "maven_jar(" +"\n"+" name ="+" " +"\""+coordinates.getArtifactId()+"\""+","+ (coordinates.getArtifactId() != null && coordinates.getGroupId() != null && coordinates.getVersion() != null ? "\n artifact = " + "\""+ coordinates.getGroupId()+":"+coordinates.getArtifactId()+":"+coordinates.getVersion()+"\""+",\n)\n": "\n)\n"); }
BazelDependencyFormatter implements DependencySynonymFormatter { @Override public String getDependencySnippet(ArtifactCoordinates artifactCoordinates) { MavenArtifactCoordinates coordinates = (MavenArtifactCoordinates) artifactCoordinates; return "maven_jar(" +"\n"+" name ="+" " +"\""+coordinates.getArtifactId()+"\""+","+ (coordinates.getArtifactId() != null && coordinates.getGroupId() != null && coordinates.getVersion() != null ? "\n artifact = " + "\""+ coordinates.getGroupId()+":"+coordinates.getArtifactId()+":"+coordinates.getVersion()+"\""+",\n)\n": "\n)\n"); } }
BazelDependencyFormatter implements DependencySynonymFormatter { @Override public String getDependencySnippet(ArtifactCoordinates artifactCoordinates) { MavenArtifactCoordinates coordinates = (MavenArtifactCoordinates) artifactCoordinates; return "maven_jar(" +"\n"+" name ="+" " +"\""+coordinates.getArtifactId()+"\""+","+ (coordinates.getArtifactId() != null && coordinates.getGroupId() != null && coordinates.getVersion() != null ? "\n artifact = " + "\""+ coordinates.getGroupId()+":"+coordinates.getArtifactId()+":"+coordinates.getVersion()+"\""+",\n)\n": "\n)\n"); }  }
BazelDependencyFormatter implements DependencySynonymFormatter { @Override public String getDependencySnippet(ArtifactCoordinates artifactCoordinates) { MavenArtifactCoordinates coordinates = (MavenArtifactCoordinates) artifactCoordinates; return "maven_jar(" +"\n"+" name ="+" " +"\""+coordinates.getArtifactId()+"\""+","+ (coordinates.getArtifactId() != null && coordinates.getGroupId() != null && coordinates.getVersion() != null ? "\n artifact = " + "\""+ coordinates.getGroupId()+":"+coordinates.getArtifactId()+":"+coordinates.getVersion()+"\""+",\n)\n": "\n)\n"); }  @PostConstruct @Override void register(); @Override String getLayout(); String getFormatAlias(); @Override String getDependencySnippet(ArtifactCoordinates artifactCoordinates); }
BazelDependencyFormatter implements DependencySynonymFormatter { @Override public String getDependencySnippet(ArtifactCoordinates artifactCoordinates) { MavenArtifactCoordinates coordinates = (MavenArtifactCoordinates) artifactCoordinates; return "maven_jar(" +"\n"+" name ="+" " +"\""+coordinates.getArtifactId()+"\""+","+ (coordinates.getArtifactId() != null && coordinates.getGroupId() != null && coordinates.getVersion() != null ? "\n artifact = " + "\""+ coordinates.getGroupId()+":"+coordinates.getArtifactId()+":"+coordinates.getVersion()+"\""+",\n)\n": "\n)\n"); }  @PostConstruct @Override void register(); @Override String getLayout(); String getFormatAlias(); @Override String getDependencySnippet(ArtifactCoordinates artifactCoordinates); static final String ALIAS; }