Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9063675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:03:48+00:00 2026-06-16T16:03:48+00:00

I’m relatively new to gradle. In order to create an automated deployment script on

  • 0

I’m relatively new to gradle.
In order to create an automated deployment script on a cluster, I have created a bunch of Custom tasks that will depend on each other. For example:

class StartSchedulerTask extends SchedulerTask {
    @TaskAction
    void start() {
        dependsOn env.nodes.name.collect {"startTomcat_$it"}
        println "Starting quartz on node: ${node}"
    }
}

in build.gradle, i have dynamically created the tasks:

project.extensions.environment.nodes.each { TomcatNode n ->
    String name = n.name
    task "nodeInit_$name"(type: DeployToNodeInitTask) {
                node(n)
    }
    task "stopWorker_$name"(type: StopWorkerTask) {
        node(n)
    }
    task "stopTomcat_$name"(type: StopTomcatTask){
        node(n)
    }
    task "updateAppConfigs_$name"(type: UpdateAppConfigsTask){
        node(n)
        apps(V3Application.ALL_APPS)
        buildName('develop')
    }
    task "deployWars_$name"(type: DeployWarsTask){
        node(n)
        apps(V3Application.ALL_APPS)
        buildName('develop')
    }
    task "startTomcat_$name"(type: StartTomcatTask){
        node(n)
    }
    task "startWorker_$name"(type: StartWorkerTask){
        node(n)
    }
    task "terminateNode_$name"(type: DeployToNodeTerminationTask){
        node(n)
    }
}
task stopScheduler(type: StopSchedulerTask) {
    environment(environment)
}
task startScheduler(type: StartSchedulerTask) {
    environment(environment)
}

The default task is configured to be startScheduler, which is the last step of the deployment process, the idea being that the task graph, once it is built, will take care of the correct execution order of my tasks.

However, when I print out the task graph, the only task listed is startScheduler. Am I missing something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:03:49+00:00Added an answer on June 16, 2026 at 4:03 pm

    Thanks to the remark of Peter Niederwieser and Jeffrey, I was able to come up with the full solution I want. I did not mark Peter’s as the answer, because the full answer is below, but it was a necessary hint to the right solution:

    I Created an interface DependencyAware:

    public interface DependencyAware {
        void declareDependencies()
    }
    

    Every task that knows how to declare its dependencies, implements this interface. For example:

    class StartSchedulerTask extends SchedulerTask {
    
        @TaskAction
        void start() {
            println "Starting quartz on node: ${node}"
        }
    
        void declareDependencies() {
            dependsOn env.nodes.name.collect {"startTomcat_$it"}
        }
    }
    

    In my build script:

    tasks.each { Task t ->
        if (t instanceof DependencyAware) {
            t.declareDependencies()
        }
    }
    

    That’s it!

    Thanks for the pointers Peter and Jeffrey

    UPDATE 1

    task deploy(dependsOn: ['backupWars', 'startScheduler'])
    
    task stopScheduler(type: StopSchedulerTask)
    
    task backupWars(type: BackupWarsTask)
    
    project.extensions.targetEnvironment.nodes.each { TomcatNode n ->
        String name = n.name
        [
            ("nodeInit_$name"): DeployToNodeInitTask,
            ("stopWorker_$name"): StopWorkerTask,
            ("stopTomcat_$name"): StopTomcatTask,
            ("updateAppConfigs_$name"): UpdateAppConfigsTask,
            ("deployWars_$name"): DeployWarsTask,
            ("startTomcat_$name"): StartTomcatTask,
            ("startWorker_$name"): StartWorkerTask,
            ("terminateNode_$name"): DeployToNodeTerminationTask,
        ].each { String taskName, Class taskType ->
            task "$taskName"(type: taskType) {
                node(n)
            }
        }
    }
    
    task startScheduler(type: StartSchedulerTask) {
        dryRun(testMode)
    }
    

    The internal dependencies between the different deployment steps, are in the tasks themselves, for example:

    class StartWorkerTask extends WorkerTask {
    
        @TaskAction
        void start() {
            println "Starting worker ${node}"
        }
    
        void declareDependencies() {
            dependsOn tomcatOnThisNodeHasBeenStarted()
        }
    
        String tomcatOnThisNodeHasBeenStarted() {
            "startTomcat_${node.name}"
        }
    }
    

    The declaration of the topology is as follows:

    environments {
        prod {
            nodes {
                (1..2).each { int i ->
                    "w${i}_prod" {
                        host = "prod-n$i"
                        userName = "xxxxx"
                        password = "xxxxx"
                        loadBalancer = 'lb_prod'
                        frontendJkManagerUrl = 'http://web01/jkmanager'
                    }
                }
    
                scheduler {
                    name = "w1_prod"
                }
            }
        }
        rc {
        //rc topology here
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small JavaScript validation script that validates inputs based on Regex. I
I have an autohotkey script which looks up a word in a bilingual dictionary
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.