org.gradle.api.tasks.compile.AbstractCompile Java Examples
The following examples show how to use
org.gradle.api.tasks.compile.AbstractCompile.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaBasePlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 7 votes |
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(); } }); }
Example #2
Source File: LegacyJavaComponentPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
/** * 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(); } }); }
Example #3
Source File: AjcAction.java From gradle-plugins with MIT License | 6 votes |
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; }
Example #4
Source File: AjcAction.java From gradle-plugins with MIT License | 6 votes |
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; }
Example #5
Source File: CompileJavaTaskMutator.java From gradle-modules-plugin with MIT License | 6 votes |
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; }
Example #6
Source File: JavaBasePlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
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(); } }); }
Example #7
Source File: TaskManager.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * 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()); } }
Example #8
Source File: JavaLanguagePlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
/** * 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(); } }); }
Example #9
Source File: JavaBasePlugin.java From javaide with GNU General Public License v3.0 | 6 votes |
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(); } }); }
Example #10
Source File: JavaBasePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
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(); } }); }
Example #11
Source File: JavaLanguagePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
/** * 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(); } }); }
Example #12
Source File: JavaBasePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
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(); } }); }
Example #13
Source File: LegacyJavaComponentPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
/** * 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(); } }); }
Example #14
Source File: AbstractCompilesUtil.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * 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()); }
Example #15
Source File: CompileTask.java From gradle-modules-plugin with MIT License | 5 votes |
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); } }); }
Example #16
Source File: MergeClassesHelper.java From gradle-modules-plugin with MIT License | 5 votes |
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()); }
Example #17
Source File: AjcAction.java From gradle-plugins with MIT License | 5 votes |
@Override public void execute(Task task) { if (!enabled.getOrElse(true)) { return; } AspectJCompileSpec spec = createSpec((AbstractCompile) task); new AspectJCompiler(javaExecHandleFactory).execute(spec); }
Example #18
Source File: PostCompilationAction.java From byte-buddy with Apache License 2.0 | 5 votes |
/** * {@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()); } }
Example #19
Source File: AspectJPostCompileWeavingPlugin.java From gradle-plugins with MIT License | 5 votes |
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; }
Example #20
Source File: AjcAction.java From gradle-plugins with MIT License | 5 votes |
@Override public void execute(Task task) { if (!enabled.getOrElse(true)) { return; } AspectJCompileSpec spec = createSpec((AbstractCompile) task); new AspectJCompiler(javaExecHandleFactory).execute(spec); }
Example #21
Source File: AspectJPostCompileWeavingPlugin.java From gradle-plugins with MIT License | 5 votes |
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; }
Example #22
Source File: ByteBuddyPlugin.java From byte-buddy with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ public void apply(Project project) { project.getTasks().withType(AbstractCompile.class, PostCompilationAction.of(project)); }
Example #23
Source File: VariantScope.java From javaide with GNU General Public License v3.0 | 4 votes |
public void setJavaCompilerTask( @NonNull AndroidTask<? extends AbstractCompile> javaCompileTask) { this.javaCompilerTask = javaCompileTask; }
Example #24
Source File: VariantScope.java From javaide with GNU General Public License v3.0 | 4 votes |
@Nullable public AndroidTask<? extends AbstractCompile> getJavaCompilerTask() { return javaCompilerTask; }
Example #25
Source File: BaseVariantImpl.java From javaide with GNU General Public License v3.0 | 4 votes |
@NonNull @Override public AbstractCompile getJavaCompiler() { return getVariantData().javaCompilerTask; }
Example #26
Source File: MergeClassesHelper.java From gradle-modules-plugin with MIT License | 4 votes |
public Stream<AbstractCompile> allCompileTaskStream() { return Stream.concat(Stream.of(javaCompileTask()), otherCompileTaskStream()); }
Example #27
Source File: MergeClassesHelper.java From gradle-modules-plugin with MIT License | 4 votes |
public Stream<AbstractCompile> otherCompileTaskStream() { return otherCompileTaskNameStream() .map(name -> helper().findTask(name, AbstractCompile.class)) .flatMap(Optional::stream); }
Example #28
Source File: BaseVariant.java From javaide with GNU General Public License v3.0 | 2 votes |
/** * Returns the Java Compiler task which can be either javac or jack depending on the project * configuration. */ @NonNull AbstractCompile getJavaCompiler();
Example #29
Source File: PostCompilationAction.java From byte-buddy with Apache License 2.0 | 2 votes |
/** * 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)); }
Example #30
Source File: TransformationAction.java From byte-buddy with Apache License 2.0 | 2 votes |
/** * 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; }