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

  • Home
  • SEARCH
  • 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 8150095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:59:00+00:00 2026-06-06T14:59:00+00:00

I am getting the error Cannot add task ‘:webserver:build’ as a task with that

  • 0

I am getting the error

Cannot add task ':webserver:build' as a task with that name already exists.

The weird thing is my hello task is fine but my build task is not AND YES, I am trying to override the Java plugin’s build task.

Master build.gradle file:

allprojects {
   apply plugin: 'java'
   apply plugin: 'eclipse'

   task hello << { task -> println "I'm $task.project.name" }
   task build << { task -> println "I'm building now" }
}

subprojects {

    hello << {println "- I depend on stserver"}

    build << { println "source sets=$sourceSets.main.java.srcDirs" }
}

My child webserver build.gradle file:

sourceSets.main{
  java.srcDirs = ['app']
}

build << { println "source sets=$sourceSets.main.java.srcDirs" }

hello << {println "- Do something specific xxxx"}

What is the deal here, is overriding build special or something? Overriding my own hello task worked fine and I thought overriding build would be just as simple?

  • 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-06T14:59:01+00:00Added an answer on June 6, 2026 at 2:59 pm

    What is the deal here, overriding build is special or something. Overriding my own hello task worked fine and I thought overriding build would be just as simple?

    The reason the behaviour seems different is because build task already exists and hello does not (and not because build is special).

    In gradle you cannot do this:

    task hello << { print "hello" }
    task hello << { print "hello again" }
    

    This will fail with the familiar error: "Cannot add task ':hello' as a task with that name already exists.".

    Since build task already exists, it’s illegal to have a second task build << { ... }. However, it will work for hello task, because it does not exist, and therefore task hello << { ... } is legal, as it’s the first declaration of hello task.

    If you replace your task build << { ... } with build << { ... }, which just adds more behaviour to an existing task, it will “compile” fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting this error saying that it cannot find my javascript function checkpw().
I'm getting an error cannot find symbol method add(java.util.Date), although what I'm passing it
i'm getting error cannot find symbol in netbeans while using the below code for
I am getting the error Cannot resolve TargetName grdGeneral . What I am trying
I'm getting a error LNK1104: cannot open file {path}\jvm.lib when trying tocompile a VS
I'm getting the following error: TypeError: Cannot read property 0.0 from null. (line227) I've
I am getting this error: Column 'Username' cannot be null. First of all I
I'm getting an an error TypeError: Cannot read property 'style' of undefined I'd be
I am getting the following error: InnerException: {Cannot insert the value NULL into column
Can someone please explain why I'm getting this error Type mismatch: cannot convert from

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.