ghik
ghik

Reputation: 10764

How to properly replace Gradle 'jar' task?

I am trying to force Gradle to create jar my own way. I wrote my own Gradle task (separate class) to do this and now I want to replace the default jar task with it, so that:

I'm struggling to do this and I'm having a lot of trouble to achieve this. For example, I was unable to force the build task to always use my new task.

I would really appreciate it if someone could support me with a short howto.

Upvotes: 8

Views: 3740

Answers (1)

Peter Niederwieser
Peter Niederwieser

Reputation: 123960

This should work:

jar {
    // reset actions
    actions = []
    // add your action that performs the work based
    // on the configuration (e.g. 'source') of this task
    doLast { ... }
}

Upvotes: 4

Related Questions