use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTest method testJavaTest.
@Test
public void testJavaTest() throws Exception {
scratch.file("java/com/google/example/BUILD", "java_library(", " name = 'foobar',", " srcs = ['FooBar.java'],", ")", "java_test(", " name = 'FooBarTest',", " srcs = ['FooBarTest.java'],", " size = 'large',", " deps = [':foobar'],", ")");
Map<String, TargetIdeInfo> targetIdeInfos = buildIdeInfo("//java/com/google/example:FooBarTest");
TargetIdeInfo testInfo = getTargetIdeInfoAndVerifyLabel("//java/com/google/example:FooBarTest", targetIdeInfos);
assertThat(testInfo.getKindString()).isEqualTo("java_test");
assertThat(relativePathsForJavaSourcesOf(testInfo)).containsExactly("java/com/google/example/FooBarTest.java");
assertThat(testInfo.getDependenciesList()).contains("//java/com/google/example:foobar");
assertThat(transform(testInfo.getJavaIdeInfo().getJarsList(), LIBRARY_ARTIFACT_TO_STRING)).containsExactly(jarString("java/com/google/example", "FooBarTest.jar", null, "FooBarTest-src.jar"));
assertThat(getIdeResolveFiles()).containsExactly("java/com/google/example/libfoobar.jar", "java/com/google/example/libfoobar-hjar.jar", "java/com/google/example/libfoobar-src.jar", "java/com/google/example/FooBarTest.jar", "java/com/google/example/FooBarTest-src.jar");
assertThat(testInfo.getJavaIdeInfo().getJdeps().getRelativePath()).isEqualTo("java/com/google/example/FooBarTest.jdeps");
assertThat(testInfo.getTestInfo().getSize()).isEqualTo("large");
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspect method createIdeBuildArtifact.
private AndroidStudioInfoFilesProvider createIdeBuildArtifact(ConfiguredTarget base, RuleContext ruleContext, DependenciesResult dependenciesResult, AndroidStudioInfoFilesProvider.Builder providerBuilder) {
Artifact ideInfoFile = derivedArtifact(base, ruleContext, ASWB_BUILD_SUFFIX);
Artifact ideInfoTextFile = derivedArtifact(base, ruleContext, ASWB_BUILD_TEXT_SUFFIX);
providerBuilder.ideInfoFilesBuilder().add(ideInfoFile);
providerBuilder.ideInfoTextFilesBuilder().add(ideInfoTextFile);
NestedSetBuilder<Artifact> ideResolveArtifacts = providerBuilder.ideResolveFilesBuilder();
TargetIdeInfo.Builder outputBuilder = TargetIdeInfo.newBuilder();
outputBuilder.setLabel(base.getLabel().toString());
outputBuilder.setBuildFileArtifactLocation(makeArtifactLocation(ruleContext.getRule().getPackage(), ruleContext.getLabel()));
outputBuilder.setKindString(ruleContext.getRule().getRuleClass());
// Java rules
JavaRuleOutputJarsProvider outputJarsProvider = JavaProvider.getProvider(JavaRuleOutputJarsProvider.class, base);
if (outputJarsProvider != null && !androidStudioInfoSemantics.suppressJavaRuleInfo(base)) {
JavaIdeInfo javaIdeInfo = makeJavaIdeInfo(base, ruleContext, outputJarsProvider, providerBuilder);
outputBuilder.setJavaIdeInfo(javaIdeInfo);
}
// C rules
if (isCppRule(base)) {
CppCompilationContext cppCompilationContext = base.getProvider(CppCompilationContext.class);
if (cppCompilationContext != null) {
CIdeInfo cIdeInfo = makeCIdeInfo(base, ruleContext, cppCompilationContext, ideResolveArtifacts);
outputBuilder.setCIdeInfo(cIdeInfo);
}
}
// CCToolchain rule
CcToolchainProvider ccToolchainProvider = base.getProvider(CcToolchainProvider.class);
if (ccToolchainProvider != null) {
CppConfiguration cppConfiguration = ccToolchainProvider.getCppConfiguration();
if (cppConfiguration != null) {
CToolchainIdeInfo cToolchainIdeInfo = makeCToolchainIdeInfo(ruleContext, cppConfiguration);
if (cToolchainIdeInfo != null) {
outputBuilder.setCToolchainIdeInfo(cToolchainIdeInfo);
}
}
}
// Android rules
AndroidIdeInfoProvider androidIdeInfoProvider = base.getProvider(AndroidIdeInfoProvider.class);
if (androidIdeInfoProvider != null) {
outputBuilder.setAndroidIdeInfo(makeAndroidIdeInfo(androidIdeInfoProvider, dependenciesResult, ideResolveArtifacts));
}
// Python rules
if (isPythonRule(base)) {
outputBuilder.setPyIdeInfo(makePyIdeInfo(base, ruleContext, ideResolveArtifacts));
}
// Test rules
if (TargetUtils.isTestRule(base.getTarget())) {
TestInfo.Builder builder = TestInfo.newBuilder();
String attr = NonconfigurableAttributeMapper.of(base.getTarget().getAssociatedRule()).get("size", Type.STRING);
if (attr != null) {
builder.setSize(attr);
}
outputBuilder.setTestInfo(builder);
}
// Java toolchain rule
JavaToolchainProvider javaToolchainProvider = base.getProvider(JavaToolchainProvider.class);
if (javaToolchainProvider != null) {
outputBuilder.setJavaToolchainIdeInfo(JavaToolchainIdeInfo.newBuilder().setSourceVersion(javaToolchainProvider.getSourceVersion()).setTargetVersion(javaToolchainProvider.getTargetVersion()));
}
androidStudioInfoSemantics.augmentRuleInfo(outputBuilder, base, ruleContext, ideResolveArtifacts);
AndroidStudioInfoFilesProvider provider = providerBuilder.build();
outputBuilder.addAllDependencies(transform(dependenciesResult.deps, LABEL_TO_STRING));
outputBuilder.addAllRuntimeDeps(transform(dependenciesResult.runtimeDeps, LABEL_TO_STRING));
outputBuilder.addAllTags(base.getTarget().getAssociatedRule().getRuleTags());
final TargetIdeInfo targetIdeInfo = outputBuilder.build();
ruleContext.registerAction(makeProtoWriteAction(ruleContext.getActionOwner(), targetIdeInfo, ideInfoFile));
ruleContext.registerAction(makeProtoTextWriteAction(ruleContext.getActionOwner(), targetIdeInfo, ideInfoTextFile));
return provider;
}
use of com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTestBase method getTargetIdeInfoAndVerifyLabel.
protected TargetIdeInfo getTargetIdeInfoAndVerifyLabel(String target, Map<String, TargetIdeInfo> ruleIdeInfos) {
TargetIdeInfo ruleIdeInfo = ruleIdeInfos.get(target);
assertThat(ruleIdeInfo).named(target).isNotNull();
assertThat(ruleIdeInfo.getLabel()).isEqualTo(target);
return ruleIdeInfo;
}
Aggregations