Search in sources :

Example 1 with JavaRunfilesProvider

use of com.google.devtools.build.lib.rules.java.JavaRunfilesProvider in project bazel by bazelbuild.

the class JavaProtoLibrary method create.

@Override
public ConfiguredTarget create(final RuleContext ruleContext) throws InterruptedException, RuleErrorException {
    JavaCompilationArgsProvider dependencyArgsProviders = JavaCompilationArgsProvider.merge(Iterables.<JavaCompilationArgsAspectProvider, JavaCompilationArgsProvider>transform(this.<JavaCompilationArgsAspectProvider>getDeps(ruleContext, JavaCompilationArgsAspectProvider.class), JavaCompilationArgsAspectProvider.GET_PROVIDER));
    if (!StrictDepsUtils.isStrictDepsJavaProtoLibrary(ruleContext)) {
        dependencyArgsProviders = StrictDepsUtils.makeNonStrict(dependencyArgsProviders);
    }
    Runfiles runfiles = new Runfiles.Builder(ruleContext.getWorkspaceName()).addArtifacts(dependencyArgsProviders.getRecursiveJavaCompilationArgs().getRuntimeJars()).build();
    JavaSourceJarsProvider sourceJarsProvider = JavaSourceJarsProvider.merge(Iterables.<JavaSourceJarsAspectProvider, JavaSourceJarsProvider>transform(this.<JavaSourceJarsAspectProvider>getDeps(ruleContext, JavaSourceJarsAspectProvider.class), JavaSourceJarsAspectProvider.GET_PROVIDER));
    NestedSetBuilder<Artifact> filesToBuild = NestedSetBuilder.stableOrder();
    filesToBuild.addAll(sourceJarsProvider.getSourceJars());
    for (JavaProtoLibraryTransitiveFilesToBuildProvider provider : ruleContext.getPrerequisites("deps", Mode.TARGET, JavaProtoLibraryTransitiveFilesToBuildProvider.class)) {
        filesToBuild.addTransitive(provider.getJars());
    }
    JavaRuleOutputJarsProvider ruleOutputJarsProvider = JavaRuleOutputJarsProvider.builder().build();
    JavaSkylarkApiProvider.Builder skylarkApiProvider = JavaSkylarkApiProvider.builder().setRuleOutputJarsProvider(ruleOutputJarsProvider).setSourceJarsProvider(sourceJarsProvider).setCompilationArgsProvider(dependencyArgsProviders);
    return new RuleConfiguredTargetBuilder(ruleContext).setFilesToBuild(filesToBuild.build()).addSkylarkTransitiveInfo(JavaSkylarkApiProvider.NAME, skylarkApiProvider.build()).addProvider(RunfilesProvider.class, RunfilesProvider.withData(Runfiles.EMPTY, runfiles)).addOutputGroup(OutputGroupProvider.DEFAULT, NestedSetBuilder.<Artifact>emptySet(STABLE_ORDER)).add(JavaCompilationArgsProvider.class, dependencyArgsProviders).add(JavaSourceJarsProvider.class, sourceJarsProvider).add(JavaRunfilesProvider.class, new JavaRunfilesProvider(runfiles)).add(JavaRuleOutputJarsProvider.class, ruleOutputJarsProvider).build();
}
Also used : JavaRuleOutputJarsProvider(com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider) JavaSourceJarsProvider(com.google.devtools.build.lib.rules.java.JavaSourceJarsProvider) JavaSkylarkApiProvider(com.google.devtools.build.lib.rules.java.JavaSkylarkApiProvider) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder) Artifact(com.google.devtools.build.lib.actions.Artifact) Runfiles(com.google.devtools.build.lib.analysis.Runfiles) JavaCompilationArgsProvider(com.google.devtools.build.lib.rules.java.JavaCompilationArgsProvider) RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder) JavaRunfilesProvider(com.google.devtools.build.lib.rules.java.JavaRunfilesProvider)

Example 2 with JavaRunfilesProvider

use of com.google.devtools.build.lib.rules.java.JavaRunfilesProvider in project bazel by bazelbuild.

the class JavaLiteProtoLibrary method create.

@Override
public ConfiguredTarget create(final RuleContext ruleContext) throws InterruptedException, RuleErrorException {
    JavaCompilationArgsProvider dependencyArgsProviders = JavaCompilationArgsProvider.merge(Iterables.<JavaCompilationArgsAspectProvider, JavaCompilationArgsProvider>transform(getDeps(ruleContext, JavaCompilationArgsAspectProvider.class), JavaCompilationArgsAspectProvider.GET_PROVIDER));
    if (!StrictDepsUtils.isStrictDepsJavaProtoLibrary(ruleContext)) {
        dependencyArgsProviders = StrictDepsUtils.makeNonStrict(dependencyArgsProviders);
    }
    Runfiles runfiles = new Runfiles.Builder(ruleContext.getWorkspaceName()).addArtifacts(dependencyArgsProviders.getRecursiveJavaCompilationArgs().getRuntimeJars()).build();
    JavaSourceJarsProvider sourceJarsProvider = JavaSourceJarsProvider.merge(Iterables.<JavaSourceJarsAspectProvider, JavaSourceJarsProvider>transform(getDeps(ruleContext, JavaSourceJarsAspectProvider.class), JavaSourceJarsAspectProvider.GET_PROVIDER));
    NestedSetBuilder<Artifact> filesToBuild = NestedSetBuilder.stableOrder();
    filesToBuild.addAll(sourceJarsProvider.getSourceJars());
    for (JavaProtoLibraryTransitiveFilesToBuildProvider provider : ruleContext.getPrerequisites("deps", Mode.TARGET, JavaProtoLibraryTransitiveFilesToBuildProvider.class)) {
        filesToBuild.addTransitive(provider.getJars());
    }
    JavaRuleOutputJarsProvider javaRuleOutputJarsProvider = JavaRuleOutputJarsProvider.builder().build();
    JavaSkylarkApiProvider.Builder skylarkApiProvider = JavaSkylarkApiProvider.builder().setRuleOutputJarsProvider(javaRuleOutputJarsProvider).setSourceJarsProvider(sourceJarsProvider).setCompilationArgsProvider(dependencyArgsProviders);
    return new RuleConfiguredTargetBuilder(ruleContext).setFilesToBuild(filesToBuild.build()).addSkylarkTransitiveInfo(JavaSkylarkApiProvider.NAME, skylarkApiProvider.build()).addProvider(RunfilesProvider.class, RunfilesProvider.withData(Runfiles.EMPTY, runfiles)).addOutputGroup(OutputGroupProvider.DEFAULT, NestedSetBuilder.<Artifact>emptySet(STABLE_ORDER)).add(JavaCompilationArgsProvider.class, dependencyArgsProviders).add(JavaSourceJarsProvider.class, sourceJarsProvider).add(JavaRunfilesProvider.class, new JavaRunfilesProvider(runfiles)).add(ProguardSpecProvider.class, getJavaLiteRuntimeSpec(ruleContext)).add(JavaRuleOutputJarsProvider.class, javaRuleOutputJarsProvider).build();
}
Also used : JavaRuleOutputJarsProvider(com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider) JavaSourceJarsProvider(com.google.devtools.build.lib.rules.java.JavaSourceJarsProvider) JavaSkylarkApiProvider(com.google.devtools.build.lib.rules.java.JavaSkylarkApiProvider) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder) RunfilesProvider(com.google.devtools.build.lib.analysis.RunfilesProvider) JavaRunfilesProvider(com.google.devtools.build.lib.rules.java.JavaRunfilesProvider) Artifact(com.google.devtools.build.lib.actions.Artifact) Runfiles(com.google.devtools.build.lib.analysis.Runfiles) JavaCompilationArgsProvider(com.google.devtools.build.lib.rules.java.JavaCompilationArgsProvider) RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder) JavaRunfilesProvider(com.google.devtools.build.lib.rules.java.JavaRunfilesProvider)

Aggregations

Artifact (com.google.devtools.build.lib.actions.Artifact)2 RuleConfiguredTargetBuilder (com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder)2 Runfiles (com.google.devtools.build.lib.analysis.Runfiles)2 NestedSetBuilder (com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)2 JavaCompilationArgsProvider (com.google.devtools.build.lib.rules.java.JavaCompilationArgsProvider)2 JavaRuleOutputJarsProvider (com.google.devtools.build.lib.rules.java.JavaRuleOutputJarsProvider)2 JavaRunfilesProvider (com.google.devtools.build.lib.rules.java.JavaRunfilesProvider)2 JavaSkylarkApiProvider (com.google.devtools.build.lib.rules.java.JavaSkylarkApiProvider)2 JavaSourceJarsProvider (com.google.devtools.build.lib.rules.java.JavaSourceJarsProvider)2 RunfilesProvider (com.google.devtools.build.lib.analysis.RunfilesProvider)1