gradle: failure when plugin task `dependsOn` another plugin task
Tag : gradle , By : dyarborough
Date : March 29 2020, 07:55 AM
wish of those help When the following piece of code is added to build.gradle: project.tasks.each { println it.name } project.afterEvaluate {
addRepositories(project)
addDependencies(project)
addTasks(project)
afterAfterEvaluate(project)
}
|
Gradle Custom Plugin: How To Configure A Gradle Task Using Properties Expected to be Set in the Build Script
Date : November 05 2020, 09:01 AM
wish of those help I'm trying to write a custom Gradle plugin and I need to configure a 'Zip' task on my project using properties the values of which I'm expecting to be provided by the build script (build.gradle). , The solution I went with is: class Oozie implements Plugin<Project> {
static final String DEFAULT_FILE_EXTENSION_FINDER_REGEX = /\.[^\.]+$/
static final String DEFAULT_EXTENSION_REPLACEMENT = '.xml'
final static DEFAULT_WORKFLOW_ROOT = 'workflow'
final static DEFAULT_COORDINATOR_ROOT = 'coordinator'
final static DEFAULT_DSL_DIR = 'dsl'
final static DEFAULT_RESOURCE_DIR = 'resources'
@Override
void apply(Project project) {
project.configurations {
oozieLibs {
description = /Java libraries (jars) to be downloaded and included in the workflow 'lib' directory/
transitive = true
}
}
project.extensions.create('oozie',
OozieExtension,
project.container(OozieSourceSet)
)
project.oozie.sourceSets {
workflow {
dslCopySpec = {
from("${DEFAULT_WORKFLOW_ROOT}/${DEFAULT_DSL_DIR}") {
rename { it - ~DEFAULT_FILE_EXTENSION_FINDER_REGEX + DEFAULT_EXTENSION_REPLACEMENT }
filter(OozieWorkflowDslFilter)
}
}
resourceCopySpec = {
from("${DEFAULT_WORKFLOW_ROOT}/${DEFAULT_RESOURCE_DIR}")
}
}
coordinator {
dslCopySpec = {
from("${DEFAULT_COORDINATOR_ROOT}/${DEFAULT_DSL_DIR}") {
rename { it - ~DEFAULT_FILE_EXTENSION_FINDER_REGEX + DEFAULT_EXTENSION_REPLACEMENT }
filter(OozieWorkflowDslFilter)
}
}
resourceCopySpec = {
from("${DEFAULT_COORDINATOR_ROOT}/${DEFAULT_RESOURCE_DIR}")
}
}
}
project.task('build', type: Zip) {
group = 'Oozie Workflow Build'
with {
archiveName = "${project.name}-${project.version}.${extension}"
destinationDir = project.buildDir
}
}
project.task('clean', type: Delete) {
group = 'Oozie Workflow Build'
delete project.buildDir
}
project.afterEvaluate {
project.build.with {
from(project.configurations.oozieLibs) {
into 'lib'
}
}
project.oozie.sourceSets.each { OozieSourceSet sourceSet ->
project.build.with(sourceSet.dslCopySpec)
project.build.with(sourceSet.resourceCopySpec)
}
}
}
}
|
Task and plugin conflict in Gradle (Failed to apply plugin [class 'org.gradle.langu...)
Tag : gradle , By : Fred Morrison
Date : March 29 2020, 07:55 AM
it should still fix some issue I tried to run a task from build.gradle using the following command: , When it comes to this message:
|
Run a Gradle plugin task when Gradle build is running (not manually from command line)
Date : March 29 2020, 07:55 AM
it fixes the issue From the official documentation: The default run/debug configuration launches the default project activity and uses the Select Deployment Target dialog for target device selection. If the default settings don't suit your project or module, you can customize the run/debug configuration, or even create a new one, at the project, default, and module levels. To edit a run/debug configuration, select Run > Edit Configurations.
|
In a custom gradle plugin, how to add task depends on task which is defined in other plugin?
Date : March 29 2020, 07:55 AM
wish helps you You don't need to know that taskB comes from PluginB to create the dependency on taskA: you can simply reference taskB by its name, as follows: class PluginA implements Plugin<Project> {
void apply(Project project) {
Task taskA = project.task('taskA') {
doLast {
println 'Executing task A from plugin A'
}
}
// create dependency from taskA to taskB
project.tasks.matching { it.name == 'taskB'}.each {
taskA.dependsOn it
}
}
}
class PluginA implements Plugin<Project> {
void apply(Project project) {
Task taskA = project.task('taskA') {
doLast {
println 'Executing task A from plugin A'
}
}
project.pluginManager.withPlugin('pluginB'){
println "pluginB applied => adding dependency from taskA to taskB"
project.afterEvaluate{
taskA.dependsOn project.tasks.getByName('taskB')
}
}
}
}
|