Java Code Examples for org.gradle.language.base.plugins.LifecycleBasePlugin
The following examples show how to use
org.gradle.language.base.plugins.LifecycleBasePlugin. These examples are extracted from open source projects.
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 Project: gradle-cpd-plugin Source File: CpdPlugin.java License: Apache License 2.0 | 6 votes |
private void logWarningIfCheckTaskOnTaskGraph(Project project, TaskExecutionGraph graph) { if (logger.isWarnEnabled()) { Optional<Task> lastCheckTask = graph.getAllTasks().stream().sorted(reverseOrder()) .filter(t -> t.getName().endsWith(LifecycleBasePlugin.CHECK_TASK_NAME)).findFirst(); if (lastCheckTask.isPresent()) { // it is possible to just execute a task before "check", e.g. "compileJava" Task task = lastCheckTask.get(); String message = "\n" + "WARNING: Due to the absence of '" + LifecycleBasePlugin.class.getSimpleName() + "' on " + project + " the task ':" + TASK_NAME_CPD_CHECK + "' could not be added to task graph. Therefore CPD will not be executed. To prevent this, manually add a task dependency of ':" + TASK_NAME_CPD_CHECK + "' to a '" + LifecycleBasePlugin.CHECK_TASK_NAME + "' task of a subproject.\n" + "1) Directly to " + task.getProject() + ":\n" + " " + task.getName() + ".dependsOn(':" + TASK_NAME_CPD_CHECK + "')\n" + "2) Indirectly, e.g. via " + project + ":\n" + " project('" + task.getProject().getPath() + "') {\n" + " plugins.withType(LifecycleBasePlugin) { // <- just required if 'java' plugin is applied within subproject\n" + " " + task.getName() + ".dependsOn(" + TASK_NAME_CPD_CHECK + ")\n" + " }\n" + " }\n"; logger.warn(message); } } }
Example 2
Source Project: pushfish-android Source File: BasePlugin.java License: BSD 2-Clause "Simplified" License | 5 votes |
public void apply(Project project) { project.getPlugins().apply(LifecycleBasePlugin.class); BasePluginConvention convention = new BasePluginConvention(project); project.getConvention().getPlugins().put("base", convention); configureBuildConfigurationRule(project); configureUploadRules(project); configureUploadArchivesTask(); configureArchiveDefaults(project, convention); configureConfigurations(project); configureAssemble(project); }
Example 3
Source Project: transport Source File: TransportPlugin.java License: BSD 2-Clause "Simplified" License | 5 votes |
/** * Configures SourceSets, dependencies and tasks related to each Transport UDF platform */ private void configurePlatform(Project project, Platform platform, SourceSet mainSourceSet, SourceSet testSourceSet, File baseOutputDir) { SourceSet sourceSet = configureSourceSet(project, platform, mainSourceSet, baseOutputDir); configureGenerateWrappersTask(project, platform, mainSourceSet, sourceSet); List<TaskProvider<? extends Task>> packagingTasks = configurePackagingTasks(project, platform, sourceSet, mainSourceSet); // Add Transport tasks to build task dependencies project.getTasks().named(LifecycleBasePlugin.BUILD_TASK_NAME).configure(task -> task.dependsOn(packagingTasks)); TaskProvider<Test> testTask = configureTestTask(project, platform, mainSourceSet, testSourceSet); project.getTasks().named(LifecycleBasePlugin.CHECK_TASK_NAME).configure(task -> task.dependsOn(testTask)); }
Example 4
Source Project: javaide Source File: BasePlugin.java License: GNU General Public License v3.0 | 5 votes |
public void apply(Project project) { project.getPluginManager().apply(LifecycleBasePlugin.class); BasePluginConvention convention = new BasePluginConvention(project); project.getConvention().getPlugins().put("base", convention); configureBuildConfigurationRule(project); configureUploadRules(project); configureUploadArchivesTask(); configureArchiveDefaults(project, convention); configureConfigurations(project); configureAssemble((ProjectInternal) project); }
Example 5
Source Project: javaide Source File: JavaBasePlugin.java License: GNU General Public License v3.0 | 5 votes |
private void createBinaryLifecycleTask(SourceSet sourceSet, Project target) { sourceSet.compiledBy(sourceSet.getClassesTaskName()); Task binaryLifecycleTask = target.task(sourceSet.getClassesTaskName()); binaryLifecycleTask.setGroup(LifecycleBasePlugin.BUILD_GROUP); binaryLifecycleTask.setDescription("Assembles " + sourceSet.getOutput() + "."); binaryLifecycleTask.dependsOn(sourceSet.getOutput().getDirs()); binaryLifecycleTask.dependsOn(sourceSet.getCompileJavaTaskName()); binaryLifecycleTask.dependsOn(sourceSet.getProcessResourcesTaskName()); }
Example 6
Source Project: gradle-plugins Source File: AggregateJacocoReportPlugin.java License: MIT License | 5 votes |
@Override public void apply(Project project) { project.getPlugins().apply(JacocoPlugin.class); project.getTasks().register("aggregateJacocoReport", JacocoReport.class, reportTask -> { reportTask.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP); reportTask.setDescription(String.format("Generates aggregated code coverage report for the %s project.", project.getPath())); project.allprojects(subproject -> { subproject.getPlugins().withType(JavaPlugin.class, javaPlugin -> { SourceSetContainer sourceSets = subproject.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets(); SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); reportTask.sourceSets(main); }); subproject.getTasks() .withType(Test.class) .forEach(reportTask::executionData); }); JacocoPluginExtension reportingExtension = project.getExtensions().getByType(JacocoPluginExtension.class); reportTask.getReports().getHtml().setEnabled(true); reportTask.getReports().all(report -> { if (report.getOutputType().equals(Report.OutputType.DIRECTORY)) { report.setDestination(project.provider(() -> new File(reportingExtension.getReportsDir(), reportTask.getName() + "/" + report.getName()))); } else { report.setDestination(project.provider(() -> new File(reportingExtension.getReportsDir(), reportTask.getName() + "/" + reportTask.getName() + "." + report.getName()))); } }); }); }
Example 7
Source Project: gradle-plugins Source File: AggregateJacocoReportPlugin.java License: MIT License | 5 votes |
@Override public void apply(Project project) { project.getPlugins().apply(JacocoPlugin.class); project.getTasks().register("aggregateJacocoReport", JacocoReport.class, reportTask -> { reportTask.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP); reportTask.setDescription(String.format("Generates aggregated code coverage report for the %s project.", project.getPath())); project.allprojects(subproject -> { subproject.getPlugins().withType(JavaPlugin.class, javaPlugin -> { SourceSetContainer sourceSets = subproject.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets(); SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); reportTask.sourceSets(main); }); subproject.getTasks() .withType(Test.class) .forEach(reportTask::executionData); }); JacocoPluginExtension reportingExtension = project.getExtensions().getByType(JacocoPluginExtension.class); reportTask.getReports().getHtml().setEnabled(true); reportTask.getReports().all(report -> { if (report.getOutputType().equals(Report.OutputType.DIRECTORY)) { report.setDestination(project.provider(() -> new File(reportingExtension.getReportsDir(), reportTask.getName() + "/" + report.getName()))); } else { report.setDestination(project.provider(() -> new File(reportingExtension.getReportsDir(), reportTask.getName() + "/" + reportTask.getName() + "." + report.getName()))); } }); }); }
Example 8
Source Project: Pushjet-Android Source File: BasePlugin.java License: BSD 2-Clause "Simplified" License | 5 votes |
public void apply(Project project) { project.getPlugins().apply(LifecycleBasePlugin.class); BasePluginConvention convention = new BasePluginConvention(project); project.getConvention().getPlugins().put("base", convention); configureBuildConfigurationRule(project); configureUploadRules(project); configureUploadArchivesTask(); configureArchiveDefaults(project, convention); configureConfigurations(project); configureAssemble(project); }
Example 9
Source Project: gradle-cpd-plugin Source File: CpdPlugin.java License: Apache License 2.0 | 5 votes |
private void createTask(Project project) { TaskProvider<Cpd> taskProvider = project.getTasks().register(TASK_NAME_CPD_CHECK, Cpd.class, task -> { task.setDescription("Run CPD analysis for all sources"); project.getAllprojects().forEach(p -> p.getPlugins().withType(JavaBasePlugin.class, plugin -> p.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(sourceSet -> sourceSet.getAllJava().getSrcDirs().forEach(task::source) ) ) ); }); project.getPlugins().withType(LifecycleBasePlugin.class, plugin -> project.getTasks().findByName(LifecycleBasePlugin.CHECK_TASK_NAME).dependsOn(taskProvider)); }
Example 10
Source Project: gradle-cpd-plugin Source File: CpdPluginTest.java License: Apache License 2.0 | 5 votes |
static Stream<Class<? extends Plugin>> CpdPlugin_shouldAddCpdCheckTaskAsDependencyOfCheckLifecycleTaskIfPluginIsApplied() { return Stream.of( LifecycleBasePlugin.class, BasePlugin.class, LanguageBasePlugin.class, JavaBasePlugin.class, JavaPlugin.class, GroovyPlugin.class, CppPlugin.class ); }
Example 11
Source Project: pushfish-android Source File: LegacyJavaComponentPlugin.java License: BSD 2-Clause "Simplified" License | 4 votes |
private void createBinaryLifecycleTask(ClassDirectoryBinarySpecInternal binary, Project target) { Task binaryLifecycleTask = target.task(binary.getNamingScheme().getLifecycleTaskName()); binaryLifecycleTask.setGroup(LifecycleBasePlugin.BUILD_GROUP); binaryLifecycleTask.setDescription(String.format("Assembles %s.", binary)); binary.setBuildTask(binaryLifecycleTask); }
Example 12
Source Project: transport Source File: TransportPlugin.java License: BSD 2-Clause "Simplified" License | 4 votes |
/** * Creates and configures a task to run tests written using the Unified Testing Framework against a given platform */ private TaskProvider<Test> configureTestTask(Project project, Platform platform, SourceSet mainSourceSet, SourceSet testSourceSet) { /* Configures the classpath configuration to run platform-specific tests. E.g. For the Presto platform, configurations { prestoTestClasspath { extendsFrom testImplementation } } dependencies { prestoTestClasspath sourceSets.main.output, sourceSets.test.output prestoTestClasspath 'com.linkedin.transport:transportable-udfs-test-presto' } */ Configuration testClasspath = project.getConfigurations() .create(platform.getName() + "TestClasspath", config -> config.extendsFrom(getConfigurationForSourceSet(project, testSourceSet, IMPLEMENTATION))); addDependencyToConfiguration(project, testClasspath, mainSourceSet.getOutput()); addDependencyToConfiguration(project, testClasspath, testSourceSet.getOutput()); platform.getDefaultTestDependencyConfigurations() .forEach(dependencyConfiguration -> addDependencyToConfiguration(project, testClasspath, dependencyConfiguration.getDependencyString())); /* Creates the test task for a given platform. E.g. For the Presto platform, task prestoTest(type: Test, dependsOn: test) { group 'Verification' description 'Runs the Presto tests.' testClassesDirs = sourceSets.test.output.classesDirs classpath = configurations.prestoTestClasspath useTestNG() } */ return project.getTasks().register(testTaskName(platform), Test.class, task -> { task.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP); task.setDescription("Runs Transport UDF tests on " + platform.getName()); task.setTestClassesDirs(testSourceSet.getOutput().getClassesDirs()); task.setClasspath(testClasspath); task.useTestNG(); task.mustRunAfter(project.getTasks().named("test")); }); }
Example 13
Source Project: curiostack Source File: StaticSitePlugin.java License: MIT License | 4 votes |
@Override public void apply(Project project) { project.getPlugins().apply(NodePlugin.class); var config = StaticSiteExtension.create(project); var mergeSite = project .getTasks() .register( "mergeSite", Copy.class, t -> { t.from("src"); t.into("build/site"); for (SiteProject site : config.getSites().get()) { site.getProject() .getPlugins() .withType( LifecycleBasePlugin.class, unused -> t.dependsOn( site.getProject() .getTasks() .named(LifecycleBasePlugin.ASSEMBLE_TASK_NAME))); t.from(site.getBuildDir(), copy -> copy.into(site.getOutputSubDir())); } }); var assemble = project.getTasks().named("assemble"); assemble.configure(t -> t.dependsOn(mergeSite)); var yarn = project.getRootProject().getTasks().named("yarn"); var deployAlpha = project .getTasks() .register( "deployAlpha", GcloudTask.class, t -> { t.dependsOn(assemble); // TODO(choko): Remove this major hack - the command line has two --project flags // and we're just lucky the later is used. t.args( config .getAppEngineProject() .map( appEngineProject -> ImmutableList.of( "app", "deploy", "--project=" + appEngineProject))); }); var deployProd = project .getTasks() .register( "deployProd", NodeTask.class, t -> { t.dependsOn(yarn, assemble); t.args( config .getFirebaseProject() .map( firebaseProject -> ImmutableList.of( "run", "firebase", "--project", firebaseProject, "deploy"))); }); project .getTasks() .register( "preview", NodeTask.class, t -> { t.dependsOn(yarn, assemble); t.args("run", "superstatic", "--port=8080"); }); CurioGenericCiPlugin.addToReleaseBuild(project, deployProd); project.afterEvaluate( unused -> { if (config.getAutoDeployAlpha().get()) { CurioGenericCiPlugin.addToMasterBuild(project, deployAlpha); } }); }
Example 14
Source Project: Pushjet-Android Source File: LegacyJavaComponentPlugin.java License: BSD 2-Clause "Simplified" License | 4 votes |
private void createBinaryLifecycleTask(ClassDirectoryBinarySpecInternal binary, Project target) { Task binaryLifecycleTask = target.task(binary.getNamingScheme().getLifecycleTaskName()); binaryLifecycleTask.setGroup(LifecycleBasePlugin.BUILD_GROUP); binaryLifecycleTask.setDescription(String.format("Assembles %s.", binary)); binary.setBuildTask(binaryLifecycleTask); }