use of com.synopsys.integration.detectable.detectables.bazel.pipeline.step.BazelVariableSubstitutor in project synopsys-detect by blackducksoftware.
the class DetectableFactory method bazelExtractor.
// #endregion
// #region Utility
private BazelExtractor bazelExtractor(BazelDetectableOptions bazelDetectableOptions) {
WorkspaceRuleChooser workspaceRuleChooser = new WorkspaceRuleChooser();
BazelWorkspaceFileParser bazelWorkspaceFileParser = new BazelWorkspaceFileParser();
HaskellCabalLibraryJsonProtoParser haskellCabalLibraryJsonProtoParser = new HaskellCabalLibraryJsonProtoParser(gson);
BazelVariableSubstitutor bazelVariableSubstitutor = new BazelVariableSubstitutor(bazelDetectableOptions.getTargetName().orElse(null), bazelDetectableOptions.getBazelCqueryAdditionalOptions());
BazelProjectNameGenerator bazelProjectNameGenerator = new BazelProjectNameGenerator();
return new BazelExtractor(executableRunner, externalIdFactory, bazelWorkspaceFileParser, workspaceRuleChooser, toolVersionLogger, haskellCabalLibraryJsonProtoParser, bazelDetectableOptions.getTargetName().orElse(null), bazelDetectableOptions.getWorkspaceRulesFromProperty(), bazelVariableSubstitutor, bazelProjectNameGenerator);
}
use of com.synopsys.integration.detectable.detectables.bazel.pipeline.step.BazelVariableSubstitutor in project synopsys-detect by blackducksoftware.
the class BazelVariableSubstitutorTest method testTargetOnly.
@Test
public void testTargetOnly() {
BazelVariableSubstitutor substitutor = new BazelVariableSubstitutor("//foo:foolib", new ArrayList<>(0));
List<String> origArgs = new ArrayList<>();
origArgs.add("query");
origArgs.add("filter(\"@.*:jar\", deps(${detect.bazel.target}))");
List<String> adjustedArgs = substitutor.substitute(origArgs, null);
assertEquals(2, adjustedArgs.size());
assertEquals("query", adjustedArgs.get(0));
assertEquals("filter(\"@.*:jar\", deps(//foo:foolib))", adjustedArgs.get(1));
}
use of com.synopsys.integration.detectable.detectables.bazel.pipeline.step.BazelVariableSubstitutor in project synopsys-detect by blackducksoftware.
the class BazelVariableSubstitutorTest method testInput.
@Test
public void testInput() {
BazelVariableSubstitutor substitutor = new BazelVariableSubstitutor("//foo:foolib", null);
List<String> origArgs = new ArrayList<>();
origArgs.add("query");
origArgs.add("filter(\"@.*:jar\", deps(${detect.bazel.target}))");
origArgs.add("kind(maven_jar, ${input.item})");
List<String> adjustedArgs = substitutor.substitute(origArgs, "//external:org_apache_commons_commons_io");
assertEquals(3, adjustedArgs.size());
assertEquals("query", adjustedArgs.get(0));
assertEquals("filter(\"@.*:jar\", deps(//foo:foolib))", adjustedArgs.get(1));
assertEquals("kind(maven_jar, //external:org_apache_commons_commons_io)", adjustedArgs.get(2));
}
use of com.synopsys.integration.detectable.detectables.bazel.pipeline.step.BazelVariableSubstitutor in project synopsys-detect by blackducksoftware.
the class BazelVariableSubstitutorTest method testListInsertion.
@Test
public void testListInsertion() {
BazelVariableSubstitutor substitutor = new BazelVariableSubstitutor("//foo:foolib", Arrays.asList("--define=a=b", "--define=c=d"));
List<String> origArgs = new ArrayList<>();
origArgs.add("cquery");
origArgs.add("${detect.bazel.cquery.options}");
origArgs.add("filter(\"@.*:jar\", deps(${detect.bazel.target}))");
origArgs.add("kind(maven_jar, ${input.item})");
List<String> adjustedArgs = substitutor.substitute(origArgs, "//external:org_apache_commons_commons_io");
assertEquals(5, adjustedArgs.size());
assertEquals("cquery", adjustedArgs.get(0));
assertEquals("--define=a=b", adjustedArgs.get(1));
assertEquals("--define=c=d", adjustedArgs.get(2));
assertEquals("filter(\"@.*:jar\", deps(//foo:foolib))", adjustedArgs.get(3));
assertEquals("kind(maven_jar, //external:org_apache_commons_commons_io)", adjustedArgs.get(4));
}
use of com.synopsys.integration.detectable.detectables.bazel.pipeline.step.BazelVariableSubstitutor in project synopsys-detect by blackducksoftware.
the class PipelinesTest method doTest.
private List<Dependency> doTest(WorkspaceRule workspaceRule, List<String> expectedBazelCommandArgs, List<String> userProvidedCqueryAdditionalOptions, String input) throws IntegrationException, ExecutableFailedException {
BazelCommandExecutor bazelCommandExecutor = Mockito.mock(BazelCommandExecutor.class);
Mockito.when(bazelCommandExecutor.executeToString(expectedBazelCommandArgs)).thenReturn(Optional.of(input));
BazelVariableSubstitutor bazelVariableSubstitutor = new BazelVariableSubstitutor("/:testTarget", userProvidedCqueryAdditionalOptions);
ExternalIdFactory externalIdFactory = new ExternalIdFactory();
HaskellCabalLibraryJsonProtoParser haskellCabalLibraryJsonProtoParser = new HaskellCabalLibraryJsonProtoParser(new Gson());
Pipelines pipelines = new Pipelines(bazelCommandExecutor, bazelVariableSubstitutor, externalIdFactory, haskellCabalLibraryJsonProtoParser);
Pipeline pipeline = pipelines.get(workspaceRule);
return pipeline.run();
}
Aggregations