From c0993919fc9bbd615c2540684181f87ee94f413a Mon Sep 17 00:00:00 2001 From: Googler Date: Mon, 28 Sep 2015 14:53:42 +0000 Subject: Add Android aspect gen jars test. -- MOS_MIGRATED_REVID=104099744 --- .../lib/ideinfo/AndroidStudioInfoAspectTest.java | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src/test/java/com/google/devtools/build/lib') diff --git a/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java b/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java index aff6d9251b..2c5333e4dc 100644 --- a/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java +++ b/src/test/java/com/google/devtools/build/lib/ideinfo/AndroidStudioInfoAspectTest.java @@ -553,6 +553,51 @@ public class AndroidStudioInfoAspectTest extends BuildViewTestCase { "" + ""); } + + public void testJavaLibraryWithoutGeneratedSourcesHasNoGenJars() throws Exception { + scratch.file( + "java/com/google/example/BUILD", + "java_library(", + " name = 'no_plugin',", + " srcs = ['Test.java'],", + ")" + ); + String target = "//java/com/google/example:no_plugin"; + Map ruleIdeInfos = buildRuleIdeInfo(target); + RuleIdeInfo ruleIdeInfo = getRuleInfoAndVerifyLabel(target, ruleIdeInfos); + + assertThat(ruleIdeInfo.getJavaRuleIdeInfo().getGeneratedJarsList()) + .isEmpty(); + } + + public void testJavaLibraryWithGeneratedSourcesHasGenJars() throws Exception { + scratch.file( + "java/com/google/example/BUILD", + "java_library(", + " name = 'test',", + " plugins = [':plugin']", + ")", + "java_plugin(", + " name = 'plugin',", + " processor_class = 'com.google.example.Plugin',", + " deps = ['plugin_lib'],", + ")", + "java_library(", + " name = 'plugin_lib',", + " srcs = ['Plugin.java'],", + ")" + ); + String target = "//java/com/google/example:test"; + Map ruleIdeInfos = buildRuleIdeInfo(target); + RuleIdeInfo ruleIdeInfo = getRuleInfoAndVerifyLabel(target, ruleIdeInfos); + + assertThat( + transform(ruleIdeInfo.getJavaRuleIdeInfo().getGeneratedJarsList(), + LIBRARY_ARTIFACT_TO_STRING)) + .containsExactly( + "" + + ""); + } private Map buildRuleIdeInfo(String target) throws Exception { AnalysisResult analysisResult = -- cgit v1.2.3