use of com.google.devtools.build.lib.rules.java.JavaGenJarsProvider in project bazel by bazelbuild.
the class AndroidStudioInfoAspect method makeJavaIdeInfo.
private JavaIdeInfo makeJavaIdeInfo(ConfiguredTarget base, RuleContext ruleContext, JavaRuleOutputJarsProvider outputJarsProvider, AndroidStudioInfoFilesProvider.Builder providerBuilder) {
NestedSetBuilder<Artifact> ideResolveArtifacts = providerBuilder.ideResolveFilesBuilder();
JavaIdeInfo.Builder builder = JavaIdeInfo.newBuilder();
List<Artifact> javaSources = Lists.newArrayList();
List<Artifact> generatedJavaSources = Lists.newArrayList();
List<Artifact> srcjars = Lists.newArrayList();
divideJavaSources(ruleContext, javaSources, generatedJavaSources, srcjars);
if (!javaSources.isEmpty()) {
Artifact packageManifest = derivedArtifact(base, ruleContext, ".manifest");
providerBuilder.ideInfoFilesBuilder().add(packageManifest);
ruleContext.registerAction(makePackageManifestAction(ruleContext, packageManifest, javaSources));
builder.setPackageManifest(makeArtifactLocation(packageManifest));
}
// This can be removed once android_resources is deleted
if (ruleContext.attributes().has("resources", BuildType.LABEL) && ruleContext.getRule().getRuleClass().startsWith("android_")) {
srcjars = ImmutableList.of();
}
if (!javaSources.isEmpty() && (!generatedJavaSources.isEmpty() || !srcjars.isEmpty())) {
Artifact filteredGenJar = derivedArtifact(base, ruleContext, "-filtered-gen.jar");
Artifact filteredGenSrcJar = derivedArtifact(base, ruleContext, "-filtered-gen-src.jar");
List<Artifact> jars = Lists.newArrayList();
List<Artifact> sourceJars = Lists.newArrayList();
for (OutputJar outputJar : outputJarsProvider.getOutputJars()) {
Artifact jar = outputJar.getIJar();
if (jar == null) {
jar = outputJar.getClassJar();
}
if (jar != null) {
jars.add(jar);
}
if (outputJar.getSrcJar() != null) {
sourceJars.add(outputJar.getSrcJar());
}
}
ruleContext.registerAction(makeFilteredJarAction(ruleContext, jars, sourceJars, generatedJavaSources, srcjars, filteredGenJar, filteredGenSrcJar));
ideResolveArtifacts.add(filteredGenJar);
ideResolveArtifacts.add(filteredGenSrcJar);
builder.setFilteredGenJar(makeLibraryArtifact(ideResolveArtifacts, filteredGenJar, null, filteredGenSrcJar));
}
collectJarsFromOutputJarsProvider(builder, ideResolveArtifacts, outputJarsProvider);
Artifact jdeps = outputJarsProvider.getJdeps();
if (jdeps != null) {
builder.setJdeps(makeArtifactLocation(jdeps));
}
JavaGenJarsProvider genJarsProvider = base.getProvider(JavaGenJarsProvider.class);
if (genJarsProvider != null) {
collectGenJars(builder, ideResolveArtifacts, genJarsProvider);
}
Collection<Artifact> sourceFiles = getSources(ruleContext);
for (Artifact sourceFile : sourceFiles) {
builder.addSources(makeArtifactLocation(sourceFile));
}
return builder.build();
}
use of com.google.devtools.build.lib.rules.java.JavaGenJarsProvider in project bazel by bazelbuild.
the class J2ObjcAspect method java.
private ConfiguredAspect java(ConfiguredTarget base, RuleContext ruleContext, AspectParameters parameters) throws InterruptedException {
JavaCompilationArgsProvider compilationArgsProvider = base.getProvider(JavaCompilationArgsProvider.class);
JavaSourceInfoProvider sourceInfoProvider = base.getProvider(JavaSourceInfoProvider.class);
JavaGenJarsProvider genJarProvider = base.getProvider(JavaGenJarsProvider.class);
ImmutableSet.Builder<Artifact> javaSourceFilesBuilder = ImmutableSet.builder();
ImmutableSet.Builder<Artifact> javaSourceJarsBuilder = ImmutableSet.builder();
if (sourceInfoProvider != null) {
javaSourceFilesBuilder.addAll(sourceInfoProvider.getSourceFiles());
javaSourceJarsBuilder.addAll(sourceInfoProvider.getSourceJars()).addAll(sourceInfoProvider.getSourceJarsForJarFiles());
}
if (genJarProvider != null && genJarProvider.getGenSourceJar() != null) {
javaSourceJarsBuilder.add(genJarProvider.getGenSourceJar());
}
ImmutableSet<Artifact> javaSourceFiles = javaSourceFilesBuilder.build();
ImmutableSet<Artifact> javaSourceJars = javaSourceJarsBuilder.build();
J2ObjcSource j2ObjcSource = javaJ2ObjcSource(ruleContext, javaSourceFiles, javaSourceJars);
J2ObjcMappingFileProvider depJ2ObjcMappingFileProvider = depJ2ObjcMappingFileProvider(ruleContext);
J2ObjcMappingFileProvider directJ2ObjcMappingFileProvider;
if (Iterables.isEmpty(j2ObjcSource.getObjcSrcs())) {
directJ2ObjcMappingFileProvider = new J2ObjcMappingFileProvider.Builder().build();
} else {
directJ2ObjcMappingFileProvider = createJ2ObjcTranspilationAction(ruleContext, javaSourceFiles, javaSourceJars, depJ2ObjcMappingFileProvider, compilationArgsProvider, j2ObjcSource);
}
return buildAspect(base, ruleContext, parameters, j2ObjcSource, directJ2ObjcMappingFileProvider, JAVA_DEPENDENT_ATTRIBUTES);
}
Aggregations