类org.gradle.api.tasks.compile.AbstractCompile源码实例Demo

下面列出了怎么用org.gradle.api.tasks.compile.AbstractCompile的API类实例代码及写法,或者点击链接到github查看源代码。

private List<String> buildCompilerArgs(JavaCompile javaCompile) {
    var patchModuleContainer = PatchModuleContainer.copyOf(
            helper().modularityExtension().optionContainer().getPatchModuleContainer());
    String moduleName = helper().moduleName();
    new MergeClassesHelper(project).otherCompileTaskStream()
            .map(AbstractCompile::getDestinationDir)
            .forEach(dir -> patchModuleContainer.addDir(moduleName, dir.getAbsolutePath()));

    var compilerArgs = new ArrayList<>(javaCompile.getOptions().getCompilerArgs());
    patchModuleContainer.buildModulePathOption(compileJavaClasspath)
            .ifPresent(option -> option.mutateArgs(compilerArgs));
    patchModuleContainer.mutator(compileJavaClasspath).mutateArgs(compilerArgs);

    moduleOptions.mutateArgs(compilerArgs);
    MutatorHelper.configureModuleVersion(helper(), compilerArgs);

    return compilerArgs;
}
 
/**
 * Preconfigures the specified compile task based on the specified source set and class directory binary.
 *
 * @param compile the compile task to be preconfigured
 * @param sourceSet the source set for the compile task
 * @param binary the binary for the compile task
 */
public void configureCompileTask(AbstractCompile compile, final JavaSourceSet sourceSet, final ClassDirectoryBinarySpec binary) {
    compile.setDescription(String.format("Compiles %s.", sourceSet));
    compile.setSource(sourceSet.getSource());
    compile.dependsOn(sourceSet);
    ConventionMapping conventionMapping = compile.getConventionMapping();
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath().getFiles();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return binary.getClassesDir();
        }
    });
}
 
源代码3 项目: pushfish-android   文件: JavaBasePlugin.java
public void configureForSourceSet(final SourceSet sourceSet, AbstractCompile compile) {
    ConventionMapping conventionMapping;
    compile.setDescription(String.format("Compiles the %s.", sourceSet.getJava()));
    conventionMapping = compile.getConventionMapping();
    compile.setSource(sourceSet.getJava());
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getOutput().getClassesDir();
        }
    });
}
 
源代码4 项目: pushfish-android   文件: JavaLanguagePlugin.java
/**
 * Preconfigures the specified compile task based on the specified source set and class directory binary.
 *
 * @param compile the compile task to be preconfigured
 * @param sourceSet the source set for the compile task
 * @param binary the binary for the compile task
 */
public void configureCompileTask(AbstractCompile compile, final JavaSourceSet sourceSet, final ClassDirectoryBinary binary) {
    compile.setDescription(String.format("Compiles %s.", sourceSet));
    compile.setSource(sourceSet.getSource());
    compile.dependsOn(sourceSet);
    ConventionMapping conventionMapping = compile.getConventionMapping();
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath().getFiles();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return binary.getClassesDir();
        }
    });
}
 
源代码5 项目: pushfish-android   文件: JavaBasePlugin.java
public void configureForSourceSet(final SourceSet sourceSet, AbstractCompile compile) {
    ConventionMapping conventionMapping;
    compile.setDescription(String.format("Compiles the %s.", sourceSet.getJava()));
    conventionMapping = compile.getConventionMapping();
    compile.setSource(sourceSet.getJava());
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getOutput().getClassesDir();
        }
    });
}
 
源代码6 项目: javaide   文件: JavaBasePlugin.java
public void configureForSourceSet(final SourceSet sourceSet, AbstractCompile compile) {
    ConventionMapping conventionMapping;
    compile.setDescription("Compiles the " + sourceSet.getJava() + ".");
    conventionMapping = compile.getConventionMapping();
    compile.setSource(sourceSet.getJava());
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getOutput().getClassesDir();
        }
    });
}
 
源代码7 项目: javaide   文件: TaskManager.java
/**
 * Makes the given task the one used by top-level "compile" task.
 */
public static void setJavaCompilerTask(
        @NonNull AndroidTask<? extends AbstractCompile> javaCompilerTask,
        @NonNull TaskFactory tasks,
        @NonNull VariantScope scope) {
    scope.getCompileTask().dependsOn(tasks, javaCompilerTask);
    scope.setJavaCompilerTask(javaCompilerTask);

    // TODO: Get rid of it once we stop keeping tasks in variant data.
    //noinspection VariableNotUsedInsideIf
    if (scope.getVariantData().javacTask != null) {
        // This is not the experimental plugin, let's update variant data, so Variants API
        // keeps working.
        scope.getVariantData().javaCompilerTask = (AbstractCompile) tasks.named(javaCompilerTask.getName());
    }

}
 
源代码8 项目: gradle-plugins   文件: AjcAction.java
private AspectJCompileSpec createSpec(AbstractCompile compile) {
    AspectJCompileSpec spec = new AspectJCompileSpec();

    spec.setDestinationDir(compile.getDestinationDir());
    spec.setWorkingDir(compile.getProject().getProjectDir());
    spec.setTempDir(compile.getTemporaryDir());
    spec.setCompileClasspath(new ArrayList<>(compile.getClasspath().filter(File::exists).getFiles()));
    spec.setTargetCompatibility(compile.getTargetCompatibility());
    spec.setSourceCompatibility(compile.getSourceCompatibility());

    spec.setAspectJClasspath(getClasspath());
    spec.setAspectJCompileOptions(getOptions());
    spec.setAdditionalInpath(getAdditionalInpath());

    return spec;
}
 
源代码9 项目: gradle-plugins   文件: AjcAction.java
private AspectJCompileSpec createSpec(AbstractCompile compile) {
    AspectJCompileSpec spec = new AspectJCompileSpec();

    spec.setDestinationDir(compile.getDestinationDir());
    spec.setWorkingDir(compile.getProject().getProjectDir());
    spec.setTempDir(compile.getTemporaryDir());
    spec.setCompileClasspath(new ArrayList<>(compile.getClasspath().filter(File::exists).getFiles()));
    spec.setTargetCompatibility(compile.getTargetCompatibility());
    spec.setSourceCompatibility(compile.getSourceCompatibility());

    spec.setAspectJClasspath(getClasspath());
    spec.setAspectJCompileOptions(getOptions());
    spec.setAdditionalInpath(getAdditionalInpath());

    return spec;
}
 
/**
 * Preconfigures the specified compile task based on the specified source set and class directory binary.
 *
 * @param compile the compile task to be preconfigured
 * @param sourceSet the source set for the compile task
 * @param binary the binary for the compile task
 */
public void configureCompileTask(AbstractCompile compile, final JavaSourceSet sourceSet, final ClassDirectoryBinarySpec binary) {
    compile.setDescription(String.format("Compiles %s.", sourceSet));
    compile.setSource(sourceSet.getSource());
    compile.dependsOn(sourceSet);
    ConventionMapping conventionMapping = compile.getConventionMapping();
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath().getFiles();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return binary.getClassesDir();
        }
    });
}
 
源代码11 项目: Pushjet-Android   文件: JavaBasePlugin.java
public void configureForSourceSet(final SourceSet sourceSet, AbstractCompile compile) {
    ConventionMapping conventionMapping;
    compile.setDescription(String.format("Compiles the %s.", sourceSet.getJava()));
    conventionMapping = compile.getConventionMapping();
    compile.setSource(sourceSet.getJava());
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getOutput().getClassesDir();
        }
    });
}
 
源代码12 项目: Pushjet-Android   文件: JavaLanguagePlugin.java
/**
 * Preconfigures the specified compile task based on the specified source set and class directory binary.
 *
 * @param compile the compile task to be preconfigured
 * @param sourceSet the source set for the compile task
 * @param binary the binary for the compile task
 */
public void configureCompileTask(AbstractCompile compile, final JavaSourceSet sourceSet, final ClassDirectoryBinary binary) {
    compile.setDescription(String.format("Compiles %s.", sourceSet));
    compile.setSource(sourceSet.getSource());
    compile.dependsOn(sourceSet);
    ConventionMapping conventionMapping = compile.getConventionMapping();
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath().getFiles();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return binary.getClassesDir();
        }
    });
}
 
源代码13 项目: Pushjet-Android   文件: JavaBasePlugin.java
public void configureForSourceSet(final SourceSet sourceSet, AbstractCompile compile) {
    ConventionMapping conventionMapping;
    compile.setDescription(String.format("Compiles the %s.", sourceSet.getJava()));
    conventionMapping = compile.getConventionMapping();
    compile.setSource(sourceSet.getJava());
    conventionMapping.map("classpath", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getCompileClasspath();
        }
    });
    conventionMapping.map("destinationDir", new Callable<Object>() {
        public Object call() throws Exception {
            return sourceSet.getOutput().getClassesDir();
        }
    });
}
 
源代码14 项目: gradle-modules-plugin   文件: MergeClassesHelper.java
public FileCollection getMergeAdjustedClasspath(FileCollection classpath) {
    if (!isMergeRequired()) {
        return classpath;
    }

    Set<File> files = new HashSet<>(classpath.getFiles());
    allCompileTaskStream().map(AbstractCompile::getDestinationDir).forEach(files::remove);
    files.add(helper().getMergedDir());
    return project.files(files.toArray());
}
 
源代码15 项目: gradle-modules-plugin   文件: CompileTask.java
private void configureCompileJava(JavaCompile compileJava) {
    project.getConfigurations().stream()
            .flatMap(configuration -> configuration.getDependencies().stream())
            .filter(dependency -> dependency instanceof ProjectDependency)
            .map(dependency -> ((ProjectDependency) dependency).getDependencyProject().getTasks())
            .map(tasks -> tasks.findByName(CompileModuleOptions.COMPILE_MODULE_INFO_TASK_NAME))
            .filter(Objects::nonNull);



    var moduleOptions = compileJava.getExtensions().create("moduleOptions", CompileModuleOptions.class, project);
    project.afterEvaluate(p -> {
        adjustMainClass(compileJava);

        MergeClassesHelper.POST_JAVA_COMPILE_TASK_NAMES.stream()
                .map(name -> helper().findTask(name, AbstractCompile.class))
                .flatMap(Optional::stream)
                .filter(task -> !task.getSource().isEmpty())
                .findAny()
                .ifPresent(task -> moduleOptions.setCompileModuleInfoSeparately(true));

        if (moduleOptions.getCompileModuleInfoSeparately()) {
            compileJava.exclude("module-info.java");
        } else {
            configureModularityForCompileJava(compileJava, moduleOptions);
        }
    });
}
 
源代码16 项目: javaide   文件: AbstractCompilesUtil.java
/**
 * Determines the java language level to use and sets it on the given task and
 * {@link CompileOptions}. The latter is to propagate the information to Studio.
 */
public static void configureLanguageLevel(
        AbstractCompile compileTask,
        final CompileOptions compileOptions,
        String compileSdkVersion) {
    final AndroidVersion hash = AndroidTargetHash.getVersionFromHash(compileSdkVersion);
    Integer compileSdkLevel = (hash == null ? null : hash.getApiLevel());

    JavaVersion javaVersionToUse;
    if (compileSdkLevel == null || (0 <= compileSdkLevel && compileSdkLevel <= 20)) {
        javaVersionToUse = JavaVersion.VERSION_1_6;
    } else {
        javaVersionToUse = JavaVersion.VERSION_1_7;
    }

    JavaVersion jdkVersion =
            JavaVersion.toVersion(System.getProperty("java.specification.version"));
    if (jdkVersion.compareTo(javaVersionToUse) < 0) {
        compileTask.getLogger().warn(
                "Default language level for compileSdkVersion '{}' is " +
                        "{}, but the JDK used is {}, so the JDK language level will be used.",
                compileSdkVersion,
                javaVersionToUse,
                jdkVersion);
        javaVersionToUse = jdkVersion;
    }

    compileOptions.setDefaultJavaVersion(javaVersionToUse);

    compileTask.setSourceCompatibility(compileOptions.getSourceCompatibility().toString());
    compileTask.setTargetCompatibility(compileOptions.getTargetCompatibility().toString());
}
 
源代码17 项目: gradle-plugins   文件: AjcAction.java
@Override
public void execute(Task task) {
    if (!enabled.getOrElse(true)) {
        return;
    }

    AspectJCompileSpec spec = createSpec((AbstractCompile) task);

    new AspectJCompiler(javaExecHandleFactory).execute(spec);
}
 
private AjcAction enhanceWithWeavingAction(AbstractCompile abstractCompile, Configuration aspectpath, Configuration inpath, Configuration aspectjConfiguration) {
    AjcAction action = project.getObjects().newInstance(AjcAction.class);

    action.getOptions().getAspectpath().from(aspectpath);
    action.getOptions().getInpath().from(inpath);
    action.getAdditionalInpath().from(abstractCompile.getDestinationDir());
    action.getClasspath().from(aspectjConfiguration);

    action.addToTask(abstractCompile);

    return action;
}
 
源代码19 项目: gradle-plugins   文件: AjcAction.java
@Override
public void execute(Task task) {
    if (!enabled.getOrElse(true)) {
        return;
    }

    AspectJCompileSpec spec = createSpec((AbstractCompile) task);

    new AspectJCompiler(javaExecHandleFactory).execute(spec);
}
 
private AjcAction enhanceWithWeavingAction(AbstractCompile abstractCompile, Configuration aspectpath, Configuration inpath, Configuration aspectjConfiguration) {
    AjcAction action = project.getObjects().newInstance(AjcAction.class);

    action.getOptions().getAspectpath().from(aspectpath);
    action.getOptions().getInpath().from(inpath);
    action.getAdditionalInpath().from(abstractCompile.getDestinationDir());
    action.getClasspath().from(aspectjConfiguration);

    action.addToTask(abstractCompile);

    return action;
}
 
源代码21 项目: byte-buddy   文件: PostCompilationAction.java
/**
 * {@inheritDoc}
 */
public void execute(AbstractCompile task) {
    if (byteBuddyExtension.implies(task)) {
        task.doLast(new TransformationAction(project, byteBuddyExtension, task));
    } else {
        project.getLogger().info("Skipping non-specified task {}", task.getName());
    }
}
 
源代码22 项目: gradle-modules-plugin   文件: MergeClassesHelper.java
public Stream<AbstractCompile> otherCompileTaskStream() {
    return otherCompileTaskNameStream()
            .map(name -> helper().findTask(name, AbstractCompile.class))
            .flatMap(Optional::stream);
}
 
源代码23 项目: gradle-modules-plugin   文件: MergeClassesHelper.java
public Stream<AbstractCompile> allCompileTaskStream() {
    return Stream.concat(Stream.of(javaCompileTask()), otherCompileTaskStream());
}
 
源代码24 项目: javaide   文件: BaseVariantImpl.java
@NonNull
@Override
public AbstractCompile getJavaCompiler() {
    return getVariantData().javaCompilerTask;
}
 
源代码25 项目: javaide   文件: VariantScope.java
@Nullable
public AndroidTask<? extends AbstractCompile> getJavaCompilerTask() {
    return javaCompilerTask;
}
 
源代码26 项目: javaide   文件: VariantScope.java
public void setJavaCompilerTask(
        @NonNull AndroidTask<? extends AbstractCompile> javaCompileTask) {
    this.javaCompilerTask = javaCompileTask;
}
 
源代码27 项目: byte-buddy   文件: ByteBuddyPlugin.java
/**
 * {@inheritDoc}
 */
public void apply(Project project) {
    project.getTasks().withType(AbstractCompile.class, PostCompilationAction.of(project));
}
 
源代码28 项目: javaide   文件: BaseVariant.java
/**
 * Returns the Java Compiler task which can be either javac or jack depending on the project
 * configuration.
 */
@NonNull
AbstractCompile getJavaCompiler();
 
源代码29 项目: byte-buddy   文件: PostCompilationAction.java
/**
 * Creates a post compilation action.
 *
 * @param project The project to apply the action upon.
 * @return An appropriate action.
 */
public static Action<AbstractCompile> of(Project project) {
    return new PostCompilationAction(project, project.getExtensions().create("byteBuddy", ByteBuddyExtension.class, project));
}
 
源代码30 项目: byte-buddy   文件: TransformationAction.java
/**
 * Creates a new transformation action.
 *
 * @param project   The current project.
 * @param extension The current project's Byte Buddy extension.
 * @param task      The task to which this transformation was appended.
 */
public TransformationAction(Project project, ByteBuddyExtension extension, AbstractCompile task) {
    this.project = project;
    this.byteBuddyExtension = extension;
    this.task = task;
}
 
 类所在包
 类方法
 同包方法