• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BaseVariant类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.android.build.gradle.api.BaseVariant的典型用法代码示例。如果您正苦于以下问题:Java BaseVariant类的具体用法?Java BaseVariant怎么用?Java BaseVariant使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BaseVariant类属于com.android.build.gradle.api包,在下文中一共展示了BaseVariant类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getAndroidVariants

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
@SuppressWarnings("WeakerAccess")
public DomainObjectSet<? extends BaseVariant> getAndroidVariants() {
    if (projectType == null) {
        throw new IllegalStateException("No android plugin found");
    }

    switch (projectType) {
        case APP:
            return ((AppExtension)androidExtension).getApplicationVariants();
        case LIBRARY:
            return ((LibraryExtension)androidExtension).getLibraryVariants();
        case FEATURE:
            return ((FeatureExtension)androidExtension).getFeatureVariants();
        default:
            throw new IllegalStateException("Unexpected project type: " + projectType);
    }
}
 
开发者ID:freefair,项目名称:android-gradle-plugins,代码行数:18,代码来源:AndroidProjectPlugin.java


示例2: configureForVariant

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
@Override
protected void configureForVariant(final BaseVariant variant, FindBugs task) {
    task.setDescription("Run FindBugs analysis for " + variant.getName() + " classes");
    task.setSource(getAllJava(variant));
    task.dependsOn(variant.getJavaCompile());
    ConventionMapping taskMapping = task.getConventionMapping();
    taskMapping.map("classes", () -> {
        // the simple "classes = sourceSet.output" may lead to non-existing resources directory
        // being passed to FindBugs Ant task, resulting in an error

        List<String> generatedClasses = new LinkedList<>();

        variant.getJavaCompile().getSource().visit(fileVisitDetails -> {
            if (!fileVisitDetails.isDirectory() && fileVisitDetails.getPath().endsWith(".java") && fileVisitDetails.getFile().getAbsolutePath().startsWith(project.getBuildDir().getAbsolutePath())) {
                generatedClasses.add(fileVisitDetails.getPath().replace(".java", ""));
            }
        });

        return getOutput(variant)
                .filter(file -> generatedClasses.parallelStream().noneMatch(generatedClass -> file.getAbsolutePath().endsWith(generatedClass + ".class") || file.getAbsolutePath().contains(generatedClass + "$")));
    });
    taskMapping.map("classpath", () -> getCompileClasspath(variant));
}
 
开发者ID:freefair,项目名称:android-gradle-plugins,代码行数:24,代码来源:AndroidFindBugsPlugin.java


示例3: createResourcesTaskCreator

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
private static Action<BaseVariant> createResourcesTaskCreator(final Project project) {
    return new Action<BaseVariant>() {
        @Override
        public void execute(final BaseVariant variant) {
            ResourcesResGeneratingTask resourcesResGeneratingTask =
                    new ResourcesResGeneratingTask(project, variant);
            ResGeneratingTask.register(resourcesResGeneratingTask);

            MergeResourcesConfigurationTask.create(project, variant, resourcesResGeneratingTask);

            DependenciesJavaGeneratingTask dependenciesJavaGeneratingTask =
                    new DependenciesJavaGeneratingTask(project, variant);
            JavaGeneratingTask.register(dependenciesJavaGeneratingTask);

            ColorsJavaGeneratingTask colorsJavaGeneratingTask =
                    new ColorsJavaGeneratingTask(project, variant, resourcesResGeneratingTask);
            JavaGeneratingTask.register(colorsJavaGeneratingTask);
        }
    };
}
 
开发者ID:Leao,项目名称:CodeColors,代码行数:21,代码来源:CodeColorsPlugin.java


示例4: GeneratingTask

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
public GeneratingTask(Project project, BaseVariant variant, String baseName, String outputDirPath,
                      boolean incremental) {
    mProject = project;
    mVariant = variant;

    if (incremental) {
        mGradleTask = project.getTasks().create(generateName(variant, baseName), GradleIncrementalTask.class);
    } else {
        mGradleTask = project.getTasks().create(generateName(variant, baseName), GradleTask.class);
    }

    // Output directory.
    mGradleTask.setOutputDir(project.file(outputDirPath));

    // Set GeneratingTask to be called by task action.
    mGradleTask.setGeneratingTask(this);
}
 
开发者ID:Leao,项目名称:CodeColors,代码行数:18,代码来源:GeneratingTask.java


示例5: publishVariant

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
protected boolean publishVariant(BaseVariant variant) {
    if (variant instanceof TestVariant || variant instanceof UnitTestVariant) {
        return false;
    }

    return  getAndroidExtension().getDefaultPublishConfig().equals(variant.getName());
}
 
开发者ID:freefair,项目名称:android-gradle-plugins,代码行数:8,代码来源:AndroidProjectPlugin.java


示例6: getExtensionElementsCallable

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
@Override
protected Callable<Collection<?>> getExtensionElementsCallable() {
    return () -> {
        ArrayList<BaseVariant> objects = new ArrayList<>();
        objects.addAll(getAndroidVariants());
        objects.addAll(getTestVariants());
        objects.addAll(getUnitTestVariants());
        return objects;
    };
}
 
开发者ID:freefair,项目名称:android-gradle-plugins,代码行数:11,代码来源:VariantBasedCodeQualityPlugin.java


示例7: configureForVariants

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
private void configureForVariants(DomainObjectSet<? extends BaseVariant> variants) {
    variants.all(sourceSet -> {
        Task task = project.getTasks().create(getTaskName(sourceSet, getTaskBaseName(), null), getCastedTaskType());
        task.setGroup(JavaBasePlugin.VERIFICATION_GROUP);
        configureForVariant(sourceSet, (T)task);
    });
}
 
开发者ID:freefair,项目名称:android-gradle-plugins,代码行数:8,代码来源:VariantBasedCodeQualityPlugin.java


示例8: getOutput

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
/**
 * @see SourceSet#getOutput()
 */
protected FileCollection getOutput(AndroidSourceSet androidSourceSet) {
    Stream<BaseVariant> testVariants = Stream.concat(getTestVariants().stream(), getUnitTestVariants().stream());
    Stream<BaseVariant> variants = Stream.concat(getAndroidVariants().stream(), testVariants);

    FileTreeInternal[] sourceTrees = variants
            .filter(variant -> variant.getJavaCompile() != null)
            .filter(variant -> variant.getSourceSets().contains(androidSourceSet))
            .map(variant -> variant.getJavaCompile().getDestinationDir())
            .map(outputDir -> (FileTreeInternal) getProject().fileTree(outputDir))
            .toArray(FileTreeInternal[]::new);
    return new UnionFileTree(sourceTrees);
}
 
开发者ID:freefair,项目名称:android-gradle-plugins,代码行数:16,代码来源:SourceSetBasedCodeQualityPlugin.java


示例9: ColorsJavaGeneratingTask

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
public ColorsJavaGeneratingTask(Project project, BaseVariant variant,
                                ResourcesResGeneratingTask resourcesResGeneratingTask) {
    super(project, variant, NAME_BASE);

    // Depends on resources res generating task.
    addDependsOn(resourcesResGeneratingTask.getGradleTask());
    addInputFile(resourcesResGeneratingTask.getOutputDir());
}
 
开发者ID:Leao,项目名称:CodeColors,代码行数:9,代码来源:ColorsJavaGeneratingTask.java


示例10: create

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
public static MergeResourcesConfigurationTask create(Project project, BaseVariant variant,
                                                     ResourcesResGeneratingTask resourcesResGeneratingTask) {
    String name = String.format(NAME_BASE, AaptUtil.capitalize(variant.getName()));
    MergeResourcesConfigurationTask task = project.getTasks().create(name, MergeResourcesConfigurationTask.class);
    task.initialize(variant, resourcesResGeneratingTask);

    return task;
}
 
开发者ID:Leao,项目名称:CodeColors,代码行数:9,代码来源:MergeResourcesConfigurationTask.java


示例11: initialize

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
public void initialize(BaseVariant v, ResourcesResGeneratingTask resourcesResGeneratingTask) {
    mVariant = v;
    mVariant.getMergeResources().dependsOn(this);

    dependsOn(resourcesResGeneratingTask.getGradleTask());
    mResFiles = resourcesResGeneratingTask.getResFiles();
}
 
开发者ID:Leao,项目名称:CodeColors,代码行数:8,代码来源:MergeResourcesConfigurationTask.java


示例12: DependenciesJavaGeneratingTask

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
public DependenciesJavaGeneratingTask(Project project, BaseVariant variant) {
    super(project, variant, NAME_BASE);

    // Depends on merged resources.
    MergeResources mergeResourcesTask = variant.getMergeResources();
    addDependsOn(mergeResourcesTask);
    mMergeResourcesDir = mergeResourcesTask.getOutputDir();
    addInputFile(mMergeResourcesDir);
}
 
开发者ID:Leao,项目名称:CodeColors,代码行数:10,代码来源:DependenciesJavaGeneratingTask.java


示例13: createHensonNavigatorGenerationTask

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
public void createHensonNavigatorGenerationTask(BaseVariant variant) {
  if (hensonExtension == null || hensonExtension.getNavigatorPackageName() == null) {
    throw new InvalidParameterException(
        "The property 'henson.navigatorPackageName' must be defined in your build.gradle");
  }
  String hensonNavigatorPackageName = hensonExtension.getNavigatorPackageName();
  File destinationFolder =
      project.file(
          new File(project.getBuildDir(), "generated/source/navigator/" + variant.getName()));
  taskManager.createHensonNavigatorGenerationTask(
      variant, hensonNavigatorPackageName, destinationFolder);
  variant.addJavaSourceFoldersToModel(destinationFolder);
}
 
开发者ID:f2prateek,项目名称:dart,代码行数:14,代码来源:HensonManager.java


示例14: setup

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
private void setup(Project target, BaseVariant variant) {
    MergeResources mergeResourcesTask = variant.getMergeResources();
    String resizeTaskName = generateTaskName("resize", variant, "Drawables");
    HashMap<String, Object> args = new HashMap<>();
    args.put("type", ResizeDrawablesTask.class);
    args.put("description", "This task resizes current build variant drawables and saves them in project build directory");
    ResizeDrawablesTask resizeTask = (ResizeDrawablesTask) target.task(args, resizeTaskName);
    resizeTask.setBuildVariant(variant);
    mergeResourcesTask.dependsOn(resizeTask);
}
 
开发者ID:Forsety,项目名称:android-drawable-resizer,代码行数:11,代码来源:ADRPlugin.java


示例15: getJavadocTask

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
public Javadoc getJavadocTask(Project project, BaseVariant variant) {

        if (!javadocTasks.containsKey(variant.getName())) {

            Javadoc task = project.getTasks().create("javadoc" + capitalize((CharSequence) variant.getName()), Javadoc.class, javadoc -> {
                javadoc.setDescription("Generate Javadoc for the " + variant.getName() + " variant");
                javadoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);

                javadoc.dependsOn(variant.getJavaCompiler());

                if (variant.getJavaCompiler() instanceof JavaCompile) {
                    JavaCompile javacTask = (JavaCompile) variant.getJavaCompiler();

                    javadoc.setSource(javacTask.getSource());

                    javadoc.setClasspath(project.files(javacTask.getDestinationDir()).plus(javacTask.getClasspath()));
                    javadoc.getOptions().setSource(javacTask.getSourceCompatibility());
                } else {
                    getProject().getLogger().warn("Failed to configure {}. Unsupported Compiler: {}", javadoc.getName(), variant.getJavaCompiler().getClass().getName());
                }

                //javadoc.exclude '**/BuildConfig.java'
                javadoc.exclude("**/R.java");

                javadoc.getOptions().encoding("UTF-8");
                javadoc.getOptions().setBootClasspath(getAndroidExtension().getBootClasspath());

                if (javadoc.getOptions() instanceof StandardJavadocDocletOptions) {
                    StandardJavadocDocletOptions realOptions = (StandardJavadocDocletOptions) javadoc.getOptions();

                    realOptions.docEncoding("UTF-8");
                    realOptions.charSet("UTF-8");

                    Serializable javaVersion = GUtil.elvis(Jvm.current().getJavaVersion().getMajorVersion(), '8');
                    realOptions.links("http://docs.oracle.com/javase/" + javaVersion + "/docs/api/");
                    realOptions.linksOffline("http://developer.android.com/reference/", getAndroidExtension().getSdkDirectory() + "/docs/reference");
                }

                javadoc.setFailOnError(false);

                File docsDir;
                if (project.hasProperty("docsDir")) {
                    docsDir = (File) project.property("docsDir");
                } else {
                    docsDir = new File(project.getBuildDir(), "docs");
                }
                File javadocDir = new File(docsDir, "javadoc");
                javadoc.setDestinationDir(new File(javadocDir, variant.getDirName()));
            });

            javadocTasks.put(variant.getName(), task);
        }

        return javadocTasks.get(variant.getName());
    }
 
开发者ID:freefair,项目名称:android-gradle-plugins,代码行数:56,代码来源:AndroidJavadocPlugin.java


示例16: getVariants

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
public Collection<BaseVariant> getVariants() {
    return this.variants;
}
 
开发者ID:freefair,项目名称:android-gradle-plugins,代码行数:4,代码来源:VariantBasedCodeQualityExtension.java


示例17: setVariants

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
public void setVariants(Collection<BaseVariant> variants) {
    this.variants = variants;
}
 
开发者ID:freefair,项目名称:android-gradle-plugins,代码行数:4,代码来源:VariantBasedCodeQualityExtension.java


示例18: getOutput

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
/**
 * @see SourceSet#getOutput()
 */
protected FileTree getOutput(BaseVariant androidSourceSet) {
    return getProject().fileTree(androidSourceSet.getJavaCompile().getDestinationDir());
}
 
开发者ID:freefair,项目名称:android-gradle-plugins,代码行数:7,代码来源:VariantBasedCodeQualityPlugin.java


示例19: addVariant

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
@Override
public void addVariant(BaseVariant variant) {
    applicationVariantList.add((ApplicationVariant) variant);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:TestExtension.java


示例20: create

import com.android.build.gradle.api.BaseVariant; //导入依赖的package包/类
public void create(BaseVariantData<?> variantData) {
    if (variantData.getType().isForTesting()) {
        // Testing variants are handled together with their "owners".
        return;
    }

    BaseVariant variantApi =
            variantFactory.createVariantApi(variantData, readOnlyObjectProvider);

    if (variantFactory.hasTestScope()) {
        TestVariantData androidTestVariantData =
                ((TestedVariantData) variantData).getTestVariantData(ANDROID_TEST);

        if (androidTestVariantData != null) {
            TestVariantImpl androidTestVariant = instantiator.newInstance(
                    TestVariantImpl.class,
                    androidTestVariantData,
                    variantApi,
                    androidBuilder,
                    readOnlyObjectProvider);

            // add the test output.
            ApplicationVariantFactory.createApkOutputApiObjects(
                    instantiator,
                    androidTestVariantData,
                    androidTestVariant);

            ((TestedAndroidConfig) extension).getTestVariants().add(androidTestVariant);
            ((TestedVariant) variantApi).setTestVariant(androidTestVariant);
        }

        TestVariantData unitTestVariantData =
                ((TestedVariantData) variantData).getTestVariantData(UNIT_TEST);
        if (unitTestVariantData != null) {
            UnitTestVariantImpl unitTestVariant = instantiator.newInstance(
                    UnitTestVariantImpl.class,
                    unitTestVariantData,
                    variantApi,
                    androidBuilder,
                    readOnlyObjectProvider);

            ((TestedAndroidConfig) extension).getUnitTestVariants().add(unitTestVariant);
            ((TestedVariant) variantApi).setUnitTestVariant(unitTestVariant);
        }
    }

    // Only add the variant API object to the domain object set once it's been fully
    // initialized.
    extension.addVariant(variantApi);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:51,代码来源:ApiObjectFactory.java



注:本文中的com.android.build.gradle.api.BaseVariant类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MinecartUpdateEvent类代码示例发布时间:2022-05-22
下一篇:
Java FacetPage类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap