How to add/replace processed jars as jar artifacts/outputs in new configuration?


(Eckhart Pedersen) #1

We have a task to do some custom processing on jar files once they are built through the normal jar task, which amongst other things includes signing the jar file through the ant signing task (the included signing functionality in gradle does not work for us).

We have tried adding our custom processing to the existing jar task, e.g. through a “doLast” and though “finalizedBy”, but because the processed jar files have been signed, this does not play nicely with unit tests, which are unsigned.

Instead I think a good solution might be to add a new “signed” configuration, complete with tasks, artifacts and so on, on which e.g. our release tasks could depend to get the signed jar files instead of the default jar files. The only problem is, I do not know how to make this work, and that is after doing extensive reading on the subject and even buying the book “Gradle in Action”.

###My Questions

  1. AFAIK, creating a new configuration is just a matter of declaring it, correct?
  2. I then need to specify that our “signJar” task is creating some output, and that that output should be the main/default artifact of the new configuration. How do I do that?
  3. When step 1 and 2 is complete, can i get all custom signed dependencies of a given project by copying “from configurations.signed”?
  4. Is there anything else I need to know?