Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option for disabling the default task dependencies #11

Open
deepy opened this issue Mar 15, 2019 · 2 comments
Open

Add an option for disabling the default task dependencies #11

deepy opened this issue Mar 15, 2019 · 2 comments

Comments

@deepy
Copy link
Member

deepy commented Mar 15, 2019

No description provided.

@judos
Copy link

judos commented Sep 15, 2020

Same here:
I have gradle backend and frontend project. And when I run assemble it automatically runs npm_install and npm_run_build which takes forever. I would like to only run the frontend part when I call gradlew jar.

Is there a workaround how to get rid of the default task dependencies?

/edit:
started looking into this a bit. Maybe something would be possible with this syntax:

frontend_npm_install.onlyIf { project.hasProperty('buildFrontend') }

But I'm not sure how to set those properties, as with this:

task frontend_enable_build {
    doLast {
        project.setProperty('buildFrontend', 1)
    }
}

I get the error: Could not set unknown property 'buildFrontend' for project ':allvisa-consult-frontend' of type org.gradle.api.Project.

/edit2:
omg Intellij calls :backend:assemble which automatically causes the frontend everytime to build. So now I can't even start the backend without waiting an extra minute every time.
Intellij runs 'Task :backend:assemble' automatically when I click to start the application main class.

@bsautel
Copy link
Contributor

bsautel commented Sep 15, 2020

This happens because the inputs and outputs of the tasks are not configured correctly. If it was the case, those tasks would run only if needed.

First, I advice you to read this part of the Gradle documentation which explains the concept.

Then, I advice you not to use the virtual npm_install or npm_any tasks because the inputs and outputs cannot be configured on those tasks. Instead, use the npmInstall task, maybe configure node.npmInstallCommand to ci if you want to make npm ci instead of npm install.

Create a buildFrontend or whatever name task with type NpxTask or NpmTask and define correctly its inputs and outputs. You can see an example of how to do this to build an Angular application here (it uses the Kotlin DSL).

Once this will be done, the tasks will run only when needed. They will run if something changed since last build but they will not run if everything is already up-to-date.

I don't think removing the dependencies is the appropriate solution. That would mean for instance that starting from a fresh source code checkout, running gradle build would not build the whole application.

Hope this will help you 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants