use of org.gradle.api.tasks.compile.JavaCompile in project gradle by gradle.
the class JavaBasePlugin method configureSourceSetDefaults.
private void configureSourceSetDefaults(Project project, final JavaPluginExtension javaPluginExtension) {
javaPluginExtension.getSourceSets().all(sourceSet -> {
ConventionMapping outputConventionMapping = ((IConventionAware) sourceSet.getOutput()).getConventionMapping();
ConfigurationContainer configurations = project.getConfigurations();
defineConfigurationsForSourceSet(sourceSet, configurations);
definePathsForSourceSet(sourceSet, outputConventionMapping, project);
createProcessResourcesTask(sourceSet, sourceSet.getResources(), project);
TaskProvider<JavaCompile> compileTask = createCompileJavaTask(sourceSet, sourceSet.getJava(), project);
createClassesTask(sourceSet, project);
configureLibraryElements(compileTask, sourceSet, configurations, project.getObjects());
configureTargetPlatform(compileTask, sourceSet, configurations);
JvmPluginsHelper.configureOutputDirectoryForSourceSet(sourceSet, sourceSet.getJava(), project, compileTask, compileTask.map(JavaCompile::getOptions));
});
}
use of org.gradle.api.tasks.compile.JavaCompile in project core-java by SpineEventEngine.
the class ModelVerifier method createClassLoaderForProject.
private static URLClassLoader createClassLoaderForProject(Project project) {
final Collection<JavaCompile> tasks = allJavaCompile(project);
final URL[] compiledCodePath = extractDestinationDirs(tasks);
log().debug("Initializing ClassLoader for URLs: {}", deepToString(compiledCodePath));
try {
// Caught exception.
@SuppressWarnings("ClassLoaderInstantiation") final URLClassLoader result = new URLClassLoader(compiledCodePath, ModelVerifier.class.getClassLoader());
return result;
} catch (SecurityException e) {
throw new IllegalStateException("Cannot analyze project source code.", e);
}
}
use of org.gradle.api.tasks.compile.JavaCompile in project gradle by gradle.
the class JavaBasePlugin method createCompileJavaTaskForBinary.
private void createCompileJavaTaskForBinary(final SourceSet sourceSet, final SourceDirectorySet sourceDirectorySet, final Project target) {
JavaCompile compileTask = target.getTasks().create(sourceSet.getCompileJavaTaskName(), JavaCompile.class);
compileTask.setDescription("Compiles " + sourceDirectorySet + ".");
compileTask.setSource(sourceDirectorySet);
ConventionMapping conventionMapping = compileTask.getConventionMapping();
conventionMapping.map("classpath", new Callable<Object>() {
public Object call() throws Exception {
return sourceSet.getCompileClasspath();
}
});
SourceSetUtil.configureAnnotationProcessorPath(sourceSet, compileTask.getOptions(), target);
SourceSetUtil.configureOutputDirectoryForSourceSet(sourceSet, sourceDirectorySet, compileTask, target);
}
use of org.gradle.api.tasks.compile.JavaCompile in project spring-boot by spring-projects.
the class JavaPluginAction method configureAdditionalMetadataLocations.
private void configureAdditionalMetadataLocations(JavaCompile compile) {
SourceSetContainer sourceSets = compile.getProject().getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
sourceSets.stream().filter((candidate) -> candidate.getCompileJavaTaskName().equals(compile.getName())).map((match) -> match.getResources().getSrcDirs()).findFirst().ifPresent((locations) -> compile.doFirst(new AdditionalMetadataLocationsConfigurer(locations)));
}
use of org.gradle.api.tasks.compile.JavaCompile in project gradle-apt-plugin by tbroyer.
the class AptPlugin34to42 method configureCompileTaskForSourceSet.
@Override
protected void configureCompileTaskForSourceSet(Project project, final SourceSet sourceSet, AbstractCompile task, CompileOptions compileOptions) {
if (!(task instanceof JavaCompile)) {
prevImpl.configureCompileTaskForSourceSet(project, sourceSet, task, compileOptions);
return;
}
compileOptions.setAnnotationProcessorPath(project.files(new Callable<FileCollection>() {
@Override
public FileCollection call() {
return new DslObject(sourceSet).getConvention().getPlugin(AptPlugin.AptSourceSetConvention.class).getAnnotationProcessorPath();
}
}));
task.getConvention().getPlugin(AptPlugin.AptConvention.class).setGeneratedSourcesDestinationDir(new Callable<File>() {
@Override
public File call() {
return new DslObject(sourceSet.getOutput()).getConvention().getPlugin(AptPlugin.AptSourceSetOutputConvention.class).getGeneratedSourcesDir();
}
});
}
Aggregations