Skip to content

Commit

Permalink
refactor(bazel): eliminated BazelExternalId class
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Billings committed Oct 7, 2019
1 parent 6d0896d commit 7fb9b4d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 65 deletions.
Expand Up @@ -34,7 +34,6 @@
import com.synopsys.integration.bdio.model.externalid.ExternalId;
import com.synopsys.integration.bdio.model.externalid.ExternalIdFactory;
import com.synopsys.integration.detectable.detectable.codelocation.CodeLocation;
import com.synopsys.integration.detectable.detectables.bazel.model.BazelExternalId;

public class BazelCodeLocationBuilder {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
Expand All @@ -46,14 +45,14 @@ public BazelCodeLocationBuilder(final ExternalIdFactory externalIdFactory) {
dependencyGraph = new MutableMapDependencyGraph();
}

public BazelCodeLocationBuilder addDependency(final BazelExternalId bazelExternalId) {
public BazelCodeLocationBuilder addDependency(final String group, final String artifact, final String version) {
try {
logger.debug(String.format("Adding dependency from external id: %s", bazelExternalId));
final ExternalId externalId = externalIdFactory.createMavenExternalId(bazelExternalId.getGroup(), bazelExternalId.getArtifact(), bazelExternalId.getVersion());
final Dependency artifactDependency = new Dependency(bazelExternalId.getArtifact(), bazelExternalId.getVersion(), externalId);
logger.debug(String.format("Adding dependency from external id: %s:%s:%s", group, artifact, version));
final ExternalId externalId = externalIdFactory.createMavenExternalId(group, artifact, version);
final Dependency artifactDependency = new Dependency(artifact, version, externalId);
dependencyGraph.addChildToRoot(artifactDependency);
} catch (final Exception e) {
logger.error(String.format("Unable to parse group:artifact:version from %s", bazelExternalId));
logger.error(String.format("Unable to create dependency from %s:%s:%s", group, artifact, version));
}
return this;
}
Expand Down
Expand Up @@ -32,7 +32,6 @@
import com.synopsys.integration.detectable.Extraction;
import com.synopsys.integration.detectable.detectable.codelocation.CodeLocation;
import com.synopsys.integration.detectable.detectable.executable.ExecutableRunner;
import com.synopsys.integration.detectable.detectables.bazel.model.BazelExternalId;
import com.synopsys.integration.detectable.detectables.bazel.pipeline.WorkspaceRuleChooser;
import com.synopsys.integration.detectable.detectables.bazel.pipeline.Pipelines;
import com.synopsys.integration.detectable.detectables.bazel.pipeline.stepexecutor.BazelCommandExecutor;
Expand Down Expand Up @@ -70,9 +69,8 @@ public Extraction extract(final File bazelExe, final File workspaceDir, final Ba
}
// final pipelineData is a list of group:artifact:version strings
for (String artifactString : pipelineData) {
BazelExternalId externalId = BazelExternalId.fromBazelArtifactString(artifactString, ":");
logger.debug(String.format("Adding externalId: %s", externalId));
codeLocationGenerator.addDependency(externalId);
final String[] gavParts = artifactString.split(":");
codeLocationGenerator.addDependency(gavParts[0], gavParts[1], gavParts[2]);
}
final List<CodeLocation> codeLocations = codeLocationGenerator.build();
final String projectName = bazelProjectNameGenerator.generateFromBazelTarget(bazelTarget);
Expand Down

This file was deleted.

Expand Up @@ -9,7 +9,6 @@
import com.synopsys.integration.bdio.model.dependency.Dependency;
import com.synopsys.integration.bdio.model.externalid.ExternalIdFactory;
import com.synopsys.integration.detectable.detectable.codelocation.CodeLocation;
import com.synopsys.integration.detectable.detectables.bazel.model.BazelExternalId;
import com.synopsys.integration.detectable.detectables.bazel.BazelCodeLocationBuilder;

public class BazelCodeLocationBuilderTest {
Expand All @@ -18,7 +17,7 @@ public class BazelCodeLocationBuilderTest {
public void test() {
BazelCodeLocationBuilder bdioBuilder = new BazelCodeLocationBuilder(new ExternalIdFactory());
final List<CodeLocation> codeLocations = bdioBuilder
.addDependency(BazelExternalId.fromBazelArtifactString("testGroup:testArtifact:testVersion", ":"))
.addDependency("testGroup", "testArtifact", "testVersion")
.build();

assertEquals(1, codeLocations.size());
Expand Down

0 comments on commit 7fb9b4d

Please sign in to comment.