use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class SkylarkRepositoryIntegrationTest method testSkylarkSymlinkFileFromRepository.
@Test
public void testSkylarkSymlinkFileFromRepository() throws Exception {
scratch.file("/repo2/bar.txt", "filegroup(name='bar', srcs=['foo.txt'], path='foo')");
scratch.file("/repo2/BUILD");
scratch.file("/repo2/WORKSPACE");
scratch.file("def.bzl", "def _impl(repository_ctx):", " repository_ctx.symlink(Label('@repo2//:bar.txt'), 'BUILD')", " repository_ctx.file('foo.txt', 'foo')", "", "repo = repository_rule(", " implementation=_impl,", " local=True)");
scratch.file(rootDirectory.getRelative("BUILD").getPathString());
scratch.overwriteFile(rootDirectory.getRelative("WORKSPACE").getPathString(), new ImmutableList.Builder<String>().addAll(analysisMock.getWorkspaceContents(mockToolsConfig)).add("local_repository(name='repo2', path='/repo2')").add("load('//:def.bzl', 'repo')").add("repo(name='foo')").build());
invalidatePackages();
ConfiguredTarget target = getConfiguredTarget("@foo//:bar");
Object path = target.getTarget().getAssociatedRule().getAttributeContainer().getAttr("path");
assertThat(path).isEqualTo("foo");
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class SkylarkRepositoryIntegrationTest method testSkylarkRepositoryTemplate.
@Test
public void testSkylarkRepositoryTemplate() throws Exception {
scratch.file("/repo2/bar.txt", "filegroup(name='{target}', srcs=['foo.txt'], path='{path}')");
scratch.file("/repo2/BUILD");
scratch.file("/repo2/WORKSPACE");
scratch.file("def.bzl", "def _impl(repository_ctx):", " repository_ctx.template('BUILD', Label('@repo2//:bar.txt'), " + "{'{target}': 'bar', '{path}': 'foo'})", " repository_ctx.file('foo.txt', 'foo')", "", "repo = repository_rule(", " implementation=_impl,", " local=True)");
scratch.file(rootDirectory.getRelative("BUILD").getPathString());
scratch.overwriteFile(rootDirectory.getRelative("WORKSPACE").getPathString(), new ImmutableList.Builder<String>().addAll(analysisMock.getWorkspaceContents(mockToolsConfig)).add("local_repository(name='repo2', path='/repo2')").add("load('//:def.bzl', 'repo')").add("repo(name='foo')").build());
invalidatePackages();
ConfiguredTarget target = getConfiguredTarget("@foo//:bar");
Object path = target.getTarget().getAssociatedRule().getAttributeContainer().getAttr("path");
assertThat(path).isEqualTo("foo");
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class AarImportTest method testNativeLibsZipMakesItIntoApk.
@Test
public void testNativeLibsZipMakesItIntoApk() throws Exception {
scratch.file("java/com/google/android/hello/BUILD", "aar_import(", " name = 'my_aar',", " aar = 'my_aar.aar',", ")", "android_binary(", " name = 'my_app',", " srcs = ['HelloApp.java'],", " deps = [':my_aar'],", " manifest = 'AndroidManifest.xml',", ")");
ConfiguredTarget binary = getConfiguredTarget("//java/com/google/android/hello:my_app");
SpawnAction apkBuilderAction = (SpawnAction) actionsTestUtil().getActionForArtifactEndingWith(getFilesToBuild(binary), "my_app_unsigned.apk");
assertThat(Iterables.find(apkBuilderAction.getArguments(), Predicates.containsPattern("_aar/my_aar/native_libs.zip$"))).isNotEmpty();
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class AarImportTest method testClassesJarProvided.
@Test
public void testClassesJarProvided() throws Exception {
ConfiguredTarget aarImportTarget = getConfiguredTarget("//a:foo");
Iterable<OutputJar> outputJars = aarImportTarget.getProvider(JavaRuleOutputJarsProvider.class).getOutputJars();
assertThat(outputJars).hasSize(1);
Artifact classesJar = outputJars.iterator().next().getClassJar();
assertThat(classesJar.getFilename()).isEqualTo("classes_and_libs_merged.jar");
SpawnAction jarMergingAction = ((SpawnAction) getGeneratingAction(classesJar));
assertThat(jarMergingAction.getArguments()).contains("--dont_change_compression");
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class AarImportTest method testExportsPropagatesResources.
@Test
public void testExportsPropagatesResources() throws Exception {
FileConfiguredTarget appTarget = getFileConfiguredTarget("//java:app.apk");
Set<Artifact> artifacts = actionsTestUtil().artifactClosureOf(appTarget.getArtifact());
ConfiguredTarget bar = getConfiguredTarget("//a:bar");
Artifact barResources = ActionsTestUtil.getFirstArtifactEndingWith(artifacts, "_aar/unzipped/resources/bar");
assertThat(barResources).isNotNull();
assertThat(barResources.getArtifactOwner().getLabel()).isEqualTo(bar.getLabel());
ConfiguredTarget foo = getConfiguredTarget("//a:foo");
Artifact fooResources = ActionsTestUtil.getFirstArtifactEndingWith(artifacts, "_aar/unzipped/resources/foo");
assertThat(fooResources).isNotNull();
assertThat(fooResources.getArtifactOwner().getLabel()).isEqualTo(foo.getLabel());
}
Aggregations